From 46be16314ded023c3e230c81539581fd1ac6acd6 Mon Sep 17 00:00:00 2001 From: Alessandro Coglio Date: Thu, 30 Nov 2023 22:51:58 -0800 Subject: [PATCH] Make a function name more descriptive. --- node/bft/src/gateway.rs | 4 ++-- node/router/src/lib.rs | 4 ++-- node/tcp/src/lib.rs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/node/bft/src/gateway.rs b/node/bft/src/gateway.rs index 8e54c8badb..a8f2823ce6 100644 --- a/node/bft/src/gateway.rs +++ b/node/bft/src/gateway.rs @@ -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, @@ -266,7 +266,7 @@ impl Gateway { /// 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. diff --git a/node/router/src/lib.rs b/node/router/src/lib.rs index b51284190b..d8f96f1b86 100644 --- a/node/router/src/lib.rs +++ b/node/router/src/lib.rs @@ -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}; @@ -217,7 +217,7 @@ impl Router { /// 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. diff --git a/node/tcp/src/lib.rs b/node/tcp/src/lib.rs index c9694466e2..3d0d059c5b 100644 --- a/node/tcp/src/lib.rs +++ b/node/tcp/src/lib.rs @@ -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(),