From c1191d5f8368e25bbf4b90365a26861947fdfeb9 Mon Sep 17 00:00:00 2001 From: Max Inden Date: Wed, 8 Apr 2020 10:31:45 +0200 Subject: [PATCH] protocols/kad/behaviour: Return peers independent of record existence (#1544) A node receiving a `GetRecord` request first checks whether it has the given record. If it does have the record it does not return closer nodes. A node that knows the record for the given key is likely within a neighborhood of nodes that know the record as well. In addition the node likely knows its neighboorhood well. When querying for a key with a quorum of 1 the above behavior of only returning the record but not any close peers is fine. Once one queries with a higher quorum having a node respond with the record as well as close nodes is likely going to speed up the query, given that the returned peers probably know the record as well. --- protocols/kad/src/behaviour.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/protocols/kad/src/behaviour.rs b/protocols/kad/src/behaviour.rs index fab9fbd6f72..d243aff3a28 100644 --- a/protocols/kad/src/behaviour.rs +++ b/protocols/kad/src/behaviour.rs @@ -1278,13 +1278,7 @@ where None => None }; - // If no record is found, at least report known closer peers. - let closer_peers = - if record.is_none() { - self.find_closest(&kbucket::Key::new(key), &source) - } else { - Vec::new() - }; + let closer_peers = self.find_closest(&kbucket::Key::new(key), &source); self.queued_events.push_back(NetworkBehaviourAction::NotifyHandler { peer_id: source,