-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a KademliaHandler #580
Conversation
1199eb5
to
21f8b4d
Compare
e1519f6
to
34dcaed
Compare
34dcaed
to
5bc0684
Compare
Good work. |
This is ready for review. While a lot of details should be fleshed out, I'd really like to get this in soon-ish, as Kademlia is still totally non-working at the moment. Notable changes:
|
use std::vec; | ||
|
||
/// Trait allowing retreival of information necessary for the Kadmelia system to work. | ||
pub trait KademliaTopology: Topology { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the Topology
constraint? KademliaTopology
does not depend on anything in Topology
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Kademlia behaviour needs to be able to call addresses_of_peer
on the topology in order to answer Kademlia requests from remotes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, by requiring both bounds: where TTopology: Topology + KademliaTopology
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
KademliaTopology
is a trait specifically for topologies that can be used by the Kademlia behaviour, hence why it depends on Topology
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise, by following that logic, we should have four traits, AddKadDiscoveredAddress
, ClosestPeer
, AddProvider
and GetProviders
, and we would require AddKadDiscoveredAddress + ClosestPeer + AddProvider + GetProviders + Topology
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the suggestion to use A + B + C + D
would have come up only if B: A, C: B, D: C
already existed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
> git diff --check master
examples/ipfs-kad.rs:53: trailing whitespace.
+
protocols/kad/src/protocol.rs:475: trailing whitespace.
+
protocols/kad/src/protocol.rs:511: trailing whitespace.
+
protocols/kad/src/protocol.rs:515: trailing whitespace.
+
protocols/kad/src/protocol.rs:518: trailing whitespace.
+
protocols/kad/src/protocol.rs:523: trailing whitespace.
+
protocols/kad/src/protocol.rs:536: trailing whitespace.
+
protocols/kad/src/protocol.rs:538: trailing whitespace.
+
protocols/kad/src/query.rs
Outdated
if peer_id == result_source { | ||
match state { | ||
state @ QueryPeerState::InProgress(_) => *state = QueryPeerState::Succeeded, | ||
_ => (), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if let
?
* upstream/master: substream -> substreams (libp2p#720) Enhance the swarm a bit (libp2p#711) multiaddr: change UDP constant from 17 to 273. (libp2p#714) Add &message.source in println! as per … (libp2p#705) Use UpgradeError::into_io_error (libp2p#709) Revamp the documentation of the root of core (libp2p#684) Fix core-derive (libp2p#707) Chore/grammar (libp2p#701) Add a KademliaHandler (libp2p#580) Add 'of' (libp2p#700)
Adds a
KademliaHandler
that generates Kademlia requests and responses.Needs some improvements before merging.
Based on #573