Removing usage of block_processor::flush from bootstrap_legacy and removing bootstrap_processor::flush.

This commit is contained in:
Colin LeMahieu 2024-01-26 17:55:08 +00:00
commit 0ce4ed40b5
No known key found for this signature in database
GPG key ID: 43708520C8DFB938
3 changed files with 6 additions and 16 deletions

View file

@ -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 };

View file

@ -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 ();

View file

@ -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 ())
{