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:
Matt Joiner 2019-03-12 20:08:07 +11:00 committed by GitHub
parent 07573a0bc4
commit ac6772539b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -297,6 +297,9 @@ func (r *dhtQueryRunner) queryPeer(proc process.Process, p peer.ID) {
r.Lock()
r.result = res
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.
// must be async, as we're one of the children, and Close blocks.