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
cd31cea3
Commit
cd31cea3
authored
Jan 30, 2015
by
Juan Batiz-Benet
Committed by
Brian Tiger Chow
Feb 01, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(bitswap/network/ipfs) ignore self as provider
parent
b4cd1252
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
2 deletions
+6
-2
network/ipfs_impl.go
network/ipfs_impl.go
+6
-2
No files found.
network/ipfs_impl.go
View file @
cd31cea3
...
@@ -110,6 +110,9 @@ func (bsnet *impl) FindProvidersAsync(ctx context.Context, k util.Key, max int)
...
@@ -110,6 +110,9 @@ func (bsnet *impl) FindProvidersAsync(ctx context.Context, k util.Key, max int)
connectedPeers
:=
bsnet
.
host
.
Network
()
.
Peers
()
connectedPeers
:=
bsnet
.
host
.
Network
()
.
Peers
()
out
:=
make
(
chan
peer
.
ID
,
len
(
connectedPeers
))
// just enough buffer for these connectedPeers
out
:=
make
(
chan
peer
.
ID
,
len
(
connectedPeers
))
// just enough buffer for these connectedPeers
for
_
,
id
:=
range
connectedPeers
{
for
_
,
id
:=
range
connectedPeers
{
if
id
==
bsnet
.
host
.
ID
()
{
continue
// ignore self as provider
}
out
<-
id
out
<-
id
}
}
...
@@ -117,9 +120,10 @@ func (bsnet *impl) FindProvidersAsync(ctx context.Context, k util.Key, max int)
...
@@ -117,9 +120,10 @@ func (bsnet *impl) FindProvidersAsync(ctx context.Context, k util.Key, max int)
defer
close
(
out
)
defer
close
(
out
)
providers
:=
bsnet
.
routing
.
FindProvidersAsync
(
ctx
,
k
,
max
)
providers
:=
bsnet
.
routing
.
FindProvidersAsync
(
ctx
,
k
,
max
)
for
info
:=
range
providers
{
for
info
:=
range
providers
{
if
info
.
ID
!
=
bsnet
.
host
.
ID
()
{
// dont add addrs for ourselves.
if
info
.
ID
=
=
bsnet
.
host
.
ID
()
{
bsnet
.
host
.
Peerstore
()
.
AddAddresses
(
info
.
ID
,
info
.
Addrs
)
continue
// ignore self as provider
}
}
bsnet
.
host
.
Peerstore
()
.
AddAddresses
(
info
.
ID
,
info
.
Addrs
)
select
{
select
{
case
<-
ctx
.
Done
()
:
case
<-
ctx
.
Done
()
:
return
return
...
...
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