Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if existing block is already confirmed in active_transactions add #2055

merged 15 commits into from Jun 10, 2019
Changes from 1 commit
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.


Just for now

Add function block_confirmed_or_not_exists ()

  • Loading branch information...
SergiySW committed Jun 2, 2019
commit 5d60b0180e57c9270bfdd24ce0cbbee628b804b2
@@ -427,13 +427,13 @@ bool nano::active_transactions::add (std::shared_ptr<nano::block> block_a, std::
auto error (true);
if (!stopped)
auto hash (block_a->hash ());
// Check if existing block is already confirmed
assert (node.ledger.block_exists (block_a->type (), hash) ? !node.ledger.block_confirmed (hash) : true);
assert (node.ledger.block_confirmed_or_not_exists (*block_a));
auto root (block_a->qualified_root ());
auto existing (roots.find (root));
if (existing == roots.end ())
auto hash (block_a->hash ());
auto election (nano::make_shared<nano::election> (node.config.use_memory_pool, node, block_a, confirmation_action_a));
uint64_t difficulty (0);
auto error (nano::work_validate (*block_a, &difficulty));
@@ -1062,10 +1062,16 @@ bool nano::ledger::block_confirmed (nano::transaction const & transaction_a, nan
return confirmed;

bool nano::ledger::block_confirmed (nano::block_hash const & hash_a) const
bool nano::ledger::block_confirmed_or_not_exists (nano::block const & block_a) const
bool result (true);
auto hash (block_a.hash ());
auto transaction (store.tx_begin_read ());
return block_confirmed (transaction, hash_a);
if (store.block_exists (transaction, block_a.type (), hash))
result = block_confirmed (transaction, hash);
return result;

namespace nano
@@ -28,7 +28,7 @@ class ledger final
std::shared_ptr<nano::block> successor (nano::transaction const &, nano::qualified_root const &);
std::shared_ptr<nano::block> forked_block (nano::transaction const &, nano::block const &);
bool block_confirmed (nano::transaction const & transaction_a, nano::block_hash const & hash_a) const;
bool block_confirmed (nano::block_hash const & hash_a) const;
bool block_confirmed_or_not_exists (nano::block const & block_a) const;
nano::block_hash latest (nano::transaction const &, nano::account const &);
nano::block_hash latest_root (nano::transaction const &, nano::account const &);
nano::block_hash representative (nano::transaction const &, nano::block_hash const &);
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.