Skip to content

Commit

Permalink
add version_string ban logic
Browse files Browse the repository at this point in the history
  • Loading branch information
nkysg committed Jan 27, 2023
1 parent 07d3afb commit d62fb0b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions network/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ use std::collections::HashMap;
use std::ops::RangeInclusive;
use std::sync::Arc;

const BARNARD_HARD_FORK_PEER_VERSION_STRING_PREFIX: &str = "barnard_rollback_block_fix";

pub struct NetworkActorService {
worker: Option<NetworkWorker>,
inner: Inner,
Expand Down Expand Up @@ -135,6 +137,16 @@ impl EventHandler<Self, Event> for NetworkActorService {
"Connected peer {:?}, protocol: {}, notif_protocols: {:?}, rpc_protocols: {:?}",
remote, protocol, notif_protocols, rpc_protocols
);
if let Some(ref ver_str) = version_string {
if !ver_str.contains(BARNARD_HARD_FORK_PEER_VERSION_STRING_PREFIX) {
debug!(
"ban {} peer {:?}",
BARNARD_HARD_FORK_PEER_VERSION_STRING_PREFIX, remote
);
self.inner.network_service.ban_peer(remote, true);
return;
}
}
let peer_event = PeerEvent::Open(remote.into(), info.clone());
self.inner.on_peer_connected(
remote.into(),
Expand Down

0 comments on commit d62fb0b

Please sign in to comment.