Skip to content

Commit

Permalink
fix: disconnect from old version peers after peer exchange (#194)
Browse files Browse the repository at this point in the history
  • Loading branch information
stringhandler authored Dec 3, 2024
1 parent 7d44224 commit 893c51c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/server/p2p/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,13 @@ where S: ShareChain
return;
}

// If they are talking an older version, disconnect
if response.info.version != PROTOCOL_VERSION {
warn!(target: LOG_TARGET, squad = &self.config.squad; "Peer {} has an outdated version, disconnecting", peer_id);
let _ = self.swarm.disconnect_peer_id(peer_id);
return;
}

// if we are a seed peer, end here
if self.config.is_seed_peer {
return;
Expand Down Expand Up @@ -1244,7 +1251,6 @@ where S: ShareChain
response,
} => match response {
Ok(response) => {
info!(target: LOG_TARGET, squad = &self.config.squad; "REQ-RES share chain sync response: {response:?}");
self.handle_sync_missing_blocks_response(response).await;
},
Err(error) => {
Expand Down Expand Up @@ -1298,7 +1304,6 @@ where S: ShareChain
request_response::Message::Response { request_id, response } => {
match response {
Ok(response) => {
info!(target: LOG_TARGET, squad = &self.config.squad; "REQ-RES catch up sync response: {response:?}");
self.handle_catch_up_sync_response(response).await;
},
Err(error) => {
Expand Down

0 comments on commit 893c51c

Please sign in to comment.