Skip to content

Commit

Permalink
client/network/src/discovery: Adjust to Kademlia API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mxinden committed Jul 1, 2020
1 parent ec2ab79 commit 4baa1b4
Show file tree
Hide file tree
Showing 5 changed files with 154 additions and 75 deletions.
156 changes: 109 additions & 47 deletions Cargo.lock

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

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -254,3 +254,8 @@ zeroize = { opt-level = 3 }
[profile.release]
# Substrate runtime requires unwinding.
panic = "unwind"


[patch.crates-io]
libp2p-kad = { git = "https://github.com/romanb/rust-libp2p", branch = "kad-bucket-control" }
libp2p = { git = "https://github.com/romanb/rust-libp2p", branch = "kad-bucket-control" }
10 changes: 8 additions & 2 deletions client/network/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ use libp2p::swarm::{NetworkBehaviourAction, NetworkBehaviourEventProcess, PollPa
use log::debug;
use sp_consensus::{BlockOrigin, import_queue::{IncomingBlock, Origin}};
use sp_runtime::{traits::{Block as BlockT, NumberFor}, ConsensusEngineId, Justification};
use std::{borrow::Cow, collections::VecDeque, iter, task::{Context, Poll}, time::Duration};
use std::{
borrow::Cow,
collections::{HashSet, VecDeque},
iter,
task::{Context, Poll},
time::Duration,
};

/// General behaviour of the network. Combines all protocols together.
#[derive(NetworkBehaviour)]
Expand Down Expand Up @@ -124,7 +130,7 @@ impl<B: BlockT, H: ExHashT> Behaviour<B, H> {
}

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

Expand Down
Loading

0 comments on commit 4baa1b4

Please sign in to comment.