Change usage of latest to accounts for consistency (#2981)

* Change usage of latest to accounts for consistency

* Update change_latest -> update_account

* Missed an update for parallel for
This commit is contained in:
Wesley Shillingford 2020-09-25 21:19:50 +01:00 committed by GitHub
commit 4beced8381
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 79 additions and 79 deletions

View file

@ -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<nano::account> 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 ());

View file

@ -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));

View file

@ -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<nano::block_hash> 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<std::mutex> 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<std::vector<boost::unordered_set<nano::account>>> 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<nano::account, nano::account_info> i, nano::store_iterator<nano::account, nano::account_info> n) {
// First cache locally
opened_account_versions_t opened_account_versions_l (epoch_count);

View file

@ -444,8 +444,8 @@ void nano::active_transactions::frontiers_confirmation (nano::unique_lock<std::m
*/
void nano::active_transactions::confirm_expired_frontiers_pessimistically (nano::transaction const & transaction_a, uint64_t max_elections_a, uint64_t & elections_count_a)
{
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::timer<std::chrono::milliseconds> 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<std::chrono::milliseconds> 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)
{

View file

@ -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_limits<decltype (request->age)>::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)
{

View file

@ -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<std::pair<nano::uint128_union, nano::account>> 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);

View file

@ -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<std::pair<nano::account, nano::confirmation_height_info>> confirmation_height_infos;

View file

@ -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);

View file

@ -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;
}

View file

@ -414,12 +414,12 @@ void nano::system::generate_send_existing (nano::node & node_a, std::vector<nano
nano::account account;
random_pool::generate_block (account.bytes.data (), sizeof (account.bytes));
auto transaction (node_a.store.tx_begin_read ());
nano::store_iterator<nano::account, nano::account_info> entry (node_a.store.latest_begin (transaction, account));
if (entry == node_a.store.latest_end ())
nano::store_iterator<nano::account, nano::account_info> 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);

View file

@ -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<QStandardItem *> items;
items.push_back (new QStandardItem (QString (i->first.to_account ().c_str ())));

View file

@ -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);

View file

@ -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<nano::account, nano::account_info> latest_begin (nano::transaction const &, nano::account const &) const = 0;
virtual nano::store_iterator<nano::account, nano::account_info> latest_begin (nano::transaction const &) const = 0;
virtual nano::store_iterator<nano::account, nano::account_info> latest_end () const = 0;
virtual nano::store_iterator<nano::account, nano::account_info> accounts_begin (nano::transaction const &, nano::account const &) const = 0;
virtual nano::store_iterator<nano::account, nano::account_info> accounts_begin (nano::transaction const &) const = 0;
virtual nano::store_iterator<nano::account, nano::account_info> 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<nano::block_hash, std::shared_ptr<nano::block>> blocks_begin (nano::transaction const & transaction_a) const = 0;
virtual nano::store_iterator<nano::block_hash, std::shared_ptr<nano::block>> blocks_end () const = 0;
virtual void latest_for_each_par (std::function<void(nano::read_transaction const &, nano::store_iterator<nano::account, nano::account_info>, nano::store_iterator<nano::account, nano::account_info>)> const &) = 0;
virtual void accounts_for_each_par (std::function<void(nano::read_transaction const &, nano::store_iterator<nano::account, nano::account_info>, nano::store_iterator<nano::account, nano::account_info>)> const &) = 0;
virtual void confirmation_height_for_each_par (std::function<void(nano::read_transaction const &, nano::store_iterator<nano::account, nano::confirmation_height_info>, nano::store_iterator<nano::account, nano::confirmation_height_info>)> const &) = 0;
virtual void pending_for_each_par (std::function<void(nano::read_transaction const &, nano::store_iterator<nano::pending_key, nano::pending_info>, nano::store_iterator<nano::pending_key, nano::pending_info>)> const &) = 0;

View file

@ -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<uint64_t, nano::amount> (nullptr);
}
nano::store_iterator<nano::account, nano::account_info> latest_end () const override
nano::store_iterator<nano::account, nano::account_info> accounts_end () const override
{
return nano::store_iterator<nano::account, nano::account_info> (nullptr);
}
@ -693,12 +693,12 @@ public:
return exists (transaction_a, tables::confirmation_height, nano::db_val<Val> (account_a));
}
nano::store_iterator<nano::account, nano::account_info> latest_begin (nano::transaction const & transaction_a, nano::account const & account_a) const override
nano::store_iterator<nano::account, nano::account_info> accounts_begin (nano::transaction const & transaction_a, nano::account const & account_a) const override
{
return make_iterator<nano::account, nano::account_info> (transaction_a, tables::accounts, nano::db_val<Val> (account_a));
}
nano::store_iterator<nano::account, nano::account_info> latest_begin (nano::transaction const & transaction_a) const override
nano::store_iterator<nano::account, nano::account_info> accounts_begin (nano::transaction const & transaction_a) const override
{
return make_iterator<nano::account, nano::account_info> (transaction_a, tables::accounts);
}
@ -758,12 +758,12 @@ public:
return count (transaction_a, tables::unchecked);
}
void latest_for_each_par (std::function<void(nano::read_transaction const &, nano::store_iterator<nano::account, nano::account_info>, nano::store_iterator<nano::account, nano::account_info>)> const & action_a) override
void accounts_for_each_par (std::function<void(nano::read_transaction const &, nano::store_iterator<nano::account, nano::account_info>, nano::store_iterator<nano::account, nano::account_info>)> const & action_a) override
{
parallel_traversal<nano::uint256_t> (
[&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 ());
});
}

View file

@ -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<nano::account, nano::account_info> i, nano::store_iterator<nano::account, nano::account_info> 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<uint64_t, nano::uncemented_info, std::greater<>> nano::ledger::unc
nano::locked<std::multimap<uint64_t, nano::uncemented_info, std::greater<>>> result;
using result_t = decltype (result)::value_type;
store.latest_for_each_par ([this, &result](nano::read_transaction const & transaction_a, nano::store_iterator<nano::account, nano::account_info> i, nano::store_iterator<nano::account, nano::account_info> n) {
store.accounts_for_each_par ([this, &result](nano::read_transaction const & transaction_a, nano::store_iterator<nano::account, nano::account_info> i, nano::store_iterator<nano::account, nano::account_info> n) {
result_t unconfirmed_frontiers_l;
for (; i != n; ++i)
{

View file

@ -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<std::shared_ptr<nano::block>> &);
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;

View file

@ -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);