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-dms3
Commits
647da1bd
Commit
647da1bd
authored
Jan 16, 2015
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #582 from jbenet/addr-explosion
addr-explosion mitigated adding
parents
f78d4141
c057cea6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
5 deletions
+14
-5
exchange/bitswap/network/ipfs_impl.go
exchange/bitswap/network/ipfs_impl.go
+3
-1
routing/dht/handlers.go
routing/dht/handlers.go
+2
-2
routing/dht/query.go
routing/dht/query.go
+5
-0
routing/dht/routing.go
routing/dht/routing.go
+4
-2
No files found.
exchange/bitswap/network/ipfs_impl.go
View file @
647da1bd
...
...
@@ -112,7 +112,9 @@ func (bsnet *impl) FindProvidersAsync(ctx context.Context, k util.Key, max int)
defer
close
(
out
)
providers
:=
bsnet
.
routing
.
FindProvidersAsync
(
ctx
,
k
,
max
)
for
info
:=
range
providers
{
bsnet
.
host
.
Peerstore
()
.
AddAddresses
(
info
.
ID
,
info
.
Addrs
)
if
info
.
ID
!=
bsnet
.
host
.
ID
()
{
// dont add addrs for ourselves.
bsnet
.
host
.
Peerstore
()
.
AddAddresses
(
info
.
ID
,
info
.
Addrs
)
}
select
{
case
<-
ctx
.
Done
()
:
return
...
...
routing/dht/handlers.go
View file @
647da1bd
...
...
@@ -236,9 +236,9 @@ func (dht *IpfsDHT) handleAddProvider(ctx context.Context, p peer.ID, pmes *pb.M
}
log
.
Infof
(
"received provider %s for %s (addrs: %s)"
,
p
,
key
,
pi
.
Addrs
)
for
_
,
maddr
:=
range
pi
.
A
ddrs
{
if
pi
.
ID
!=
dht
.
self
{
// dont add own a
ddrs
.
// add the received addresses to our peerstore.
dht
.
peerstore
.
Add
Address
(
p
,
maddr
)
dht
.
peerstore
.
Add
PeerInfo
(
pi
)
}
dht
.
providers
.
AddProvider
(
key
,
p
)
}
...
...
routing/dht/query.go
View file @
647da1bd
...
...
@@ -254,6 +254,11 @@ func (r *dhtQueryRunner) queryPeer(cg ctxgroup.ContextGroup, p peer.ID) {
}
else
if
len
(
res
.
closerPeers
)
>
0
{
log
.
Debugf
(
"PEERS CLOSER -- worker for: %v (%d closer peers)"
,
p
,
len
(
res
.
closerPeers
))
for
_
,
next
:=
range
res
.
closerPeers
{
if
next
.
ID
==
r
.
query
.
dht
.
self
{
// dont add self.
log
.
Debugf
(
"PEERS CLOSER -- worker for: %v found self"
,
p
)
continue
}
// add their addresses to the dialer's peerstore
r
.
query
.
dht
.
peerstore
.
AddPeerInfo
(
next
)
r
.
addPeerToQuery
(
cg
.
Context
(),
next
.
ID
)
...
...
routing/dht/routing.go
View file @
647da1bd
...
...
@@ -223,8 +223,10 @@ func (dht *IpfsDHT) closerPeersSingle(ctx context.Context, key u.Key, p peer.ID)
var
out
[]
peer
.
ID
for
_
,
pbp
:=
range
pmes
.
GetCloserPeers
()
{
pid
:=
peer
.
ID
(
pbp
.
GetId
())
dht
.
peerstore
.
AddAddresses
(
pid
,
pbp
.
Addresses
())
out
=
append
(
out
,
pid
)
if
pid
!=
dht
.
self
{
// dont add self
dht
.
peerstore
.
AddAddresses
(
pid
,
pbp
.
Addresses
())
out
=
append
(
out
,
pid
)
}
}
return
out
,
nil
}
...
...
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