Extracting root_exists function to check if the root block or account exists.
This commit is contained in:
parent
5e0cb86fa1
commit
d2c943adfe
3 changed files with 7 additions and 1 deletions
|
@ -832,6 +832,11 @@ rai::block_counts rai::block_store::block_count (MDB_txn * transaction_a)
|
|||
return result;
|
||||
}
|
||||
|
||||
bool rai::block_store::root_exists (MDB_txn * transaction_a, rai::uint256_union const & root_a)
|
||||
{
|
||||
return block_exists (transaction_a, root_a) || account_exists (transaction_a, root_a);
|
||||
}
|
||||
|
||||
void rai::block_store::account_del (MDB_txn * transaction_a, rai::account const & account_a)
|
||||
{
|
||||
auto status (mdb_del (transaction_a, accounts, rai::mdb_val (account_a), nullptr));
|
||||
|
|
|
@ -60,6 +60,7 @@ public:
|
|||
void block_del (MDB_txn *, rai::block_hash const &);
|
||||
bool block_exists (MDB_txn *, rai::block_hash const &);
|
||||
rai::block_counts block_count (MDB_txn *);
|
||||
bool root_exists (MDB_txn *, rai::uint256_union const &);
|
||||
|
||||
void frontier_put (MDB_txn *, rai::block_hash const &, rai::account const &);
|
||||
rai::account frontier_get (MDB_txn *, rai::block_hash const &);
|
||||
|
|
|
@ -885,7 +885,7 @@ void rai::bootstrap_attempt::process_fork (MDB_txn * transaction_a, std::shared_
|
|||
{
|
||||
std::lock_guard<std::mutex> lock (mutex);
|
||||
auto root (block_a->root ());
|
||||
if (!node->store.block_exists (transaction_a, block_a->hash ()) && (node->store.block_exists (transaction_a, root) || node->store.account_exists (transaction_a, root)))
|
||||
if (!node->store.block_exists (transaction_a, block_a->hash ()) && node->store.root_exists (transaction_a, block_a->root ()))
|
||||
{
|
||||
std::shared_ptr<rai::block> ledger_block (node->ledger.forked_block (transaction_a, *block_a));
|
||||
if (ledger_block)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue