Why is Behavior::find_closest_local_peers()
limited to the replication_factor
instead of K_VALUE
?
#5969
Replies: 5 comments 1 reply
-
cc @guillaumemichel since you are more familiar with Kadelima. |
Beta Was this translation helpful? Give feedback.
-
Thanks @drHuangMHT for the heads up! AFAIK the Kademlia
There is no strict requirement that all 3 values should be the same. In your example, it is totally fine to set a replication factor lower than I think the reason for which I would suggest to adapt the code to allow a replication factor distinct from |
Beta Was this translation helpful? Give feedback.
-
Hey @guillaumemichel, Thank you for the quick reply!
Wouldn't it make more sense to limit the number of peers returned in I was wondering if that cascades unexpected behaviour into other parts of the Kad logic, such as bootstrapping / bucket refreshing, because that also relies on |
Beta Was this translation helpful? Give feedback.
-
Example PR of the change that I want to propose: #5971 I don't understand why you would want the amount of results here to be different than |
Beta Was this translation helpful? Give feedback.
-
Fixed now with PR #5971 , thank you @guillaumemichel ! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
When performing a
FIND_NODE
request, we expect a node to return up toK
closest nodes to the key, as specified in the Kademlia protocol. However, Libp2p limits the number of returned nodes to thereplication_factor
:https://github.com/libp2p/rust-libp2p/blob/master/protocols/kad/src/behaviour.rs#L773-L783 .
By default,
replication_factor
is set toK_VALUE
:rust-libp2p/protocols/kad/src/query.rs
Line 274 in f4322c5
However, it can be manually adjusted. For instance, our application sets the replication factor to
7
using this function here:rust-libp2p/protocols/kad/src/behaviour.rs
Line 256 in f4322c5
FIND_NODE
returns only up to7
nodes instead ofK
=20
, which seems unexpected.Could someone clarify the reasoning behind limiting the results to
replication_factor
instead ofK
?Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions