Rename exists () to contains ()

This commit is contained in:
Piotr Wójcik 2024-10-15 17:19:01 +02:00
commit b44040347b
7 changed files with 11 additions and 11 deletions

View file

@ -1224,7 +1224,7 @@ TEST (active_elections, activate_inactive)
ASSERT_NE (nullptr, election);
election->force_confirm ();
ASSERT_TIMELY (5s, !node.confirming_set.exists (send2->hash ()));
ASSERT_TIMELY (5s, !node.confirming_set.contains (send2->hash ()));
ASSERT_TIMELY (5s, node.block_confirmed (send2->hash ()));
ASSERT_TIMELY (5s, node.block_confirmed (send->hash ()));

View file

@ -30,7 +30,7 @@ TEST (confirming_set, add_exists)
nano::confirming_set confirming_set{ config, ctx.ledger (), ctx.stats () };
auto send = ctx.blocks ()[0];
confirming_set.add (send->hash ());
ASSERT_TRUE (confirming_set.exists (send->hash ()));
ASSERT_TRUE (confirming_set.contains (send->hash ()));
}
TEST (confirming_set, process_one)
@ -242,7 +242,7 @@ TEST (confirmation_callback, dependent_election)
// Wait for blocks to be confirmed in ledger, callbacks will happen after
ASSERT_TIMELY_EQ (5s, 3, node->stats.count (nano::stat::type::confirmation_height, nano::stat::detail::blocks_confirmed, nano::stat::dir::in));
// Once the item added to the confirming set no longer exists, callbacks have completed
ASSERT_TIMELY (5s, !node->confirming_set.exists (send2->hash ()));
ASSERT_TIMELY (5s, !node->confirming_set.contains (send2->hash ()));
ASSERT_TIMELY_EQ (5s, 1, node->stats.count (nano::stat::type::confirmation_observer, nano::stat::detail::active_quorum, nano::stat::dir::out));
ASSERT_TIMELY_EQ (5s, 1, node->stats.count (nano::stat::type::confirmation_observer, nano::stat::detail::active_conf_height, nano::stat::dir::out));

View file

@ -68,7 +68,7 @@ void nano::confirming_set::stop ()
notification_workers.stop ();
}
bool nano::confirming_set::exists (nano::block_hash const & hash) const
bool nano::confirming_set::contains (nano::block_hash const & hash) const
{
std::lock_guard lock{ mutex };
return set.get<tag_hash> ().contains (hash);

View file

@ -51,7 +51,7 @@ public:
// Adds a block to the set of blocks to be confirmed
void add (nano::block_hash const & hash, std::shared_ptr<nano::election> const & election = nullptr);
// Added blocks will remain in this set until after ledger has them marked as confirmed.
bool exists (nano::block_hash const & hash) const;
bool contains (nano::block_hash const & hash) const;
std::size_t size () const;
nano::container_info container_info () const;

View file

@ -1187,7 +1187,7 @@ void nano::json_handler::block_confirm ()
if (!node.ledger.confirmed.block_exists_or_pruned (transaction, hash))
{
// Start new confirmation for unconfirmed (or not being confirmed) block
if (!node.confirming_set.exists (hash))
if (!node.confirming_set.contains (hash))
{
node.start_election (std::move (block_l));
}

View file

@ -1104,14 +1104,14 @@ void nano::node::start_election (std::shared_ptr<nano::block> const & block)
scheduler.manual.push (block);
}
bool nano::node::block_confirmed (nano::block_hash const & hash_a)
bool nano::node::block_confirmed (nano::block_hash const & hash)
{
return ledger.confirmed.block_exists_or_pruned (ledger.tx_begin_read (), hash_a);
return ledger.confirmed.block_exists_or_pruned (ledger.tx_begin_read (), hash);
}
bool nano::node::block_confirmed_or_being_confirmed (nano::secure::transaction const & transaction, nano::block_hash const & hash_a)
bool nano::node::block_confirmed_or_being_confirmed (nano::secure::transaction const & transaction, nano::block_hash const & hash)
{
return confirming_set.exists (hash_a) || ledger.confirmed.block_exists_or_pruned (transaction, hash_a);
return confirming_set.contains (hash) || ledger.confirmed.block_exists_or_pruned (transaction, hash);
}
bool nano::node::block_confirmed_or_being_confirmed (nano::block_hash const & hash_a)

View file

@ -1201,7 +1201,7 @@ bool nano::wallet::search_receivable (store::transaction const & wallet_transact
// Receive confirmed block
receive_async (hash, representative, amount, account, [] (std::shared_ptr<nano::block> const &) {});
}
else if (!wallets.node.confirming_set.exists (hash))
else if (!wallets.node.confirming_set.contains (hash))
{
auto block = wallets.node.ledger.any.block_get (block_transaction, hash);
if (block)