From 7dcb20b076d8f68841906cd6e4938897e6e77c4d Mon Sep 17 00:00:00 2001 From: Sergey Kroshnin Date: Thu, 12 Mar 2020 17:31:08 +0300 Subject: [PATCH] Delay inactive/gap cache bootstrap start for 30 seconds (#2631) instead of 5 seconds. To allow more frequent new blocks arrival with realtime network & kess usage for expensive bootstrap --- nano/node/active_transactions.cpp | 5 ++--- nano/node/gap_cache.cpp | 5 ++--- nano/secure/common.cpp | 1 + nano/secure/common.hpp | 1 + 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/nano/node/active_transactions.cpp b/nano/node/active_transactions.cpp index a2c84669..3ef813ca 100644 --- a/nano/node/active_transactions.cpp +++ b/nano/node/active_transactions.cpp @@ -975,11 +975,10 @@ bool nano::active_transactions::inactive_votes_bootstrap_check (std::vectornetwork_params.network.is_test_network () ? now + std::chrono::milliseconds (5) : now + std::chrono::seconds (5), [node_l, hash_a]() { + node.alarm.add (std::chrono::steady_clock::now () + node.network_params.bootstrap.gap_cache_bootstrap_start_interval, [node_l, hash_a]() { auto transaction (node_l->store.tx_begin_read ()); if (!node_l->store.block_exists (transaction, hash_a)) { diff --git a/nano/node/gap_cache.cpp b/nano/node/gap_cache.cpp index bf1be781..e57f2f9c 100644 --- a/nano/node/gap_cache.cpp +++ b/nano/node/gap_cache.cpp @@ -86,11 +86,10 @@ bool nano::gap_cache::bootstrap_check (std::vector const & voters { start_bootstrap = true; } - if (start_bootstrap) + if (start_bootstrap && !node.ledger.block_exists (hash_a)) { auto node_l (node.shared ()); - auto now (std::chrono::steady_clock::now ()); - node.alarm.add (node_l->network_params.network.is_test_network () ? now + std::chrono::milliseconds (5) : now + std::chrono::seconds (5), [node_l, hash_a]() { + node.alarm.add (std::chrono::steady_clock::now () + node.network_params.bootstrap.gap_cache_bootstrap_start_interval, [node_l, hash_a]() { auto transaction (node_l->store.tx_begin_read ()); if (!node_l->store.block_exists (transaction, hash_a)) { diff --git a/nano/secure/common.cpp b/nano/secure/common.cpp index f75a57b8..c66f4720 100644 --- a/nano/secure/common.cpp +++ b/nano/secure/common.cpp @@ -158,6 +158,7 @@ nano::bootstrap_constants::bootstrap_constants (nano::network_constants & networ frontier_retry_limit = network_constants.is_test_network () ? 2 : 16; lazy_retry_limit = network_constants.is_test_network () ? 2 : frontier_retry_limit * 10; lazy_destinations_retry_limit = network_constants.is_test_network () ? 1 : frontier_retry_limit / 4; + gap_cache_bootstrap_start_interval = network_constants.is_test_network () ? std::chrono::milliseconds (5) : std::chrono::milliseconds (30 * 1000); } /* Convenience constants for core_test which is always on the test network */ diff --git a/nano/secure/common.hpp b/nano/secure/common.hpp index 338237bc..1781ba20 100644 --- a/nano/secure/common.hpp +++ b/nano/secure/common.hpp @@ -455,6 +455,7 @@ public: unsigned frontier_retry_limit; unsigned lazy_retry_limit; unsigned lazy_destinations_retry_limit; + std::chrono::milliseconds gap_cache_bootstrap_start_interval; }; /** Constants whose value depends on the active network */