Skip to content

Commit

Permalink
Merge pull request #2907 from AleoHQ/feat/rename-ip-function
Browse files Browse the repository at this point in the history
Consider making a function name more descriptive.
  • Loading branch information
howardwu authored Dec 18, 2023
2 parents 38c4d4c + 46be163 commit 76efa35
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions node/bft/src/gateway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ use snarkos_node_bft_ledger_service::LedgerService;
use snarkos_node_sync::communication_service::CommunicationService;
use snarkos_node_tcp::{
is_bogon_ip,
is_unspecified_ip,
is_unspecified_or_broadcast_ip,
protocols::{Disconnect, Handshake, OnConnect, Reading, Writing},
Config,
Connection,
Expand Down Expand Up @@ -266,7 +266,7 @@ impl<N: Network> Gateway<N> {

/// Returns `true` if the given IP is not this node, is not a bogon address, and is not unspecified.
pub fn is_valid_peer_ip(&self, ip: SocketAddr) -> bool {
!self.is_local_ip(ip) && !is_bogon_ip(ip.ip()) && !is_unspecified_ip(ip.ip())
!self.is_local_ip(ip) && !is_bogon_ip(ip.ip()) && !is_unspecified_or_broadcast_ip(ip.ip())
}

/// Returns the resolver.
Expand Down
4 changes: 2 additions & 2 deletions node/router/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub use routing::*;

use crate::messages::NodeType;
use snarkos_account::Account;
use snarkos_node_tcp::{is_bogon_ip, is_unspecified_ip, Config, Tcp};
use snarkos_node_tcp::{is_bogon_ip, is_unspecified_or_broadcast_ip, Config, Tcp};
use snarkvm::prelude::{Address, Network, PrivateKey, ViewKey};

use anyhow::{bail, Result};
Expand Down Expand Up @@ -217,7 +217,7 @@ impl<N: Network> Router<N> {

/// Returns `true` if the given IP is not this node, is not a bogon address, and is not unspecified.
pub fn is_valid_peer_ip(&self, ip: &SocketAddr) -> bool {
!self.is_local_ip(ip) && !is_bogon_ip(ip.ip()) && !is_unspecified_ip(ip.ip())
!self.is_local_ip(ip) && !is_bogon_ip(ip.ip()) && !is_unspecified_or_broadcast_ip(ip.ip())
}

/// Returns the node type.
Expand Down
2 changes: 1 addition & 1 deletion node/tcp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub fn is_bogon_ip(ip: IpAddr) -> bool {
}

/// Checks if the given IP address is unspecified or broadcast.
pub fn is_unspecified_ip(ip: IpAddr) -> bool {
pub fn is_unspecified_or_broadcast_ip(ip: IpAddr) -> bool {
match ip {
IpAddr::V4(ipv4) => ipv4.is_unspecified() || ipv4.is_broadcast(),
ipv6 => ipv6.is_unspecified(),
Expand Down

0 comments on commit 76efa35

Please sign in to comment.