Use a Kademlia instance per ProtocolId. (#5045)

This commit is contained in:
Toralf Wittner
2020-04-16 10:43:40 +02:00
committed by GitHub
parent 980b635c8d
commit 4db45a85de
3 changed files with 358 additions and 199 deletions
+4 -13
View File
@@ -16,7 +16,7 @@
use crate::{
config::Role,
debug_info, discovery::DiscoveryBehaviour, discovery::DiscoveryOut,
debug_info, discovery::{DiscoveryBehaviour, DiscoveryConfig, DiscoveryOut},
Event, ObservedRole, DhtEvent, ExHashT,
};
use crate::protocol::{self, light_client_handler, message::Roles, CustomMessageOutcome, Protocol};
@@ -67,28 +67,19 @@ pub enum BehaviourOut<B: BlockT> {
impl<B: BlockT, H: ExHashT> Behaviour<B, H> {
/// Builds a new `Behaviour`.
pub async fn new(
pub fn new(
substrate: Protocol<B, H>,
role: Role,
user_agent: String,
local_public_key: PublicKey,
known_addresses: Vec<(PeerId, Multiaddr)>,
enable_mdns: bool,
allow_private_ipv4: bool,
discovery_only_if_under_num: u64,
block_requests: protocol::BlockRequests<B>,
light_client_handler: protocol::LightClientHandler<B>,
disco_config: DiscoveryConfig,
) -> Self {
Behaviour {
substrate,
debug_info: debug_info::DebugInfoBehaviour::new(user_agent, local_public_key.clone()),
discovery: DiscoveryBehaviour::new(
local_public_key,
known_addresses,
enable_mdns,
allow_private_ipv4,
discovery_only_if_under_num,
).await,
discovery: disco_config.finish(),
block_requests,
light_client_handler,
events: Vec::new(),