From 6003adbfa4c2bb8beec9588e29f0e0be5df88328 Mon Sep 17 00:00:00 2001 From: Jos Dehaes Date: Sun, 10 Mar 2024 23:33:04 +0100 Subject: [PATCH] fix: rename parameter --- cli/src/commands/start.rs | 6 +++--- node/router/src/handshake.rs | 4 ++-- node/router/src/heartbeat.rs | 4 ++-- node/router/src/inbound.rs | 2 +- node/router/src/lib.rs | 10 +++++----- node/src/node.rs | 4 ++-- node/src/validator/mod.rs | 4 ++-- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/cli/src/commands/start.rs b/cli/src/commands/start.rs index b655be403a..796061cd9f 100644 --- a/cli/src/commands/start.rs +++ b/cli/src/commands/start.rs @@ -145,9 +145,9 @@ pub struct Start { /// If development mode is enabled, specify the custom bonded balances as a json object. (default: None) dev_bonded_balances: Option, - #[clap(long = "allow-outside-peers")] + #[clap(long = "allow-external-peers")] /// If the flag is set, the validator will allow untrusted peers to connect - allow_outside_peers: bool, + allow_external_peers: bool, } impl Start { @@ -531,7 +531,7 @@ impl Start { // Initialize the node. let bft_ip = if self.dev.is_some() { self.bft } else { None }; match node_type { - NodeType::Validator => Node::new_validator(self.node, bft_ip, rest_ip, self.rest_rps, account, &trusted_peers, &trusted_validators, genesis, cdn, storage_mode, self.allow_outside_peers).await, + NodeType::Validator => Node::new_validator(self.node, bft_ip, rest_ip, self.rest_rps, account, &trusted_peers, &trusted_validators, genesis, cdn, storage_mode, self.allow_external_peers).await, NodeType::Prover => Node::new_prover(self.node, account, &trusted_peers, genesis, storage_mode).await, NodeType::Client => Node::new_client(self.node, rest_ip, self.rest_rps, account, &trusted_peers, genesis, cdn, storage_mode).await, } diff --git a/node/router/src/handshake.rs b/node/router/src/handshake.rs index 8a45cee439..d5ef8cf87a 100644 --- a/node/router/src/handshake.rs +++ b/node/router/src/handshake.rs @@ -265,9 +265,9 @@ impl Router { bail!("Dropping connection request from '{peer_ip}' (already connected)") } // Only allow trusted peers to connect if we are a validator - // (unless allow_outside_peers is set) + // (unless allow_external_peers is set) let is_validator = self.node_type().is_validator(); - if is_validator && !self.allow_outside_peers() && !self.is_trusted(&peer_ip) { + if is_validator && !self.allow_external_peers() && !self.is_trusted(&peer_ip) { bail!("Dropping connection request from '{peer_ip}' (untrusted)") } // Ensure the peer is not restricted. diff --git a/node/router/src/heartbeat.rs b/node/router/src/heartbeat.rs index 599da2c6ea..7498b7d033 100644 --- a/node/router/src/heartbeat.rs +++ b/node/router/src/heartbeat.rs @@ -109,7 +109,7 @@ pub trait Heartbeat: Outbound { let is_validator = self.router().node_type().is_validator(); // Skip if the node is not requesting peers. - if is_validator && !self.router().allow_outside_peers() { + if is_validator && !self.router().allow_external_peers() { return; } @@ -223,7 +223,7 @@ pub trait Heartbeat: Outbound { self.router().connect(peer_ip); } let is_validator = self.router().node_type().is_validator(); - if !is_validator || self.router().allow_outside_peers() { + if !is_validator || self.router().allow_external_peers() { // Request more peers from the connected peers. for peer_ip in self.router().connected_peers().into_iter().choose_multiple(rng, 3) { self.send(peer_ip, Message::PeerRequest(PeerRequest)); diff --git a/node/router/src/inbound.rs b/node/router/src/inbound.rs index a44098042d..10c032936c 100644 --- a/node/router/src/inbound.rs +++ b/node/router/src/inbound.rs @@ -125,7 +125,7 @@ pub trait Inbound: Reading + Outbound { if !self.router().cache.contains_outbound_peer_request(peer_ip) { bail!("Peer '{peer_ip}' is not following the protocol (unexpected peer response)") } - if self.router().node_type().is_validator() && !self.router().allow_outside_peers() { + if self.router().node_type().is_validator() && !self.router().allow_external_peers() { bail!("Not accepting peer response from '{peer_ip}' (validator gossip is disabled)"); } diff --git a/node/router/src/lib.rs b/node/router/src/lib.rs index 5bba3cac41..239202b7d4 100644 --- a/node/router/src/lib.rs +++ b/node/router/src/lib.rs @@ -96,7 +96,7 @@ pub struct InnerRouter { /// The boolean flag for the development mode. is_dev: bool, /// If the flag is set, the node will not engage in P2P gossip to request more peers. - allow_outside_peers: bool, + allow_external_peers: bool, } impl Router { @@ -118,7 +118,7 @@ impl Router { trusted_peers: &[SocketAddr], max_peers: u16, is_dev: bool, - allow_outside_peers: bool, + allow_external_peers: bool, ) -> Result { // Initialize the TCP stack. let tcp = Tcp::new(Config::new(node_ip, max_peers)); @@ -136,7 +136,7 @@ impl Router { restricted_peers: Default::default(), handles: Default::default(), is_dev, - allow_outside_peers, + allow_external_peers, }))) } } @@ -256,8 +256,8 @@ impl Router { } /// Returns `true` if the node is not engaging in P2P gossip to request more peers. - pub fn allow_outside_peers(&self) -> bool { - self.allow_outside_peers + pub fn allow_external_peers(&self) -> bool { + self.allow_external_peers } /// Returns the listener IP address from the (ambiguous) peer address. diff --git a/node/src/node.rs b/node/src/node.rs index 563f81f152..5fcdd5ea5d 100644 --- a/node/src/node.rs +++ b/node/src/node.rs @@ -50,7 +50,7 @@ impl Node { genesis: Block, cdn: Option, storage_mode: StorageMode, - allow_outside_peers: bool, + allow_external_peers: bool, ) -> Result { Ok(Self::Validator(Arc::new( Validator::new( @@ -64,7 +64,7 @@ impl Node { genesis, cdn, storage_mode, - allow_outside_peers, + allow_external_peers, ) .await?, ))) diff --git a/node/src/validator/mod.rs b/node/src/validator/mod.rs index 8add855f6f..cf8bbf13b8 100644 --- a/node/src/validator/mod.rs +++ b/node/src/validator/mod.rs @@ -83,7 +83,7 @@ impl> Validator { genesis: Block, cdn: Option, storage_mode: StorageMode, - allow_outside_peers: bool, + allow_external_peers: bool, ) -> Result { // Prepare the shutdown flag. let shutdown: Arc = Default::default(); @@ -126,7 +126,7 @@ impl> Validator { trusted_peers, Self::MAXIMUM_NUMBER_OF_PEERS as u16, matches!(storage_mode, StorageMode::Development(_)), - allow_outside_peers, + allow_external_peers, ) .await?;