Handle rollbacks when cementing
This commit is contained in:
parent
2badf06647
commit
0747d4afe4
2 changed files with 12 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
|||
#include <nano/lib/thread_roles.hpp>
|
||||
#include <nano/node/confirming_set.hpp>
|
||||
#include <nano/secure/ledger.hpp>
|
||||
#include <nano/secure/ledger_set_any.hpp>
|
||||
#include <nano/secure/ledger_set_confirmed.hpp>
|
||||
#include <nano/store/component.hpp>
|
||||
#include <nano/store/write_queue.hpp>
|
||||
|
@ -180,6 +181,13 @@ void nano::confirming_set::run_batch (std::unique_lock<std::mutex> & lock)
|
|||
|
||||
stats.inc (nano::stat::type::confirming_set, nano::stat::detail::cementing);
|
||||
|
||||
// The block might be rolled back before it's fully cemented
|
||||
if (!ledger.any.block_exists (transaction, hash))
|
||||
{
|
||||
stats.inc (nano::stat::type::confirming_set, nano::stat::detail::missing_block);
|
||||
break;
|
||||
}
|
||||
|
||||
auto added = ledger.confirm (transaction, hash, config.max_blocks);
|
||||
if (!added.empty ())
|
||||
{
|
||||
|
|
|
@ -865,7 +865,10 @@ std::deque<std::shared_ptr<nano::block>> nano::ledger::confirm (secure::write_tr
|
|||
bool refreshed = transaction.refresh_if_needed ();
|
||||
if (refreshed)
|
||||
{
|
||||
release_assert (any.block_exists (transaction, target_hash), "block was rolled back during cementing");
|
||||
if (!any.block_exists (transaction, target_hash))
|
||||
{
|
||||
break; // Block was rolled back during cementing
|
||||
}
|
||||
}
|
||||
|
||||
// Early return might leave parts of the dependency tree unconfirmed
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue