Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Use a Kademlia instance per ProtocolId. #5045

Merged
merged 12 commits into from
Apr 16, 2020
75 changes: 25 additions & 50 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,6 @@ members = [
[profile.release]
# Substrate runtime requires unwinding.
panic = "unwind"

[patch.crates-io]
libp2p = { git = "https://github.com/libp2p/rust-libp2p" }
6 changes: 6 additions & 0 deletions client/network/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.

use crate::{
config::ProtocolId,
debug_info, discovery::DiscoveryBehaviour, discovery::DiscoveryOut, DiscoveryNetBehaviour,
Event, protocol::event::DhtEvent, ExHashT,
};
Expand Down Expand Up @@ -86,6 +87,11 @@ impl<B: BlockT, H: ExHashT> Behaviour<B, H> {
}
}

/// Enable discovery for the given protocol.
pub fn add_discovery(&mut self, p: ProtocolId) {
twittner marked this conversation as resolved.
Show resolved Hide resolved
self.discovery.add_discovery(p)
}

/// Returns the list of nodes that we know exist in the network.
pub fn known_peers(&mut self) -> impl Iterator<Item = &PeerId> {
self.discovery.known_peers()
Expand Down
Loading