Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-bitswap
Commits
4038218e
Unverified
Commit
4038218e
authored
Feb 05, 2019
by
Hannah Howard
Committed by
GitHub
Feb 05, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #59 from ipfs/fix/providers-only
providers: don't add every connected node as a provider
parents
5b807cbc
586a5c00
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
16 deletions
+1
-16
network/ipfs_impl.go
network/ipfs_impl.go
+1
-16
No files found.
network/ipfs_impl.go
View file @
4038218e
...
...
@@ -151,22 +151,7 @@ func (bsnet *impl) ConnectTo(ctx context.Context, p peer.ID) error {
// FindProvidersAsync returns a channel of providers for the given key.
func
(
bsnet
*
impl
)
FindProvidersAsync
(
ctx
context
.
Context
,
k
cid
.
Cid
,
max
int
)
<-
chan
peer
.
ID
{
// Since routing queries are expensive, give bitswap the peers to which we
// have open connections. Note that this may cause issues if bitswap starts
// precisely tracking which peers provide certain keys. This optimization
// would be misleading. In the long run, this may not be the most
// appropriate place for this optimization, but it won't cause any harm in
// the short term.
connectedPeers
:=
bsnet
.
host
.
Network
()
.
Peers
()
out
:=
make
(
chan
peer
.
ID
,
len
(
connectedPeers
))
// just enough buffer for these connectedPeers
for
_
,
id
:=
range
connectedPeers
{
if
id
==
bsnet
.
host
.
ID
()
{
continue
// ignore self as provider
}
out
<-
id
}
out
:=
make
(
chan
peer
.
ID
,
max
)
go
func
()
{
defer
close
(
out
)
providers
:=
bsnet
.
routing
.
FindProvidersAsync
(
ctx
,
k
,
max
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment