Skip to content
Snippets Groups Projects
Commit f514bc38 authored by Nazar Mokrynskyi's avatar Nazar Mokrynskyi Committed by GitHub
Browse files

Ignore boot and reserved nodes with peer ID the same as in local node itself (#11851)

parent 74f0f45b
No related merge requests found
......@@ -148,6 +148,47 @@ where
/// for the network processing to advance. From it, you can extract a `NetworkService` using
/// `worker.service()`. The `NetworkService` can be shared through the codebase.
pub fn new(mut params: Params<B, H, Client>) -> Result<Self, Error> {
// Private and public keys configuration.
let local_identity = params.network_config.node_key.clone().into_keypair()?;
let local_public = local_identity.public();
let local_peer_id = local_public.to_peer_id();
params.network_config.boot_nodes = params
.network_config
.boot_nodes
.into_iter()
.filter(|boot_node| {
if boot_node.peer_id == local_peer_id {
warn!(
target: "sub-libp2p",
"Local peer ID used in bootnode, ignoring: {}",
boot_node,
);
false
} else {
true
}
})
.collect();
params.network_config.default_peers_set.reserved_nodes = params
.network_config
.default_peers_set
.reserved_nodes
.into_iter()
.filter(|reserved_node| {
if reserved_node.peer_id == local_peer_id {
warn!(
target: "sub-libp2p",
"Local peer ID used in reserved node, ignoring: {}",
reserved_node,
);
false
} else {
true
}
})
.collect();
// Ensure the listen addresses are consistent with the transport.
ensure_addresses_consistent_with_transport(
params.network_config.listen_addresses.iter(),
......@@ -190,10 +231,6 @@ where
.extra_sets
.insert(0, transactions_handler_proto.set_config());
// Private and public keys configuration.
let local_identity = params.network_config.node_key.clone().into_keypair()?;
let local_public = local_identity.public();
let local_peer_id = local_public.to_peer_id();
info!(
target: "sub-libp2p",
"🏷 Local node identity is: {}",
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment