diff --git a/src/blockchain/chain.rs b/src/blockchain/chain.rs index e395b49..1ce4538 100644 --- a/src/blockchain/chain.rs +++ b/src/blockchain/chain.rs @@ -635,9 +635,7 @@ impl Chain { } pub fn update_max_height(&mut self, height: u64) { - if height > self.max_height { - self.max_height = height; - } + self.max_height = height; } /// Check if this block can be added to our blockchain diff --git a/src/p2p/network.rs b/src/p2p/network.rs index 28b2e7e..5c8cc39 100644 --- a/src/p2p/network.rs +++ b/src/p2p/network.rs @@ -98,6 +98,11 @@ impl Network { } } + if peers.is_ignored(&address.ip()) { + debug!("Ignoring connection from banned {:?}", &address.ip()); + continue; + } + if yggdrasil_only && !is_yggdrasil(&address.ip()) { debug!("Dropping connection from Internet"); stream.shutdown(Shutdown::Both).unwrap_or_else(|e|{ warn!("Error in shutdown, {}", e); }); diff --git a/src/p2p/peers.rs b/src/p2p/peers.rs index fbdb29c..765608f 100644 --- a/src/p2p/peers.rs +++ b/src/p2p/peers.rs @@ -140,6 +140,10 @@ impl Peers { self.my_id.eq(rand) } + pub fn is_ignored(&self, addr: &IpAddr) -> bool { + self.ignored.contains(addr) + } + pub fn get_peers_for_exchange(&self, peer_address: &SocketAddr) -> Vec { let mut result: Vec = Vec::new(); for (_, peer) in self.peers.iter() {