Skip to content

Commit

Permalink
fix: rename parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
joske committed Mar 10, 2024
1 parent ce1ca02 commit 6003adb
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions cli/src/commands/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<BondedBalances>,

#[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 {
Expand Down Expand Up @@ -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,
}
Expand Down
4 changes: 2 additions & 2 deletions node/router/src/handshake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,9 @@ impl<N: Network> Router<N> {
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.
Expand Down
4 changes: 2 additions & 2 deletions node/router/src/heartbeat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ pub trait Heartbeat<N: Network>: Outbound<N> {

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;
}

Expand Down Expand Up @@ -223,7 +223,7 @@ pub trait Heartbeat<N: Network>: Outbound<N> {
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));
Expand Down
2 changes: 1 addition & 1 deletion node/router/src/inbound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ pub trait Inbound<N: Network>: Reading + Outbound<N> {
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)");
}

Expand Down
10 changes: 5 additions & 5 deletions node/router/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ pub struct InnerRouter<N: Network> {
/// 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<N: Network> Router<N> {
Expand All @@ -118,7 +118,7 @@ impl<N: Network> Router<N> {
trusted_peers: &[SocketAddr],
max_peers: u16,
is_dev: bool,
allow_outside_peers: bool,
allow_external_peers: bool,
) -> Result<Self> {
// Initialize the TCP stack.
let tcp = Tcp::new(Config::new(node_ip, max_peers));
Expand All @@ -136,7 +136,7 @@ impl<N: Network> Router<N> {
restricted_peers: Default::default(),
handles: Default::default(),
is_dev,
allow_outside_peers,
allow_external_peers,
})))
}
}
Expand Down Expand Up @@ -256,8 +256,8 @@ impl<N: Network> Router<N> {
}

/// 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.
Expand Down
4 changes: 2 additions & 2 deletions node/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl<N: Network> Node<N> {
genesis: Block<N>,
cdn: Option<String>,
storage_mode: StorageMode,
allow_outside_peers: bool,
allow_external_peers: bool,
) -> Result<Self> {
Ok(Self::Validator(Arc::new(
Validator::new(
Expand All @@ -64,7 +64,7 @@ impl<N: Network> Node<N> {
genesis,
cdn,
storage_mode,
allow_outside_peers,
allow_external_peers,
)
.await?,
)))
Expand Down
4 changes: 2 additions & 2 deletions node/src/validator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl<N: Network, C: ConsensusStorage<N>> Validator<N, C> {
genesis: Block<N>,
cdn: Option<String>,
storage_mode: StorageMode,
allow_outside_peers: bool,
allow_external_peers: bool,
) -> Result<Self> {
// Prepare the shutdown flag.
let shutdown: Arc<AtomicBool> = Default::default();
Expand Down Expand Up @@ -126,7 +126,7 @@ impl<N: Network, C: ConsensusStorage<N>> Validator<N, C> {
trusted_peers,
Self::MAXIMUM_NUMBER_OF_PEERS as u16,
matches!(storage_mode, StorageMode::Development(_)),
allow_outside_peers,
allow_external_peers,
)
.await?;

Expand Down

0 comments on commit 6003adb

Please sign in to comment.