Ban peers that fail handshake
@@ -28,7 +28,7 @@ use crate::core::pow::Difficulty;
use crate::handshake::Handshake;
use crate::peer::Peer;
use crate::peers::Peers;
-use crate::store::PeerStore;
+use crate::store::{PeerStore, State};
use crate::types::{Capabilities, ChainAdapter, Error, NetAdapter, P2PConfig, TxHashSetRead};
use crate::util::{Mutex, StopState};
use chrono::prelude::{DateTime, Utc};
@@ -87,6 +87,7 @@ impl Server {
let sc = stream.try_clone();
if let Err(e) = self.handle_new_peer(stream) {
warn!("Error accepting peer {}: {:?}", peer_addr.to_string(), e);
+ let _ = self.peers.update_state(peer_addr, State::Banned);
} else if let Ok(s) = sc {
connected_sockets.insert(peer_addr, s);
}
