diff --git a/nano/node/blockprocessor.cpp b/nano/node/blockprocessor.cpp index e696b5966b..76786fd247 100644 --- a/nano/node/blockprocessor.cpp +++ b/nano/node/blockprocessor.cpp @@ -37,17 +37,6 @@ void nano::block_processor::stop () nano::join_or_pass (processing_thread); } -void nano::block_processor::flush () -{ - flushing = true; - nano::unique_lock<nano::mutex> lock{ mutex }; - while (!stopped && (have_blocks () || active)) - { - condition.wait (lock); - } - flushing = false; -} - std::size_t nano::block_processor::size () { nano::unique_lock<nano::mutex> lock{ mutex }; diff --git a/nano/node/blockprocessor.hpp b/nano/node/blockprocessor.hpp index fc6c7172a0..a53fa80761 100644 --- a/nano/node/blockprocessor.hpp +++ b/nano/node/blockprocessor.hpp @@ -29,7 +29,6 @@ class block_processor final public: explicit block_processor (nano::node &, nano::write_database_queue &); void stop (); - void flush (); std::size_t size (); bool full (); bool half_full (); diff --git a/nano/node/bootstrap/bootstrap_legacy.cpp b/nano/node/bootstrap/bootstrap_legacy.cpp index 446d094646..9badee97cc 100644 --- a/nano/node/bootstrap/bootstrap_legacy.cpp +++ b/nano/node/bootstrap/bootstrap_legacy.cpp @@ -223,10 +223,12 @@ void nano::bootstrap_attempt_legacy::run () condition.wait (lock, [&stopped = stopped, &pulling = pulling] { return stopped || pulling == 0; }); } - // Flushing may resolve forks which can add more pulls - lock.unlock (); - node->block_processor.flush (); - lock.lock (); + // TODO: This check / wait is a heuristic and should be improved. + auto wait_start = std::chrono::steady_clock::now (); + while (!stopped && node->block_processor.size () != 0 && ((std::chrono::steady_clock::now () - wait_start) < std::chrono::seconds{ 10 })) + { + condition.wait_for (lock, std::chrono::milliseconds{ 100 }, [this, node] { return stopped || node->block_processor.size () == 0; }); + } if (start_account.number () != std::numeric_limits<nano::uint256_t>::max ()) {