fix refreshing buckets during query. getting topK peers is more efficient.

This commit is contained in:
Adin Schmahmann
2020-01-21 14:58:18 -08:00
committed by Steven Allen
parent 68b116932f
commit 5cabdf6d13
3 changed files with 13 additions and 12 deletions

View File

@@ -403,7 +403,7 @@ func (dht *IpfsDHT) getValues(ctx context.Context, key string, stopFn func() boo
}
}
if !shortcutTaken {
if !shortcutTaken && ctx.Err() == nil {
kadID := kb.ConvertKey(key)
// refresh the cpl for this key as the query was successful
dht.routingTable.ResetCplRefreshedAtForID(kadID, time.Now())
@@ -678,7 +678,7 @@ func (dht *IpfsDHT) FindPeer(ctx context.Context, id peer.ID) (_ peer.AddrInfo,
return dht.peerstore.PeerInfo(id), nil
} else {
if ctx.Err() != nil {
if ctx.Err() == nil {
kadID := kb.ConvertPeerID(id)
// refresh the cpl for this key as the query was successful
dht.routingTable.ResetCplRefreshedAtForID(kadID, time.Now())