mirror of
https://github.com/fluencelabs/go-libp2p-kad-dht
synced 2025-04-25 14:52:14 +00:00
Add find peer success addr to peerstore (#296)
When a peer is found, add its addr to the peerstore, just like the addresses for closer peers are added. In particular this is helpful for followup queries by the DHT user.
This commit is contained in:
parent
07573a0bc4
commit
ac6772539b
3
query.go
3
query.go
@ -297,6 +297,9 @@ func (r *dhtQueryRunner) queryPeer(proc process.Process, p peer.ID) {
|
|||||||
r.Lock()
|
r.Lock()
|
||||||
r.result = res
|
r.result = res
|
||||||
r.Unlock()
|
r.Unlock()
|
||||||
|
if res.peer != nil {
|
||||||
|
r.query.dht.peerstore.AddAddrs(res.peer.ID, res.peer.Addrs, pstore.TempAddrTTL)
|
||||||
|
}
|
||||||
go r.proc.Close() // signal to everyone that we're done.
|
go r.proc.Close() // signal to everyone that we're done.
|
||||||
// must be async, as we're one of the children, and Close blocks.
|
// must be async, as we're one of the children, and Close blocks.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user