Skip to content

Commit

Permalink
fix: block peer who sends 0 catchup blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
stringhandler committed Dec 30, 2024
1 parent 1a8cc27 commit fdc2a66
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/server/p2p/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1626,6 +1626,11 @@ where S: ShareChain
let mut blocks: Vec<_> = response.into_blocks().into_iter().map(Arc::new).collect();
if blocks.is_empty() {
warn!(target: SYNC_REQUEST_LOG_TARGET, "Peer {} sent 0 blocks for catch up sync", peer);
let _res = self.swarm.disconnect_peer_id(peer);
self.network_peer_store
.write()
.await
.move_to_blacklist(&peer, "Peer sent 0 blocks for catch up sync".to_string());
return;
}
info!(target: SYNC_REQUEST_LOG_TARGET, "Received catch up sync response for chain {} from {} with blocks {}. Their tip: {}:{}", algo, peer, blocks.iter().map(|a| a.height.to_string()).join(", "), their_height, &their_tip_hash.to_hex()[0..8]);
Expand Down

0 comments on commit fdc2a66

Please sign in to comment.