From bee3669e9b840a3870184a4badc5a36eb88c9079 Mon Sep 17 00:00:00 2001 From: arkpar Date: Tue, 31 May 2016 15:34:25 +0200 Subject: [PATCH] Deactivate peers giving us invalid/empty headers --- sync/src/chain.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sync/src/chain.rs b/sync/src/chain.rs index 277be7fea..569b6402d 100644 --- a/sync/src/chain.rs +++ b/sync/src/chain.rs @@ -319,6 +319,7 @@ impl ChainSync { /// Remove peer from active peer set fn deactivate_peer(&mut self, io: &mut SyncIo, peer_id: PeerId) { + trace!(target: "sync", "Deactivating peer {}", peer_id); self.active_peers.remove(&peer_id); if self.active_peers.is_empty() { trace!(target: "sync", "No more active peers"); @@ -456,6 +457,9 @@ impl ChainSync { } }, SyncState::Blocks | SyncState::NewBlocks | SyncState::Waiting => { + if headers.len() == 0 { + self.deactivate_peer(io, peer_id); // disable the peer for this syncing round if it gives invalid chain + } trace!(target: "sync", "Inserted {} headers", headers.len()); self.blocks.insert_headers(headers); },