From 66242464c46e19a391bc8c2287dd04c266842b1b Mon Sep 17 00:00:00 2001 From: Revertron Date: Fri, 8 Oct 2021 09:15:12 +0200 Subject: [PATCH] Removed tight restrictions of blocks sync. Sped up initial sync a lot. --- src/commons/constants.rs | 4 ++-- src/p2p/peers.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/commons/constants.rs b/src/commons/constants.rs index 5339036..2254ee8 100644 --- a/src/commons/constants.rs +++ b/src/commons/constants.rs @@ -40,8 +40,8 @@ pub const UI_REFRESH_DELAY_MS: u128 = 500; pub const LOG_REFRESH_DELAY_SEC: u64 = 60; pub const POLL_TIMEOUT: Option = Some(Duration::from_millis(500)); -/// We start syncing blocks only when we got 8 and more connected nodes -pub const MIN_CONNECTED_NODES_START_SYNC: usize = 8; +/// We start syncing blocks only when we got 4 and more connected nodes +pub const MIN_CONNECTED_NODES_START_SYNC: usize = 4; pub const MAX_RECONNECTS: u32 = 5; pub const MAX_IDLE_SECONDS: u64 = 180; pub const MAX_NODES: usize = 15; diff --git a/src/p2p/peers.rs b/src/p2p/peers.rs index e50b7af..44d0db8 100644 --- a/src/p2p/peers.rs +++ b/src/p2p/peers.rs @@ -282,7 +282,7 @@ impl Peers { // If someone has more blocks we sync if nodes >= MIN_CONNECTED_NODES_START_SYNC { if height < max_height { - let count = min(max_height - height, (nodes - 5) as u64); + let count = min(max_height - height, nodes as u64); self.ask_blocks_from_peers(registry, height, height + count, have_blocks); } }