Fixed banning process.

This commit is contained in:
Revertron
2021-04-19 23:36:08 +02:00
parent 068ff395f7
commit e0425f46dc
3 changed files with 10 additions and 3 deletions
+1 -3
View File
@@ -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
+5
View File
@@ -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); });
+4
View File
@@ -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<String> {
let mut result: Vec<String> = Vec::new();
for (_, peer) in self.peers.iter() {