Commit 5858c8cf authored by Brian Tiger Chow's avatar Brian Tiger Chow

fix(routing:dht) implement FindProvidersAsync in terms of FindProviders

until construction is complete on the actual async method

reverts changes from ec50703395098f75946f0bad01816cc54ab18a58

https://github.com/jbenet/go-ipfs/commit/ec50703395098f75946f0bad01816cc54ab18a58
parent a6241103
......@@ -115,8 +115,26 @@ func (dht *IpfsDHT) Provide(ctx context.Context, key u.Key) error {
return nil
}
// FindProvidersAsync runs FindProviders and sends back results over a channel
// NB: not actually async. Used to keep the interface consistent while the
// actual async method, FindProvidersAsync2 is under construction
func (dht *IpfsDHT) FindProvidersAsync(ctx context.Context, key u.Key, count int) <-chan *peer.Peer {
ch := make(chan *peer.Peer)
providers, err := dht.FindProviders(ctx, key)
if err != nil {
close(ch)
return ch
}
go func() {
defer close(ch)
for _, p := range providers {
ch <- p
}
}()
return ch
}
// FIXME: there's a bug here!
func (dht *IpfsDHT) FindProvidersAsync2(ctx context.Context, key u.Key, count int) <-chan *peer.Peer {
peerOut := make(chan *peer.Peer, count)
go func() {
ps := newPeerSet()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment