diff --git a/nano/core_test/block_store.cpp b/nano/core_test/block_store.cpp index a607833f5..01265fbf5 100644 --- a/nano/core_test/block_store.cpp +++ b/nano/core_test/block_store.cpp @@ -461,8 +461,8 @@ TEST (block_store, empty_accounts) auto store = nano::make_store (logger, nano::unique_path ()); ASSERT_TRUE (!store->init_error ()); auto transaction (store->tx_begin_read ()); - auto begin (store->latest_begin (transaction)); - auto end (store->latest_end ()); + auto begin (store->accounts_begin (transaction)); + auto end (store->accounts_end ()); ASSERT_EQ (end, begin); } @@ -546,8 +546,8 @@ TEST (block_store, one_account) auto transaction (store->tx_begin_write ()); store->confirmation_height_put (transaction, account, { 20, nano::block_hash (15) }); store->account_put (transaction, account, { hash, account, hash, 42, 100, 200, nano::epoch::epoch_0 }); - auto begin (store->latest_begin (transaction)); - auto end (store->latest_end ()); + auto begin (store->accounts_begin (transaction)); + auto end (store->accounts_end ()); ASSERT_NE (end, begin); ASSERT_EQ (account, nano::account (begin->first)); nano::account_info info (begin->second); @@ -600,8 +600,8 @@ TEST (block_store, two_account) store->account_put (transaction, account1, { hash1, account1, hash1, 42, 100, 300, nano::epoch::epoch_0 }); store->confirmation_height_put (transaction, account2, { 30, nano::block_hash (20) }); store->account_put (transaction, account2, { hash2, account2, hash2, 84, 200, 400, nano::epoch::epoch_0 }); - auto begin (store->latest_begin (transaction)); - auto end (store->latest_end ()); + auto begin (store->accounts_begin (transaction)); + auto end (store->accounts_end ()); ASSERT_NE (end, begin); ASSERT_EQ (account1, nano::account (begin->first)); nano::account_info info1 (begin->second); @@ -642,14 +642,14 @@ TEST (block_store, latest_find) store->account_put (transaction, account1, { hash1, account1, hash1, 100, 0, 300, nano::epoch::epoch_0 }); store->confirmation_height_put (transaction, account2, { 0, nano::block_hash (0) }); store->account_put (transaction, account2, { hash2, account2, hash2, 200, 0, 400, nano::epoch::epoch_0 }); - auto first (store->latest_begin (transaction)); - auto second (store->latest_begin (transaction)); + auto first (store->accounts_begin (transaction)); + auto second (store->accounts_begin (transaction)); ++second; - auto find1 (store->latest_begin (transaction, 1)); + auto find1 (store->accounts_begin (transaction, 1)); ASSERT_EQ (first, find1); - auto find2 (store->latest_begin (transaction, 3)); + auto find2 (store->accounts_begin (transaction, 3)); ASSERT_EQ (second, find2); - auto find3 (store->latest_begin (transaction, 2)); + auto find3 (store->accounts_begin (transaction, 2)); ASSERT_EQ (second, find3); } @@ -789,7 +789,7 @@ TEST (block_store, large_iteration) std::unordered_set accounts2; nano::account previous (0); auto transaction (store->tx_begin_read ()); - for (auto i (store->latest_begin (transaction, 0)), n (store->latest_end ()); i != n; ++i) + for (auto i (store->accounts_begin (transaction, 0)), n (store->accounts_end ()); i != n; ++i) { nano::account current (i->first); ASSERT_GT (current.number (), previous.number ()); diff --git a/nano/core_test/ledger.cpp b/nano/core_test/ledger.cpp index 2ae044dfc..9639d1353 100644 --- a/nano/core_test/ledger.cpp +++ b/nano/core_test/ledger.cpp @@ -584,10 +584,10 @@ TEST (system, DISABLED_generate_send_new) system.wallet (0)->insert_adhoc (nano::dev_genesis_key.prv); { auto transaction (node1.store.tx_begin_read ()); - auto iterator1 (node1.store.latest_begin (transaction)); - ASSERT_NE (node1.store.latest_end (), iterator1); + auto iterator1 (node1.store.accounts_begin (transaction)); + ASSERT_NE (node1.store.accounts_end (), iterator1); ++iterator1; - ASSERT_EQ (node1.store.latest_end (), iterator1); + ASSERT_EQ (node1.store.accounts_end (), iterator1); } nano::keypair stake_preserver; auto send_block (system.wallet (0)->send_action (nano::genesis_account, stake_preserver.pub, nano::genesis_amount / 3 * 2, true)); diff --git a/nano/nano_node/entry.cpp b/nano/nano_node/entry.cpp index ebff6f075..5b889a56b 100644 --- a/nano/nano_node/entry.cpp +++ b/nano/nano_node/entry.cpp @@ -425,7 +425,7 @@ int main (int argc, char * const * argv) // Cache the account heads to make searching quicker against unchecked keys. auto transaction (node->store.tx_begin_read ()); std::unordered_set frontier_hashes; - for (auto i (node->store.latest_begin (transaction)), n (node->store.latest_end ()); i != n; ++i) + for (auto i (node->store.accounts_begin (transaction)), n (node->store.accounts_end ()); i != n; ++i) { frontier_hashes.insert (i->second.head); } @@ -1648,7 +1648,7 @@ int main (int argc, char * const * argv) } size_t const accounts_deque_overflow (32 * 1024); auto transaction (node->store.tx_begin_read ()); - for (auto i (node->store.latest_begin (transaction)), n (node->store.latest_end ()); i != n; ++i) + for (auto i (node->store.accounts_begin (transaction)), n (node->store.accounts_end ()); i != n; ++i) { { nano::unique_lock lock (mutex); @@ -1817,7 +1817,7 @@ int main (int argc, char * const * argv) auto transaction (source_node->store.tx_begin_read ()); block_count = source_node->ledger.cache.block_count; std::cout << boost::str (boost::format ("Performing bootstrap emulation, %1% blocks in ledger...") % block_count) << std::endl; - for (auto i (source_node->store.latest_begin (transaction)), n (source_node->store.latest_end ()); i != n; ++i) + for (auto i (source_node->store.accounts_begin (transaction)), n (source_node->store.accounts_end ()); i != n; ++i) { nano::account const & account (i->first); nano::account_info const & info (i->second); @@ -1919,7 +1919,7 @@ int main (int argc, char * const * argv) // Cache the accounts in a collection to make searching quicker against unchecked keys. Group by epoch nano::locked>> opened_account_versions_shared (epoch_count); using opened_account_versions_t = decltype (opened_account_versions_shared)::value_type; - node->store.latest_for_each_par ( + node->store.accounts_for_each_par ( [&opened_account_versions_shared, epoch_count](nano::read_transaction const & /*unused*/, nano::store_iterator i, nano::store_iterator n) { // First cache locally opened_account_versions_t opened_account_versions_l (epoch_count); diff --git a/nano/node/active_transactions.cpp b/nano/node/active_transactions.cpp index 83acfcd4d..e9b5a4f79 100644 --- a/nano/node/active_transactions.cpp +++ b/nano/node/active_transactions.cpp @@ -444,8 +444,8 @@ void nano::active_transactions::frontiers_confirmation (nano::unique_lock timer (nano::timer_state::started); nano::confirmation_height_info confirmation_height_info; @@ -715,8 +715,8 @@ void nano::active_transactions::prioritize_frontiers_for_confirmation (nano::tra } nano::timer timer (nano::timer_state::started); - auto i (node.store.latest_begin (transaction_a, next_frontier_account)); - auto n (node.store.latest_end ()); + auto i (node.store.accounts_begin (transaction_a, next_frontier_account)); + auto n (node.store.accounts_end ()); nano::confirmation_height_info confirmation_height_info; for (; i != n && should_iterate (); ++i) { diff --git a/nano/node/bootstrap/bootstrap_frontier.cpp b/nano/node/bootstrap/bootstrap_frontier.cpp index 3d9cd79b1..914ba3553 100644 --- a/nano/node/bootstrap/bootstrap_frontier.cpp +++ b/nano/node/bootstrap/bootstrap_frontier.cpp @@ -205,13 +205,13 @@ void nano::frontier_req_client::next () { size_t max_size (128); auto transaction (connection->node->store.tx_begin_read ()); - for (auto i (connection->node->store.latest_begin (transaction, current.number () + 1)), n (connection->node->store.latest_end ()); i != n && accounts.size () != max_size; ++i) + for (auto i (connection->node->store.accounts_begin (transaction, current.number () + 1)), n (connection->node->store.accounts_end ()); i != n && accounts.size () != max_size; ++i) { nano::account_info const & info (i->second); nano::account const & account (i->first); accounts.emplace_back (account, info.head); } - /* If loop breaks before max_size, then latest_end () is reached + /* If loop breaks before max_size, then accounts_end () is reached Add empty record to finish frontier_req_server */ if (accounts.size () != max_size) { @@ -320,7 +320,7 @@ void nano::frontier_req_server::next () bool skip_old (request->age != std::numeric_limitsage)>::max ()); size_t max_size (128); auto transaction (connection->node->store.tx_begin_read ()); - for (auto i (connection->node->store.latest_begin (transaction, current.number () + 1)), n (connection->node->store.latest_end ()); i != n && accounts.size () != max_size; ++i) + for (auto i (connection->node->store.accounts_begin (transaction, current.number () + 1)), n (connection->node->store.accounts_end ()); i != n && accounts.size () != max_size; ++i) { nano::account_info const & info (i->second); if (!skip_old || (now - info.modified) <= request->age) @@ -329,7 +329,7 @@ void nano::frontier_req_server::next () accounts.emplace_back (account, info.head); } } - /* If loop breaks before max_size, then latest_end () is reached + /* If loop breaks before max_size, then accounts_end () is reached Add empty record to finish frontier_req_server */ if (accounts.size () != max_size) { diff --git a/nano/node/json_handler.cpp b/nano/node/json_handler.cpp index 9a286bc8f..4b0f5d1de 100644 --- a/nano/node/json_handler.cpp +++ b/nano/node/json_handler.cpp @@ -2007,7 +2007,7 @@ void nano::json_handler::delegators () { boost::property_tree::ptree delegators; auto transaction (node.store.tx_begin_read ()); - for (auto i (node.store.latest_begin (transaction)), n (node.store.latest_end ()); i != n; ++i) + for (auto i (node.store.accounts_begin (transaction)), n (node.store.accounts_end ()); i != n; ++i) { nano::account_info const & info (i->second); if (info.representative == account) @@ -2030,7 +2030,7 @@ void nano::json_handler::delegators_count () { uint64_t count (0); auto transaction (node.store.tx_begin_read ()); - for (auto i (node.store.latest_begin (transaction)), n (node.store.latest_end ()); i != n; ++i) + for (auto i (node.store.accounts_begin (transaction)), n (node.store.accounts_end ()); i != n; ++i) { nano::account_info const & info (i->second); if (info.representative == account) @@ -2141,7 +2141,7 @@ void nano::json_handler::frontiers () { boost::property_tree::ptree frontiers; auto transaction (node.store.tx_begin_read ()); - for (auto i (node.store.latest_begin (transaction, start)), n (node.store.latest_end ()); i != n && frontiers.size () < count; ++i) + for (auto i (node.store.accounts_begin (transaction, start)), n (node.store.accounts_end ()); i != n && frontiers.size () < count; ++i) { frontiers.put (i->first.to_account (), i->second.head.to_string ()); } @@ -2509,7 +2509,7 @@ void nano::json_handler::ledger () auto transaction (node.store.tx_begin_read ()); if (!ec && !sorting) // Simple { - for (auto i (node.store.latest_begin (transaction, start)), n (node.store.latest_end ()); i != n && accounts.size () < count; ++i) + for (auto i (node.store.accounts_begin (transaction, start)), n (node.store.accounts_end ()); i != n && accounts.size () < count; ++i) { nano::account_info const & info (i->second); if (info.modified >= modified_since && (pending || info.balance.number () >= threshold.number ())) @@ -2549,7 +2549,7 @@ void nano::json_handler::ledger () else if (!ec) // Sorting { std::vector> ledger_l; - for (auto i (node.store.latest_begin (transaction, start)), n (node.store.latest_end ()); i != n; ++i) + for (auto i (node.store.accounts_begin (transaction, start)), n (node.store.accounts_end ()); i != n; ++i) { nano::account_info const & info (i->second); nano::uint128_union balance (info.balance); diff --git a/nano/node/lmdb/lmdb.cpp b/nano/node/lmdb/lmdb.cpp index d7effcb6f..6cf3d0229 100644 --- a/nano/node/lmdb/lmdb.cpp +++ b/nano/node/lmdb/lmdb.cpp @@ -420,8 +420,8 @@ void nano::mdb_store::upgrade_v16_to_v17 (nano::write_transaction const & transa { logger.always_log ("Preparing v16 to v17 database upgrade..."); - auto account_info_i = latest_begin (transaction_a); - auto account_info_n = latest_end (); + auto account_info_i = accounts_begin (transaction_a); + auto account_info_n = accounts_end (); // Set the confirmed frontier for each account in the confirmation height table std::vector> confirmation_height_infos; diff --git a/nano/node/node.cpp b/nano/node/node.cpp index 5321c6663..0b94ee467 100644 --- a/nano/node/node.cpp +++ b/nano/node/node.cpp @@ -355,7 +355,7 @@ node_seq (seq) auto is_initialized (false); { auto transaction (store.tx_begin_read ()); - is_initialized = (store.latest_begin (transaction) != store.latest_end ()); + is_initialized = (store.accounts_begin (transaction) != store.accounts_end ()); } nano::genesis genesis; @@ -1446,7 +1446,7 @@ void nano::node::epoch_upgrader_impl (nano::private_key const & prv_a, nano::epo { auto transaction (store.tx_begin_read ()); // Collect accounts to upgrade - for (auto i (store.latest_begin (transaction)), n (store.latest_end ()); i != n && accounts_list.size () < count_limit; ++i) + for (auto i (store.accounts_begin (transaction)), n (store.accounts_end ()); i != n && accounts_list.size () < count_limit; ++i) { nano::account const & account (i->first); nano::account_info const & info (i->second); diff --git a/nano/node/rocksdb/rocksdb.cpp b/nano/node/rocksdb/rocksdb.cpp index 99a5c9eb2..554e917e6 100644 --- a/nano/node/rocksdb/rocksdb.cpp +++ b/nano/node/rocksdb/rocksdb.cpp @@ -501,7 +501,7 @@ uint64_t nano::rocksdb_store::count (nano::transaction const & transaction_a, ta else if (table_a == tables::accounts) { debug_assert (network_constants ().is_dev_network ()); - for (auto i (latest_begin (transaction_a)), n (latest_end ()); i != n; ++i) + for (auto i (accounts_begin (transaction_a)), n (accounts_end ()); i != n; ++i) { ++sum; } diff --git a/nano/node/testing.cpp b/nano/node/testing.cpp index ef0e75186..b196496b2 100644 --- a/nano/node/testing.cpp +++ b/nano/node/testing.cpp @@ -414,12 +414,12 @@ void nano::system::generate_send_existing (nano::node & node_a, std::vector entry (node_a.store.latest_begin (transaction, account)); - if (entry == node_a.store.latest_end ()) + nano::store_iterator entry (node_a.store.accounts_begin (transaction, account)); + if (entry == node_a.store.accounts_end ()) { - entry = node_a.store.latest_begin (transaction); + entry = node_a.store.accounts_begin (transaction); } - debug_assert (entry != node_a.store.latest_end ()); + debug_assert (entry != node_a.store.accounts_end ()); destination = nano::account (entry->first); source = get_random_account (accounts_a); amount = get_random_amount (transaction, node_a, source); diff --git a/nano/qt/qt.cpp b/nano/qt/qt.cpp index c8375e89a..2b36a58f8 100644 --- a/nano/qt/qt.cpp +++ b/nano/qt/qt.cpp @@ -1956,7 +1956,7 @@ void nano_qt::advanced_actions::refresh_ledger () { ledger_model->removeRows (0, ledger_model->rowCount ()); auto transaction (wallet.node.store.tx_begin_read ()); - for (auto i (wallet.node.ledger.store.latest_begin (transaction)), j (wallet.node.ledger.store.latest_end ()); i != j; ++i) + for (auto i (wallet.node.ledger.store.accounts_begin (transaction)), j (wallet.node.ledger.store.accounts_end ()); i != j; ++i) { QList items; items.push_back (new QStandardItem (QString (i->first.to_account ().c_str ()))); diff --git a/nano/rpc_test/rpc.cpp b/nano/rpc_test/rpc.cpp index da869c945..18c0f25d7 100644 --- a/nano/rpc_test/rpc.cpp +++ b/nano/rpc_test/rpc.cpp @@ -7105,7 +7105,7 @@ TEST (rpc, epoch_upgrade) { auto transaction (node->store.tx_begin_read ()); ASSERT_EQ (2, node->store.account_count (transaction)); - for (auto i (node->store.latest_begin (transaction)); i != node->store.latest_end (); ++i) + for (auto i (node->store.accounts_begin (transaction)); i != node->store.accounts_end (); ++i) { nano::account_info info (i->second); ASSERT_EQ (info.epoch (), nano::epoch::epoch_0); @@ -7135,7 +7135,7 @@ TEST (rpc, epoch_upgrade) { auto transaction (node->store.tx_begin_read ()); ASSERT_EQ (4, node->store.account_count (transaction)); - for (auto i (node->store.latest_begin (transaction)); i != node->store.latest_end (); ++i) + for (auto i (node->store.accounts_begin (transaction)); i != node->store.accounts_end (); ++i) { nano::account_info info (i->second); ASSERT_EQ (info.epoch (), nano::epoch::epoch_1); @@ -7173,7 +7173,7 @@ TEST (rpc, epoch_upgrade) { auto transaction (node->store.tx_begin_read ()); ASSERT_EQ (5, node->store.account_count (transaction)); - for (auto i (node->store.latest_begin (transaction)); i != node->store.latest_end (); ++i) + for (auto i (node->store.accounts_begin (transaction)); i != node->store.accounts_end (); ++i) { nano::account_info info (i->second); ASSERT_EQ (info.epoch (), nano::epoch::epoch_2); @@ -7209,7 +7209,7 @@ TEST (rpc, epoch_upgrade_multithreaded) { auto transaction (node->store.tx_begin_read ()); ASSERT_EQ (2, node->store.account_count (transaction)); - for (auto i (node->store.latest_begin (transaction)); i != node->store.latest_end (); ++i) + for (auto i (node->store.accounts_begin (transaction)); i != node->store.accounts_end (); ++i) { nano::account_info info (i->second); ASSERT_EQ (info.epoch (), nano::epoch::epoch_0); @@ -7236,7 +7236,7 @@ TEST (rpc, epoch_upgrade_multithreaded) { auto transaction (node->store.tx_begin_read ()); ASSERT_EQ (4, node->store.account_count (transaction)); - for (auto i (node->store.latest_begin (transaction)); i != node->store.latest_end (); ++i) + for (auto i (node->store.accounts_begin (transaction)); i != node->store.accounts_end (); ++i) { nano::account_info info (i->second); ASSERT_EQ (info.epoch (), nano::epoch::epoch_1); @@ -7274,7 +7274,7 @@ TEST (rpc, epoch_upgrade_multithreaded) { auto transaction (node->store.tx_begin_read ()); ASSERT_EQ (5, node->store.account_count (transaction)); - for (auto i (node->store.latest_begin (transaction)); i != node->store.latest_end (); ++i) + for (auto i (node->store.accounts_begin (transaction)); i != node->store.accounts_end (); ++i) { nano::account_info info (i->second); ASSERT_EQ (info.epoch (), nano::epoch::epoch_2); diff --git a/nano/secure/blockstore.hpp b/nano/secure/blockstore.hpp index 7b8e5ad90..71367de83 100644 --- a/nano/secure/blockstore.hpp +++ b/nano/secure/blockstore.hpp @@ -617,9 +617,9 @@ public: virtual size_t account_count (nano::transaction const &) = 0; virtual void confirmation_height_clear (nano::write_transaction const &, nano::account const &, uint64_t) = 0; virtual void confirmation_height_clear (nano::write_transaction const &) = 0; - virtual nano::store_iterator latest_begin (nano::transaction const &, nano::account const &) const = 0; - virtual nano::store_iterator latest_begin (nano::transaction const &) const = 0; - virtual nano::store_iterator latest_end () const = 0; + virtual nano::store_iterator accounts_begin (nano::transaction const &, nano::account const &) const = 0; + virtual nano::store_iterator accounts_begin (nano::transaction const &) const = 0; + virtual nano::store_iterator accounts_end () const = 0; virtual void pending_put (nano::write_transaction const &, nano::pending_key const &, nano::pending_info const &) = 0; virtual void pending_del (nano::write_transaction const &, nano::pending_key const &) = 0; @@ -696,7 +696,7 @@ public: virtual nano::store_iterator> blocks_begin (nano::transaction const & transaction_a) const = 0; virtual nano::store_iterator> blocks_end () const = 0; - virtual void latest_for_each_par (std::function, nano::store_iterator)> const &) = 0; + virtual void accounts_for_each_par (std::function, nano::store_iterator)> const &) = 0; virtual void confirmation_height_for_each_par (std::function, nano::store_iterator)> const &) = 0; virtual void pending_for_each_par (std::function, nano::store_iterator)> const &) = 0; diff --git a/nano/secure/blockstore_partial.hpp b/nano/secure/blockstore_partial.hpp index a1f1b187b..e0b62e237 100644 --- a/nano/secure/blockstore_partial.hpp +++ b/nano/secure/blockstore_partial.hpp @@ -40,7 +40,7 @@ public: void initialize (nano::write_transaction const & transaction_a, nano::genesis const & genesis_a, nano::ledger_cache & ledger_cache_a) override { auto hash_l (genesis_a.hash ()); - debug_assert (latest_begin (transaction_a) == latest_end ()); + debug_assert (accounts_begin (transaction_a) == accounts_end ()); genesis_a.open->sideband_set (nano::block_sideband (network_params.ledger.genesis_account, 0, network_params.ledger.genesis_amount, 1, nano::seconds_since_epoch (), nano::epoch::epoch_0, false, false, false, nano::epoch::epoch_0)); block_put (transaction_a, hash_l, *genesis_a.open); ++ledger_cache_a.block_count; @@ -62,8 +62,8 @@ public: bool account_exists (nano::transaction const & transaction_a, nano::account const & account_a) override { - auto iterator (latest_begin (transaction_a, account_a)); - return iterator != latest_end () && nano::account (iterator->first) == account_a; + auto iterator (accounts_begin (transaction_a, account_a)); + return iterator != accounts_end () && nano::account (iterator->first) == account_a; } void confirmation_height_clear (nano::write_transaction const & transaction_a, nano::account const & account_a, uint64_t existing_confirmation_height_a) override @@ -333,7 +333,7 @@ public: return nano::store_iterator (nullptr); } - nano::store_iterator latest_end () const override + nano::store_iterator accounts_end () const override { return nano::store_iterator (nullptr); } @@ -693,12 +693,12 @@ public: return exists (transaction_a, tables::confirmation_height, nano::db_val (account_a)); } - nano::store_iterator latest_begin (nano::transaction const & transaction_a, nano::account const & account_a) const override + nano::store_iterator accounts_begin (nano::transaction const & transaction_a, nano::account const & account_a) const override { return make_iterator (transaction_a, tables::accounts, nano::db_val (account_a)); } - nano::store_iterator latest_begin (nano::transaction const & transaction_a) const override + nano::store_iterator accounts_begin (nano::transaction const & transaction_a) const override { return make_iterator (transaction_a, tables::accounts); } @@ -758,12 +758,12 @@ public: return count (transaction_a, tables::unchecked); } - void latest_for_each_par (std::function, nano::store_iterator)> const & action_a) override + void accounts_for_each_par (std::function, nano::store_iterator)> const & action_a) override { parallel_traversal ( [&action_a, this](nano::uint256_t const & start, nano::uint256_t const & end, bool const is_last) { auto transaction (this->tx_begin_read ()); - action_a (transaction, this->latest_begin (transaction, start), !is_last ? this->latest_begin (transaction, end) : this->latest_end ()); + action_a (transaction, this->accounts_begin (transaction, start), !is_last ? this->accounts_begin (transaction, end) : this->accounts_end ()); }); } diff --git a/nano/secure/ledger.cpp b/nano/secure/ledger.cpp index 9d24578d3..f1312d81a 100644 --- a/nano/secure/ledger.cpp +++ b/nano/secure/ledger.cpp @@ -41,7 +41,7 @@ public: ledger.store.pending_del (transaction, key); ledger.cache.rep_weights.representation_add (info.representative, pending.amount.number ()); nano::account_info new_info (block_a.hashables.previous, info.representative, info.open_block, ledger.balance (transaction, block_a.hashables.previous), nano::seconds_since_epoch (), info.block_count - 1, nano::epoch::epoch_0); - ledger.change_latest (transaction, pending.source, info, new_info); + ledger.update_account (transaction, pending.source, info, new_info); ledger.store.block_del (transaction, hash); ledger.store.frontier_del (transaction, hash); ledger.store.frontier_put (transaction, block_a.hashables.previous, pending.source); @@ -61,7 +61,7 @@ public: debug_assert (!error); ledger.cache.rep_weights.representation_add (info.representative, 0 - amount); nano::account_info new_info (block_a.hashables.previous, info.representative, info.open_block, ledger.balance (transaction, block_a.hashables.previous), nano::seconds_since_epoch (), info.block_count - 1, nano::epoch::epoch_0); - ledger.change_latest (transaction, destination_account, info, new_info); + ledger.update_account (transaction, destination_account, info, new_info); ledger.store.block_del (transaction, hash); ledger.store.pending_put (transaction, nano::pending_key (destination_account, block_a.hashables.source), { source_account, amount, nano::epoch::epoch_0 }); ledger.store.frontier_del (transaction, hash); @@ -77,7 +77,7 @@ public: auto source_account (ledger.account (transaction, block_a.hashables.source)); ledger.cache.rep_weights.representation_add (block_a.representative (), 0 - amount); nano::account_info new_info; - ledger.change_latest (transaction, destination_account, new_info, new_info); + ledger.update_account (transaction, destination_account, new_info, new_info); ledger.store.block_del (transaction, hash); ledger.store.pending_put (transaction, nano::pending_key (destination_account, block_a.hashables.source), { source_account, amount, nano::epoch::epoch_0 }); ledger.store.frontier_del (transaction, hash); @@ -99,7 +99,7 @@ public: ledger.cache.rep_weights.representation_add_dual (block_a.representative (), 0 - balance, representative, balance); ledger.store.block_del (transaction, hash); nano::account_info new_info (block_a.hashables.previous, representative, info.open_block, info.balance, nano::seconds_since_epoch (), info.block_count - 1, nano::epoch::epoch_0); - ledger.change_latest (transaction, account, info, new_info); + ledger.update_account (transaction, account, info, new_info); ledger.store.frontier_del (transaction, hash); ledger.store.frontier_put (transaction, block_a.hashables.previous, account); ledger.store.block_successor_clear (transaction, block_a.hashables.previous); @@ -153,7 +153,7 @@ public: debug_assert (!error); auto previous_version (ledger.store.block_version (transaction, block_a.hashables.previous)); nano::account_info new_info (block_a.hashables.previous, representative, info.open_block, balance, nano::seconds_since_epoch (), info.block_count - 1, previous_version); - ledger.change_latest (transaction, block_a.hashables.account, info, new_info); + ledger.update_account (transaction, block_a.hashables.account, info, new_info); auto previous (ledger.store.block_get (transaction, block_a.hashables.previous)); if (previous != nullptr) @@ -372,7 +372,7 @@ void ledger_processor::state_block_impl (nano::state_block & block_a) } nano::account_info new_info (hash, block_a.representative (), info.open_block.is_zero () ? hash : info.open_block, block_a.hashables.balance, nano::seconds_since_epoch (), info.block_count + 1, epoch); - ledger.change_latest (transaction, block_a.hashables.account, info, new_info); + ledger.update_account (transaction, block_a.hashables.account, info, new_info); if (!ledger.store.frontier_get (transaction, info.head).is_zero ()) { ledger.store.frontier_del (transaction, info.head); @@ -449,7 +449,7 @@ void ledger_processor::epoch_block_impl (nano::state_block & block_a) block_a.sideband_set (nano::block_sideband (block_a.hashables.account /* unused */, 0, 0 /* unused */, info.block_count + 1, nano::seconds_since_epoch (), block_details, nano::epoch::epoch_0 /* unused */)); ledger.store.block_put (transaction, hash, block_a); nano::account_info new_info (hash, block_a.representative (), info.open_block.is_zero () ? hash : info.open_block, info.balance, nano::seconds_since_epoch (), info.block_count + 1, epoch); - ledger.change_latest (transaction, block_a.hashables.account, info, new_info); + ledger.update_account (transaction, block_a.hashables.account, info, new_info); if (!ledger.store.frontier_get (transaction, info.head).is_zero ()) { ledger.store.frontier_del (transaction, info.head); @@ -515,7 +515,7 @@ void ledger_processor::change_block (nano::change_block & block_a) auto balance (ledger.balance (transaction, block_a.hashables.previous)); ledger.cache.rep_weights.representation_add_dual (block_a.representative (), balance, info.representative, 0 - balance); nano::account_info new_info (hash, block_a.representative (), info.open_block, info.balance, nano::seconds_since_epoch (), info.block_count + 1, nano::epoch::epoch_0); - ledger.change_latest (transaction, account, info, new_info); + ledger.update_account (transaction, account, info, new_info); ledger.store.frontier_del (transaction, block_a.hashables.previous); ledger.store.frontier_put (transaction, hash, account); result.previous_balance = info.balance; @@ -572,7 +572,7 @@ void ledger_processor::send_block (nano::send_block & block_a) block_a.sideband_set (nano::block_sideband (account, 0, block_a.hashables.balance /* unused */, info.block_count + 1, nano::seconds_since_epoch (), block_details, nano::epoch::epoch_0 /* unused */)); ledger.store.block_put (transaction, hash, block_a); nano::account_info new_info (hash, info.representative, info.open_block, block_a.hashables.balance, nano::seconds_since_epoch (), info.block_count + 1, nano::epoch::epoch_0); - ledger.change_latest (transaction, account, info, new_info); + ledger.update_account (transaction, account, info, new_info); ledger.store.pending_put (transaction, nano::pending_key (block_a.hashables.destination, hash), { account, amount, nano::epoch::epoch_0 }); ledger.store.frontier_del (transaction, block_a.hashables.previous); ledger.store.frontier_put (transaction, hash, account); @@ -643,7 +643,7 @@ void ledger_processor::receive_block (nano::receive_block & block_a) block_a.sideband_set (nano::block_sideband (account, 0, new_balance, info.block_count + 1, nano::seconds_since_epoch (), block_details, nano::epoch::epoch_0 /* unused */)); ledger.store.block_put (transaction, hash, block_a); nano::account_info new_info (hash, info.representative, info.open_block, new_balance, nano::seconds_since_epoch (), info.block_count + 1, nano::epoch::epoch_0); - ledger.change_latest (transaction, account, info, new_info); + ledger.update_account (transaction, account, info, new_info); ledger.cache.rep_weights.representation_add (info.representative, pending.amount.number ()); ledger.store.frontier_del (transaction, block_a.hashables.previous); ledger.store.frontier_put (transaction, hash, account); @@ -711,7 +711,7 @@ void ledger_processor::open_block (nano::open_block & block_a) block_a.sideband_set (nano::block_sideband (block_a.hashables.account, 0, pending.amount, 1, nano::seconds_since_epoch (), block_details, nano::epoch::epoch_0 /* unused */)); ledger.store.block_put (transaction, hash, block_a); nano::account_info new_info (hash, block_a.representative (), hash, pending.amount.number (), nano::seconds_since_epoch (), 1, nano::epoch::epoch_0); - ledger.change_latest (transaction, block_a.hashables.account, info, new_info); + ledger.update_account (transaction, block_a.hashables.account, info, new_info); ledger.cache.rep_weights.representation_add (block_a.representative (), pending.amount.number ()); ledger.store.frontier_put (transaction, hash, block_a.hashables.account); result.previous_balance = 0; @@ -751,7 +751,7 @@ void nano::ledger::initialize (nano::generate_cache const & generate_cache_a) { if (generate_cache_a.reps || generate_cache_a.account_count || generate_cache_a.epoch_2 || generate_cache_a.block_count) { - store.latest_for_each_par ( + store.accounts_for_each_par ( [this](nano::read_transaction const & /*unused*/, nano::store_iterator i, nano::store_iterator n) { uint64_t block_count_l{ 0 }; uint64_t account_count_l{ 0 }; @@ -1226,7 +1226,7 @@ nano::link const & nano::ledger::epoch_link (nano::epoch epoch_a) const return network_params.ledger.epochs.link (epoch_a); } -void nano::ledger::change_latest (nano::write_transaction const & transaction_a, nano::account const & account_a, nano::account_info const & old_a, nano::account_info const & new_a) +void nano::ledger::update_account (nano::write_transaction const & transaction_a, nano::account const & account_a, nano::account_info const & old_a, nano::account_info const & new_a) { if (!new_a.head.is_zero ()) { @@ -1355,7 +1355,7 @@ std::multimap> nano::ledger::unc nano::locked>> result; using result_t = decltype (result)::value_type; - store.latest_for_each_par ([this, &result](nano::read_transaction const & transaction_a, nano::store_iterator i, nano::store_iterator n) { + store.accounts_for_each_par ([this, &result](nano::read_transaction const & transaction_a, nano::store_iterator i, nano::store_iterator n) { result_t unconfirmed_frontiers_l; for (; i != n; ++i) { diff --git a/nano/secure/ledger.hpp b/nano/secure/ledger.hpp index ab468f567..fd0e12be8 100644 --- a/nano/secure/ledger.hpp +++ b/nano/secure/ledger.hpp @@ -56,7 +56,7 @@ public: nano::process_return process (nano::write_transaction const &, nano::block &, nano::signature_verification = nano::signature_verification::unknown); bool rollback (nano::write_transaction const &, nano::block_hash const &, std::vector> &); bool rollback (nano::write_transaction const &, nano::block_hash const &); - void change_latest (nano::write_transaction const &, nano::account const &, nano::account_info const &, nano::account_info const &); + void update_account (nano::write_transaction const &, nano::account const &, nano::account_info const &, nano::account_info const &); uint64_t pruning_action (nano::write_transaction &, nano::block_hash const &, uint64_t const); void dump_account_chain (nano::account const &, std::ostream & = std::cout); bool could_fit (nano::transaction const &, nano::block const &) const; diff --git a/nano/slow_test/node.cpp b/nano/slow_test/node.cpp index e50ef1276..b4d7fcbd4 100644 --- a/nano/slow_test/node.cpp +++ b/nano/slow_test/node.cpp @@ -25,7 +25,7 @@ TEST (system, generate_mass_activity) uint32_t count (20); system.generate_mass_activity (count, *system.nodes[0]); auto transaction (system.nodes[0]->store.tx_begin_read ()); - for (auto i (system.nodes[0]->store.latest_begin (transaction)), n (system.nodes[0]->store.latest_end ()); i != n; ++i) + for (auto i (system.nodes[0]->store.accounts_begin (transaction)), n (system.nodes[0]->store.accounts_end ()); i != n; ++i) { } } @@ -42,7 +42,7 @@ TEST (system, generate_mass_activity_long) uint32_t count (1000000000); system.generate_mass_activity (count, *system.nodes[0]); auto transaction (system.nodes[0]->store.tx_begin_read ()); - for (auto i (system.nodes[0]->store.latest_begin (transaction)), n (system.nodes[0]->store.latest_end ()); i != n; ++i) + for (auto i (system.nodes[0]->store.accounts_begin (transaction)), n (system.nodes[0]->store.accounts_end ()); i != n; ++i) { } system.stop (); @@ -545,7 +545,7 @@ TEST (confirmation_height, many_accounts_single_confirmation) // All frontiers (except last) should have 2 blocks and both should be confirmed auto transaction = node->store.tx_begin_read (); - for (auto i (node->store.latest_begin (transaction)), n (node->store.latest_end ()); i != n; ++i) + for (auto i (node->store.accounts_begin (transaction)), n (node->store.accounts_end ()); i != n; ++i) { auto & account = i->first; auto & account_info = i->second; @@ -1676,7 +1676,7 @@ TEST (node, mass_epoch_upgrader) { auto transaction (node.store.tx_begin_read ()); size_t block_count_sum = 0; - for (auto i (node.store.latest_begin (transaction)); i != node.store.latest_end (); ++i) + for (auto i (node.store.accounts_begin (transaction)); i != node.store.accounts_end (); ++i) { nano::account_info info (i->second); ASSERT_EQ (info.epoch (), nano::epoch::epoch_1);