Commit f76fe2ad authored by Brian Tiger Chow's avatar Brian Tiger Chow Committed by Juan Batiz-Benet

fix(bitswap) always add addresses

parent 90324639
...@@ -180,6 +180,7 @@ func (bs *bitswap) sendWantListTo(ctx context.Context, peers <-chan peer.PeerInf ...@@ -180,6 +180,7 @@ func (bs *bitswap) sendWantListTo(ctx context.Context, peers <-chan peer.PeerInf
for peerToQuery := range peers { for peerToQuery := range peers {
log.Event(ctx, "PeerToQuery", peerToQuery.ID) log.Event(ctx, "PeerToQuery", peerToQuery.ID)
wg.Add(1) wg.Add(1)
bs.network.Peerstore().AddAddresses(peerToQuery.ID, peerToQuery.Addrs)
go func(p peer.ID) { go func(p peer.ID) {
defer wg.Done() defer wg.Done()
if err := bs.send(ctx, p, message); err != nil { if err := bs.send(ctx, p, message); err != nil {
...@@ -212,8 +213,8 @@ func (bs *bitswap) sendWantlistToProviders(ctx context.Context, wantlist *wantli ...@@ -212,8 +213,8 @@ func (bs *bitswap) sendWantlistToProviders(ctx context.Context, wantlist *wantli
defer wg.Done() defer wg.Done()
child, _ := context.WithTimeout(ctx, providerRequestTimeout) child, _ := context.WithTimeout(ctx, providerRequestTimeout)
providers := bs.routing.FindProvidersAsync(child, k, maxProvidersPerRequest) providers := bs.routing.FindProvidersAsync(child, k, maxProvidersPerRequest)
for prov := range providers { for prov := range providers {
bs.network.Peerstore().AddAddresses(prov.ID, prov.Addrs)
if set.TryAdd(prov.ID) { //Do once per peer if set.TryAdd(prov.ID) { //Do once per peer
bs.send(ctx, prov.ID, message) bs.send(ctx, prov.ID, message)
} }
...@@ -265,7 +266,6 @@ func (bs *bitswap) clientWorker(parent context.Context) { ...@@ -265,7 +266,6 @@ func (bs *bitswap) clientWorker(parent context.Context) {
// newer bitswap strategies. // newer bitswap strategies.
child, _ := context.WithTimeout(ctx, providerRequestTimeout) child, _ := context.WithTimeout(ctx, providerRequestTimeout)
providers := bs.routing.FindProvidersAsync(child, ks[0], maxProvidersPerRequest) providers := bs.routing.FindProvidersAsync(child, ks[0], maxProvidersPerRequest)
err := bs.sendWantListTo(ctx, providers) err := bs.sendWantListTo(ctx, providers)
if err != nil { if err != nil {
log.Errorf("error sending wantlist: %s", err) log.Errorf("error sending wantlist: %s", err)
......
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