Skip to content

Commit

Permalink
Removing usage of block_processor::flush from bootstrap_legacy and re…
Browse files Browse the repository at this point in the history
…moving bootstrap_processor::flush.
  • Loading branch information
clemahieu committed Jan 31, 2024
1 parent 701dbfd commit 0ce4ed4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
11 changes: 0 additions & 11 deletions nano/node/blockprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down
1 change: 0 additions & 1 deletion nano/node/blockprocessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ();
Expand Down
10 changes: 6 additions & 4 deletions nano/node/bootstrap/bootstrap_legacy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ())
{
Expand Down

0 comments on commit 0ce4ed4

Please sign in to comment.