From 4c48a26f20d800b2098c18b723dfb83cb878f0ad Mon Sep 17 00:00:00 2001 From: SW van Heerden Date: Tue, 12 Sep 2023 11:17:53 +0200 Subject: [PATCH] fix: remove peer (#5757) Description --- Fixes remove peer in header sync Fixes latency counter in block sync Motivation and Context --- Header sync should remove the peer for all errors Block sync should only increase the latency once --- .../core/src/base_node/sync/block_sync/synchronizer.rs | 4 ---- .../core/src/base_node/sync/header_sync/synchronizer.rs | 7 ++----- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/base_layer/core/src/base_node/sync/block_sync/synchronizer.rs b/base_layer/core/src/base_node/sync/block_sync/synchronizer.rs index 0ceb473904..20d93ad53f 100644 --- a/base_layer/core/src/base_node/sync/block_sync/synchronizer.rs +++ b/base_layer/core/src/base_node/sync/block_sync/synchronizer.rs @@ -193,10 +193,6 @@ impl<'a, B: BlockchainBackend + 'static> BlockSynchronizer<'a, B> { } else { self.remove_sync_peer(node_id); } - - if let BlockSyncError::MaxLatencyExceeded { .. } = err { - latency_counter += 1; - } }, } } diff --git a/base_layer/core/src/base_node/sync/header_sync/synchronizer.rs b/base_layer/core/src/base_node/sync/header_sync/synchronizer.rs index 0d793d56fd..7e13dbf2c3 100644 --- a/base_layer/core/src/base_node/sync/header_sync/synchronizer.rs +++ b/base_layer/core/src/base_node/sync/header_sync/synchronizer.rs @@ -151,14 +151,11 @@ impl<'a, B: BlockchainBackend + 'static> HeaderSynchronizer<'a, B> { self.peer_ban_manager .ban_peer_if_required(node_id, &Some(reason.clone())) .await; - - if reason.ban_duration > self.config.short_ban_period { - self.remove_sync_peer(node_id); - } } - if let BlockHeaderSyncError::MaxLatencyExceeded { .. } = err { latency_counter += 1; + } else { + self.remove_sync_peer(node_id); } }, }