Skip to content

Commit f6c995e

Browse files
authored
Merge pull request ipfs/go-bitswap#59 from ipfs/fix/providers-only
providers: don't add every connected node as a provider This commit was moved from ipfs/go-bitswap@4038218
2 parents 317bf06 + 5f5e919 commit f6c995e

File tree

1 file changed

+1
-16
lines changed

1 file changed

+1
-16
lines changed

bitswap/network/ipfs_impl.go

+1-16
Original file line numberDiff line numberDiff line change
@@ -151,22 +151,7 @@ func (bsnet *impl) ConnectTo(ctx context.Context, p peer.ID) error {
151151

152152
// FindProvidersAsync returns a channel of providers for the given key.
153153
func (bsnet *impl) FindProvidersAsync(ctx context.Context, k cid.Cid, max int) <-chan peer.ID {
154-
155-
// Since routing queries are expensive, give bitswap the peers to which we
156-
// have open connections. Note that this may cause issues if bitswap starts
157-
// precisely tracking which peers provide certain keys. This optimization
158-
// would be misleading. In the long run, this may not be the most
159-
// appropriate place for this optimization, but it won't cause any harm in
160-
// the short term.
161-
connectedPeers := bsnet.host.Network().Peers()
162-
out := make(chan peer.ID, len(connectedPeers)) // just enough buffer for these connectedPeers
163-
for _, id := range connectedPeers {
164-
if id == bsnet.host.ID() {
165-
continue // ignore self as provider
166-
}
167-
out <- id
168-
}
169-
154+
out := make(chan peer.ID, max)
170155
go func() {
171156
defer close(out)
172157
providers := bsnet.routing.FindProvidersAsync(ctx, k, max)

0 commit comments

Comments
 (0)