Beispiel #1
0
func (d *dht) Init() error {
	d.m = mesh.FromEndpoint(d.e)
	if d.m == nil {
		panic("kademlia requires the mesh module.")
	}

	d.e.AddHandler(d.prefix+"see", e3x.HandlerFunc(d.handle_see))

	return nil
}
Beispiel #2
0
func (r *ring) Create() error {
	m := mesh.FromEndpoint(r.endpoint)
	if m == nil {
		panic("Chord requires the `mesh` module")
	}

	ring, err := chord.Create(r.conf, newTransport(r.endpoint, m))
	if err != nil {
		return err
	}

	r.ring = ring
	return nil
}
Beispiel #3
0
func (r *ring) Join(existing *e3x.Addr) error {
	m := mesh.FromEndpoint(r.endpoint)
	if m == nil {
		panic("Chord requires the `mesh` module")
	}

	t := newTransport(r.endpoint, m)
	t.registerAddr(existing)
	ring, err := chord.Join(r.conf, t, string(existing.Hashname()))
	if err != nil {
		return err
	}

	r.ring = ring
	return nil
}