This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Use a Kademlia instance per ProtocolId
.
#5045
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This PR changes discovery to use one kademlia instance per protocol ID. The change is motivated by the fact that the single DHT we use now includes incompatible nodes with different protocols. To retain backwards compatibility we currently use a fake `ProtocolId` matching the existing `/ipfs/kad/1.0.0` protocol string. If and when this change is rolled out we can remove it and work solely with `ProtocolId`s taken from the chain specification.
I think libp2p 0.16.2 contains the methods that you're using, so we can remove the |
tomaka
suggested changes
Mar 9, 2020
self.kademlia.get_record(key, Quorum::One) | ||
for k in self.kademlias.values_mut() { | ||
k.get_record(key, Quorum::One) | ||
} | ||
} | ||
|
||
/// Start putting a record into the DHT. Other nodes can later fetch that value with | ||
/// `get_value`. | ||
/// | ||
/// A corresponding `ValuePut` or `ValuePutFailed` event will later be generated. | ||
pub fn put_value(&mut self, key: record::Key, value: Vec<u8>) { |
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.
get_value
and put_value
ultimately should be changed to pass a ProtocolId
to designate which DHT to target.
I'm unsure if we should do this now though.
In case no kademlia instance is registered for some protocol ID.
# Conflicts: # client/network/src/behaviour.rs # client/network/src/discovery.rs # client/network/src/service.rs
tomaka
suggested changes
Apr 15, 2020
As requested this is now set implicitly in `DiscoveryConfig::new`.
tomaka
approved these changes
Apr 15, 2020
Please merge master in order for the Polkadot check to pass. |
tomaka
added
A8-mergeoncegreen
and removed
A0-please_review
Pull request needs code review.
labels
Apr 15, 2020
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR changes discovery to use one kademlia instance per protocol ID. The change is motivated by the fact that the single DHT we use now includes incompatible nodes with different protocols.
To retain backwards compatibility we currently use a fake
ProtocolId
matching the existing/ipfs/kad/1.0.0
protocol string. If and when this change is rolled out we can remove it and work solely withProtocolId
s taken from the chain specification.Currently the implementation relies on changes in libp2p master which have yet to be published so a patch section is added to
Cargo.toml
which should be removed before merging this PR.