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
p2p
go-p2p-kad-dht
Commits
7f60a9d4
Commit
7f60a9d4
authored
Apr 24, 2020
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: don't add addresses for connected peers
They've told us better ones via identify.
parent
e1a40766
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
4 deletions
+11
-4
dht.go
dht.go
+9
-0
query.go
query.go
+1
-1
routing.go
routing.go
+1
-3
No files found.
dht.go
View file @
7f60a9d4
...
...
@@ -32,6 +32,7 @@ import (
"github.com/jbenet/goprocess"
goprocessctx
"github.com/jbenet/goprocess/context"
"github.com/multiformats/go-base32"
ma
"github.com/multiformats/go-multiaddr"
"github.com/multiformats/go-multihash"
)
...
...
@@ -702,3 +703,11 @@ func (dht *IpfsDHT) newContextWithLocalTags(ctx context.Context, extraTags ...ta
)
// ignoring error as it is unrelated to the actual function of this code.
return
ctx
}
func
(
dht
*
IpfsDHT
)
maybeAddAddrs
(
p
peer
.
ID
,
addrs
[]
ma
.
Multiaddr
,
ttl
time
.
Duration
)
{
// Don't add addresses for self or our connected peers. We have better ones.
if
p
==
dht
.
self
||
dht
.
host
.
Network
()
.
Connectedness
(
p
)
==
network
.
Connected
{
return
}
dht
.
peerstore
.
AddAddrs
(
p
,
addrs
,
ttl
)
}
query.go
View file @
7f60a9d4
...
...
@@ -416,7 +416,7 @@ func (q *query) queryPeer(ctx context.Context, ch chan<- *queryUpdate, p peer.ID
// add their addresses to the dialer's peerstore
if
q
.
dht
.
queryPeerFilter
(
q
.
dht
,
*
next
)
{
q
.
dht
.
peerstore
.
AddAddrs
(
next
.
ID
,
next
.
Addrs
,
pstore
.
TempAddrTTL
)
q
.
dht
.
maybe
AddAddrs
(
next
.
ID
,
next
.
Addrs
,
pstore
.
TempAddrTTL
)
saw
=
append
(
saw
,
next
.
ID
)
}
}
...
...
routing.go
View file @
7f60a9d4
...
...
@@ -575,9 +575,7 @@ func (dht *IpfsDHT) findProvidersAsyncRoutine(ctx context.Context, key multihash
// Add unique providers from request, up to 'count'
for
_
,
prov
:=
range
provs
{
if
prov
.
ID
!=
dht
.
self
{
dht
.
peerstore
.
AddAddrs
(
prov
.
ID
,
prov
.
Addrs
,
peerstore
.
TempAddrTTL
)
}
dht
.
maybeAddAddrs
(
prov
.
ID
,
prov
.
Addrs
,
peerstore
.
TempAddrTTL
)
logger
.
Debugf
(
"got provider: %s"
,
prov
)
if
ps
.
TryAdd
(
prov
.
ID
)
{
logger
.
Debugf
(
"using provider: %s"
,
prov
)
...
...
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