Account store break up (#3306)
* Moves account store related methods out of block_store class * Renames 'account' word from the method names * Adds a comment to the class
This commit is contained in:
parent
17e7687033
commit
fbb9c7922f
27 changed files with 375 additions and 330 deletions
|
@ -330,7 +330,7 @@ TEST (block_store, genesis)
|
|||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger_cache);
|
||||
nano::account_info info;
|
||||
ASSERT_FALSE (store->account_get (transaction, nano::genesis_account, info));
|
||||
ASSERT_FALSE (store->account.get (transaction, nano::genesis_account, info));
|
||||
ASSERT_EQ (hash, info.head);
|
||||
auto block1 (store->block_get (transaction, info.head));
|
||||
ASSERT_NE (nullptr, block1);
|
||||
|
@ -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->accounts_begin (transaction));
|
||||
auto end (store->accounts_end ());
|
||||
auto begin (store->account.begin (transaction));
|
||||
auto end (store->account.end ());
|
||||
ASSERT_EQ (end, begin);
|
||||
}
|
||||
|
||||
|
@ -529,9 +529,9 @@ TEST (block_store, frontier_retrieval)
|
|||
nano::account_info info1 (0, 0, 0, 0, 0, 0, nano::epoch::epoch_0);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->confirmation_height_put (transaction, account1, { 0, nano::block_hash (0) });
|
||||
store->account_put (transaction, account1, info1);
|
||||
store->account.put (transaction, account1, info1);
|
||||
nano::account_info info2;
|
||||
store->account_get (transaction, account1, info2);
|
||||
store->account.get (transaction, account1, info2);
|
||||
ASSERT_EQ (info1, info2);
|
||||
}
|
||||
|
||||
|
@ -544,9 +544,9 @@ TEST (block_store, one_account)
|
|||
nano::block_hash hash (0);
|
||||
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->accounts_begin (transaction));
|
||||
auto end (store->accounts_end ());
|
||||
store->account.put (transaction, account, { hash, account, hash, 42, 100, 200, nano::epoch::epoch_0 });
|
||||
auto begin (store->account.begin (transaction));
|
||||
auto end (store->account.end ());
|
||||
ASSERT_NE (end, begin);
|
||||
ASSERT_EQ (account, nano::account (begin->first));
|
||||
nano::account_info info (begin->second);
|
||||
|
@ -596,11 +596,11 @@ TEST (block_store, two_account)
|
|||
nano::block_hash hash2 (4);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->confirmation_height_put (transaction, account1, { 20, nano::block_hash (10) });
|
||||
store->account_put (transaction, account1, { hash1, account1, hash1, 42, 100, 300, nano::epoch::epoch_0 });
|
||||
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->accounts_begin (transaction));
|
||||
auto end (store->accounts_end ());
|
||||
store->account.put (transaction, account2, { hash2, account2, hash2, 84, 200, 400, nano::epoch::epoch_0 });
|
||||
auto begin (store->account.begin (transaction));
|
||||
auto end (store->account.end ());
|
||||
ASSERT_NE (end, begin);
|
||||
ASSERT_EQ (account1, nano::account (begin->first));
|
||||
nano::account_info info1 (begin->second);
|
||||
|
@ -638,17 +638,17 @@ TEST (block_store, latest_find)
|
|||
nano::block_hash hash2 (4);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->confirmation_height_put (transaction, account1, { 0, nano::block_hash (0) });
|
||||
store->account_put (transaction, account1, { hash1, account1, hash1, 100, 0, 300, nano::epoch::epoch_0 });
|
||||
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->accounts_begin (transaction));
|
||||
auto second (store->accounts_begin (transaction));
|
||||
store->account.put (transaction, account2, { hash2, account2, hash2, 200, 0, 400, nano::epoch::epoch_0 });
|
||||
auto first (store->account.begin (transaction));
|
||||
auto second (store->account.begin (transaction));
|
||||
++second;
|
||||
auto find1 (store->accounts_begin (transaction, 1));
|
||||
auto find1 (store->account.begin (transaction, 1));
|
||||
ASSERT_EQ (first, find1);
|
||||
auto find2 (store->accounts_begin (transaction, 3));
|
||||
auto find2 (store->account.begin (transaction, 3));
|
||||
ASSERT_EQ (second, find2);
|
||||
auto find3 (store->accounts_begin (transaction, 2));
|
||||
auto find3 (store->account.begin (transaction, 2));
|
||||
ASSERT_EQ (second, find3);
|
||||
}
|
||||
|
||||
|
@ -765,9 +765,9 @@ TEST (block_store, latest_exists)
|
|||
nano::account_info info;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->confirmation_height_put (transaction, two, { 0, nano::block_hash (0) });
|
||||
store->account_put (transaction, two, info);
|
||||
store->account.put (transaction, two, info);
|
||||
nano::account one (1);
|
||||
ASSERT_FALSE (store->account_exists (transaction, one));
|
||||
ASSERT_FALSE (store->account.exists (transaction, one));
|
||||
}
|
||||
|
||||
TEST (block_store, large_iteration)
|
||||
|
@ -783,12 +783,12 @@ TEST (block_store, large_iteration)
|
|||
nano::random_pool::generate_block (account.bytes.data (), account.bytes.size ());
|
||||
accounts1.insert (account);
|
||||
store->confirmation_height_put (transaction, account, { 0, nano::block_hash (0) });
|
||||
store->account_put (transaction, account, nano::account_info ());
|
||||
store->account.put (transaction, account, nano::account_info ());
|
||||
}
|
||||
std::unordered_set<nano::account> accounts2;
|
||||
nano::account previous (0);
|
||||
auto transaction (store->tx_begin_read ());
|
||||
for (auto i (store->accounts_begin (transaction, 0)), n (store->accounts_end ()); i != n; ++i)
|
||||
for (auto i (store->account.begin (transaction, 0)), n (store->account.end ()); i != n; ++i)
|
||||
{
|
||||
nano::account current (i->first);
|
||||
ASSERT_GT (current.number (), previous.number ());
|
||||
|
@ -799,7 +799,7 @@ TEST (block_store, large_iteration)
|
|||
// Reverse iteration
|
||||
std::unordered_set<nano::account> accounts3;
|
||||
previous = std::numeric_limits<nano::uint256_t>::max ();
|
||||
for (auto i (store->accounts_rbegin (transaction)), n (store->accounts_end ()); i != n; --i)
|
||||
for (auto i (store->account.rbegin (transaction)), n (store->account.end ()); i != n; --i)
|
||||
{
|
||||
nano::account current (i->first);
|
||||
ASSERT_LT (current.number (), previous.number ());
|
||||
|
@ -865,13 +865,13 @@ TEST (block_store, account_count)
|
|||
ASSERT_TRUE (!store->init_error ());
|
||||
{
|
||||
auto transaction (store->tx_begin_write ());
|
||||
ASSERT_EQ (0, store->account_count (transaction));
|
||||
ASSERT_EQ (0, store->account.count (transaction));
|
||||
nano::account account (200);
|
||||
store->confirmation_height_put (transaction, account, { 0, nano::block_hash (0) });
|
||||
store->account_put (transaction, account, nano::account_info ());
|
||||
store->account.put (transaction, account, nano::account_info ());
|
||||
}
|
||||
auto transaction (store->tx_begin_read ());
|
||||
ASSERT_EQ (1, store->account_count (transaction));
|
||||
ASSERT_EQ (1, store->account.count (transaction));
|
||||
}
|
||||
|
||||
TEST (block_store, cemented_count_cache)
|
||||
|
@ -1285,7 +1285,7 @@ TEST (mdb_block_store, upgrade_v14_v15)
|
|||
auto transaction (store.tx_begin_write ());
|
||||
store.initialize (transaction, genesis, ledger.cache);
|
||||
nano::account_info account_info;
|
||||
ASSERT_FALSE (store.account_get (transaction, nano::genesis_account, account_info));
|
||||
ASSERT_FALSE (store.account.get (transaction, nano::genesis_account, account_info));
|
||||
nano::confirmation_height_info confirmation_height_info;
|
||||
ASSERT_FALSE (store.confirmation_height_get (transaction, nano::genesis_account, confirmation_height_info));
|
||||
ASSERT_EQ (confirmation_height_info.height, 1);
|
||||
|
@ -1325,7 +1325,7 @@ TEST (mdb_block_store, upgrade_v14_v15)
|
|||
ASSERT_FALSE (mdb_get (store.env.tx (transaction), store.accounts_v1, nano::mdb_val (nano::genesis_account), value));
|
||||
nano::account_info info;
|
||||
ASSERT_NE (value.size (), info.db_size ());
|
||||
store.account_del (transaction, nano::genesis_account);
|
||||
store.account.del (transaction, nano::genesis_account);
|
||||
|
||||
// Confirmation height for the account should be deleted
|
||||
ASSERT_TRUE (mdb_get (store.env.tx (transaction), store.confirmation_height, nano::mdb_val (nano::genesis_account), value));
|
||||
|
@ -2116,7 +2116,7 @@ void write_block_w_sideband_v18 (nano::mdb_store & store_a, MDB_dbi database, na
|
|||
void modify_account_info_to_v14 (nano::mdb_store & store, nano::transaction const & transaction, nano::account const & account, uint64_t confirmation_height, nano::block_hash const & rep_block)
|
||||
{
|
||||
nano::account_info info;
|
||||
ASSERT_FALSE (store.account_get (transaction, account, info));
|
||||
ASSERT_FALSE (store.account.get (transaction, account, info));
|
||||
nano::account_info_v14 account_info_v14 (info.head, rep_block, info.open_block, info.balance, info.modified, info.block_count, confirmation_height, info.epoch ());
|
||||
auto status (mdb_put (store.env.tx (transaction), info.epoch () == nano::epoch::epoch_0 ? store.accounts_v0 : store.accounts_v1, nano::mdb_val (account), nano::mdb_val (account_info_v14), 0));
|
||||
ASSERT_EQ (status, 0);
|
||||
|
|
|
@ -162,22 +162,22 @@ TEST (confirmation_height, multiple_accounts)
|
|||
auto & store = node->store;
|
||||
auto transaction = node->store.tx_begin_read ();
|
||||
ASSERT_TRUE (node->ledger.block_confirmed (transaction, receive3->hash ()));
|
||||
ASSERT_FALSE (store.account_get (transaction, nano::dev_genesis_key.pub, account_info));
|
||||
ASSERT_FALSE (store.account.get (transaction, nano::dev_genesis_key.pub, account_info));
|
||||
ASSERT_FALSE (node->store.confirmation_height_get (transaction, nano::dev_genesis_key.pub, confirmation_height_info));
|
||||
ASSERT_EQ (4, confirmation_height_info.height);
|
||||
ASSERT_EQ (send3.hash (), confirmation_height_info.frontier);
|
||||
ASSERT_EQ (4, account_info.block_count);
|
||||
ASSERT_FALSE (store.account_get (transaction, key1.pub, account_info));
|
||||
ASSERT_FALSE (store.account.get (transaction, key1.pub, account_info));
|
||||
ASSERT_FALSE (node->store.confirmation_height_get (transaction, key1.pub, confirmation_height_info));
|
||||
ASSERT_EQ (2, confirmation_height_info.height);
|
||||
ASSERT_EQ (send4.hash (), confirmation_height_info.frontier);
|
||||
ASSERT_EQ (3, account_info.block_count);
|
||||
ASSERT_FALSE (store.account_get (transaction, key2.pub, account_info));
|
||||
ASSERT_FALSE (store.account.get (transaction, key2.pub, account_info));
|
||||
ASSERT_FALSE (node->store.confirmation_height_get (transaction, key2.pub, confirmation_height_info));
|
||||
ASSERT_EQ (3, confirmation_height_info.height);
|
||||
ASSERT_EQ (send6.hash (), confirmation_height_info.frontier);
|
||||
ASSERT_EQ (4, account_info.block_count);
|
||||
ASSERT_FALSE (store.account_get (transaction, key3.pub, account_info));
|
||||
ASSERT_FALSE (store.account.get (transaction, key3.pub, account_info));
|
||||
ASSERT_FALSE (node->store.confirmation_height_get (transaction, key3.pub, confirmation_height_info));
|
||||
ASSERT_EQ (2, confirmation_height_info.height);
|
||||
ASSERT_EQ (receive3->hash (), confirmation_height_info.frontier);
|
||||
|
@ -443,13 +443,13 @@ TEST (confirmation_height, send_receive_between_2_accounts)
|
|||
ASSERT_TRUE (node->ledger.block_confirmed (transaction, receive4->hash ()));
|
||||
nano::account_info account_info;
|
||||
nano::confirmation_height_info confirmation_height_info;
|
||||
ASSERT_FALSE (node->store.account_get (transaction, nano::dev_genesis_key.pub, account_info));
|
||||
ASSERT_FALSE (node->store.account.get (transaction, nano::dev_genesis_key.pub, account_info));
|
||||
ASSERT_FALSE (node->store.confirmation_height_get (transaction, nano::dev_genesis_key.pub, confirmation_height_info));
|
||||
ASSERT_EQ (6, confirmation_height_info.height);
|
||||
ASSERT_EQ (send5.hash (), confirmation_height_info.frontier);
|
||||
ASSERT_EQ (7, account_info.block_count);
|
||||
|
||||
ASSERT_FALSE (node->store.account_get (transaction, key1.pub, account_info));
|
||||
ASSERT_FALSE (node->store.account.get (transaction, key1.pub, account_info));
|
||||
ASSERT_FALSE (node->store.confirmation_height_get (transaction, key1.pub, confirmation_height_info));
|
||||
ASSERT_EQ (5, confirmation_height_info.height);
|
||||
ASSERT_EQ (receive4->hash (), confirmation_height_info.frontier);
|
||||
|
@ -513,7 +513,7 @@ TEST (confirmation_height, send_receive_self)
|
|||
auto transaction (node->store.tx_begin_read ());
|
||||
ASSERT_TRUE (node->ledger.block_confirmed (transaction, receive3->hash ()));
|
||||
nano::account_info account_info;
|
||||
ASSERT_FALSE (node->store.account_get (transaction, nano::dev_genesis_key.pub, account_info));
|
||||
ASSERT_FALSE (node->store.account.get (transaction, nano::dev_genesis_key.pub, account_info));
|
||||
nano::confirmation_height_info confirmation_height_info;
|
||||
ASSERT_FALSE (node->store.confirmation_height_get (transaction, nano::dev_genesis_key.pub, confirmation_height_info));
|
||||
ASSERT_EQ (7, confirmation_height_info.height);
|
||||
|
@ -611,19 +611,19 @@ TEST (confirmation_height, all_block_types)
|
|||
ASSERT_TRUE (node->ledger.block_confirmed (transaction, state_send2->hash ()));
|
||||
nano::account_info account_info;
|
||||
nano::confirmation_height_info confirmation_height_info;
|
||||
ASSERT_FALSE (node->store.account_get (transaction, nano::dev_genesis_key.pub, account_info));
|
||||
ASSERT_FALSE (node->store.account.get (transaction, nano::dev_genesis_key.pub, account_info));
|
||||
ASSERT_FALSE (node->store.confirmation_height_get (transaction, nano::dev_genesis_key.pub, confirmation_height_info));
|
||||
ASSERT_EQ (3, confirmation_height_info.height);
|
||||
ASSERT_EQ (send1.hash (), confirmation_height_info.frontier);
|
||||
ASSERT_LE (4, account_info.block_count);
|
||||
|
||||
ASSERT_FALSE (node->store.account_get (transaction, key1.pub, account_info));
|
||||
ASSERT_FALSE (node->store.account.get (transaction, key1.pub, account_info));
|
||||
ASSERT_FALSE (node->store.confirmation_height_get (transaction, key1.pub, confirmation_height_info));
|
||||
ASSERT_EQ (state_send1.hash (), confirmation_height_info.frontier);
|
||||
ASSERT_EQ (6, confirmation_height_info.height);
|
||||
ASSERT_LE (7, account_info.block_count);
|
||||
|
||||
ASSERT_FALSE (node->store.account_get (transaction, key2.pub, account_info));
|
||||
ASSERT_FALSE (node->store.account.get (transaction, key2.pub, account_info));
|
||||
ASSERT_FALSE (node->store.confirmation_height_get (transaction, key2.pub, confirmation_height_info));
|
||||
ASSERT_EQ (7, confirmation_height_info.height);
|
||||
ASSERT_EQ (state_send2->hash (), confirmation_height_info.frontier);
|
||||
|
|
|
@ -54,7 +54,7 @@ TEST (ledger, genesis_balance)
|
|||
auto amount (ledger.amount (transaction, nano::genesis_account));
|
||||
ASSERT_EQ (nano::genesis_amount, amount);
|
||||
nano::account_info info;
|
||||
ASSERT_FALSE (store->account_get (transaction, nano::genesis_account, info));
|
||||
ASSERT_FALSE (store->account.get (transaction, nano::genesis_account, info));
|
||||
ASSERT_EQ (1, ledger.cache.account_count);
|
||||
// Frontier time should have been updated when genesis balance was added
|
||||
ASSERT_GE (nano::seconds_since_epoch (), info.modified);
|
||||
|
@ -105,7 +105,7 @@ TEST (ledger, process_send)
|
|||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::account_info info1;
|
||||
ASSERT_FALSE (store->account_get (transaction, nano::dev_genesis_key.pub, info1));
|
||||
ASSERT_FALSE (store->account.get (transaction, nano::dev_genesis_key.pub, info1));
|
||||
nano::keypair key2;
|
||||
nano::send_block send (info1.head, key2.pub, 50, nano::dev_genesis_key.prv, nano::dev_genesis_key.pub, *pool.generate (info1.head));
|
||||
nano::block_hash hash1 (send.hash ());
|
||||
|
@ -123,7 +123,7 @@ TEST (ledger, process_send)
|
|||
ASSERT_EQ (50, ledger.account_balance (transaction, nano::dev_genesis_key.pub));
|
||||
ASSERT_EQ (nano::genesis_amount - 50, ledger.account_pending (transaction, key2.pub));
|
||||
nano::account_info info2;
|
||||
ASSERT_FALSE (store->account_get (transaction, nano::dev_genesis_key.pub, info2));
|
||||
ASSERT_FALSE (store->account.get (transaction, nano::dev_genesis_key.pub, info2));
|
||||
ASSERT_EQ (2, info2.block_count);
|
||||
auto latest6 (store->block_get (transaction, info2.head));
|
||||
ASSERT_NE (nullptr, latest6);
|
||||
|
@ -149,14 +149,14 @@ TEST (ledger, process_send)
|
|||
ASSERT_EQ (50, ledger.weight (nano::dev_genesis_key.pub));
|
||||
ASSERT_EQ (nano::genesis_amount - 50, ledger.weight (key2.pub));
|
||||
nano::account_info info3;
|
||||
ASSERT_FALSE (store->account_get (transaction, nano::dev_genesis_key.pub, info3));
|
||||
ASSERT_FALSE (store->account.get (transaction, nano::dev_genesis_key.pub, info3));
|
||||
auto latest2 (store->block_get (transaction, info3.head));
|
||||
ASSERT_NE (nullptr, latest2);
|
||||
auto latest3 (dynamic_cast<nano::send_block *> (latest2.get ()));
|
||||
ASSERT_NE (nullptr, latest3);
|
||||
ASSERT_EQ (send, *latest3);
|
||||
nano::account_info info4;
|
||||
ASSERT_FALSE (store->account_get (transaction, key2.pub, info4));
|
||||
ASSERT_FALSE (store->account.get (transaction, key2.pub, info4));
|
||||
auto latest4 (store->block_get (transaction, info4.head));
|
||||
ASSERT_NE (nullptr, latest4);
|
||||
auto latest5 (dynamic_cast<nano::open_block *> (latest4.get ()));
|
||||
|
@ -165,7 +165,7 @@ TEST (ledger, process_send)
|
|||
ASSERT_FALSE (ledger.rollback (transaction, hash2));
|
||||
ASSERT_TRUE (store->frontier.get (transaction, hash2).is_zero ());
|
||||
nano::account_info info5;
|
||||
ASSERT_TRUE (ledger.store.account_get (transaction, key2.pub, info5));
|
||||
ASSERT_TRUE (ledger.store.account.get (transaction, key2.pub, info5));
|
||||
nano::pending_info pending1;
|
||||
ASSERT_FALSE (ledger.store.pending.get (transaction, nano::pending_key (key2.pub, hash1), pending1));
|
||||
ASSERT_EQ (nano::dev_genesis_key.pub, pending1.source);
|
||||
|
@ -176,21 +176,21 @@ TEST (ledger, process_send)
|
|||
ASSERT_EQ (50, ledger.weight (nano::dev_genesis_key.pub));
|
||||
ASSERT_EQ (0, ledger.weight (key2.pub));
|
||||
nano::account_info info6;
|
||||
ASSERT_FALSE (ledger.store.account_get (transaction, nano::dev_genesis_key.pub, info6));
|
||||
ASSERT_FALSE (ledger.store.account.get (transaction, nano::dev_genesis_key.pub, info6));
|
||||
ASSERT_EQ (hash1, info6.head);
|
||||
ASSERT_FALSE (ledger.rollback (transaction, info6.head));
|
||||
ASSERT_EQ (nano::genesis_amount, ledger.weight (nano::dev_genesis_key.pub));
|
||||
ASSERT_EQ (nano::dev_genesis_key.pub, store->frontier.get (transaction, info1.head));
|
||||
ASSERT_TRUE (store->frontier.get (transaction, hash1).is_zero ());
|
||||
nano::account_info info7;
|
||||
ASSERT_FALSE (ledger.store.account_get (transaction, nano::dev_genesis_key.pub, info7));
|
||||
ASSERT_FALSE (ledger.store.account.get (transaction, nano::dev_genesis_key.pub, info7));
|
||||
ASSERT_EQ (1, info7.block_count);
|
||||
ASSERT_EQ (info1.head, info7.head);
|
||||
nano::pending_info pending2;
|
||||
ASSERT_TRUE (ledger.store.pending.get (transaction, nano::pending_key (key2.pub, hash1), pending2));
|
||||
ASSERT_EQ (nano::genesis_amount, ledger.account_balance (transaction, nano::dev_genesis_key.pub));
|
||||
ASSERT_EQ (0, ledger.account_pending (transaction, key2.pub));
|
||||
ASSERT_EQ (store->account_count (transaction), ledger.cache.account_count);
|
||||
ASSERT_EQ (store->account.count (transaction), ledger.cache.account_count);
|
||||
}
|
||||
|
||||
TEST (ledger, process_receive)
|
||||
|
@ -205,7 +205,7 @@ TEST (ledger, process_receive)
|
|||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::account_info info1;
|
||||
ASSERT_FALSE (store->account_get (transaction, nano::dev_genesis_key.pub, info1));
|
||||
ASSERT_FALSE (store->account.get (transaction, nano::dev_genesis_key.pub, info1));
|
||||
nano::keypair key2;
|
||||
nano::send_block send (info1.head, key2.pub, 50, nano::dev_genesis_key.prv, nano::dev_genesis_key.pub, *pool.generate (info1.head));
|
||||
nano::block_hash hash1 (send.hash ());
|
||||
|
@ -254,7 +254,7 @@ TEST (ledger, process_receive)
|
|||
ASSERT_FALSE (ledger.store.pending.get (transaction, nano::pending_key (key2.pub, hash3), pending1));
|
||||
ASSERT_EQ (nano::dev_genesis_key.pub, pending1.source);
|
||||
ASSERT_EQ (25, pending1.amount.number ());
|
||||
ASSERT_EQ (store->account_count (transaction), ledger.cache.account_count);
|
||||
ASSERT_EQ (store->account.count (transaction), ledger.cache.account_count);
|
||||
}
|
||||
|
||||
TEST (ledger, rollback_receiver)
|
||||
|
@ -269,7 +269,7 @@ TEST (ledger, rollback_receiver)
|
|||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::account_info info1;
|
||||
ASSERT_FALSE (store->account_get (transaction, nano::dev_genesis_key.pub, info1));
|
||||
ASSERT_FALSE (store->account.get (transaction, nano::dev_genesis_key.pub, info1));
|
||||
nano::keypair key2;
|
||||
nano::send_block send (info1.head, key2.pub, 50, nano::dev_genesis_key.prv, nano::dev_genesis_key.pub, *pool.generate (info1.head));
|
||||
nano::block_hash hash1 (send.hash ());
|
||||
|
@ -291,8 +291,8 @@ TEST (ledger, rollback_receiver)
|
|||
ASSERT_EQ (0, ledger.weight (key2.pub));
|
||||
ASSERT_EQ (0, ledger.weight (key3.pub));
|
||||
nano::account_info info2;
|
||||
ASSERT_TRUE (ledger.store.account_get (transaction, key2.pub, info2));
|
||||
ASSERT_EQ (store->account_count (transaction), ledger.cache.account_count);
|
||||
ASSERT_TRUE (ledger.store.account.get (transaction, key2.pub, info2));
|
||||
ASSERT_EQ (store->account.count (transaction), ledger.cache.account_count);
|
||||
nano::pending_info pending1;
|
||||
ASSERT_TRUE (ledger.store.pending.get (transaction, nano::pending_key (key2.pub, info2.head), pending1));
|
||||
}
|
||||
|
@ -327,11 +327,11 @@ TEST (ledger, rollback_representation)
|
|||
ASSERT_EQ (1, ledger.weight (key3.pub));
|
||||
ASSERT_EQ (nano::genesis_amount - 1, ledger.weight (key4.pub));
|
||||
nano::account_info info1;
|
||||
ASSERT_FALSE (store->account_get (transaction, key2.pub, info1));
|
||||
ASSERT_FALSE (store->account.get (transaction, key2.pub, info1));
|
||||
ASSERT_EQ (key4.pub, info1.representative);
|
||||
ASSERT_FALSE (ledger.rollback (transaction, receive1.hash ()));
|
||||
nano::account_info info2;
|
||||
ASSERT_FALSE (store->account_get (transaction, key2.pub, info2));
|
||||
ASSERT_FALSE (store->account.get (transaction, key2.pub, info2));
|
||||
ASSERT_EQ (key4.pub, info2.representative);
|
||||
ASSERT_EQ (0, ledger.weight (key2.pub));
|
||||
ASSERT_EQ (nano::genesis_amount - 50, ledger.weight (key4.pub));
|
||||
|
@ -341,11 +341,11 @@ TEST (ledger, rollback_representation)
|
|||
ledger.rollback (transaction, send1.hash ());
|
||||
ASSERT_EQ (nano::genesis_amount, ledger.weight (key3.pub));
|
||||
nano::account_info info3;
|
||||
ASSERT_FALSE (store->account_get (transaction, nano::dev_genesis_key.pub, info3));
|
||||
ASSERT_FALSE (store->account.get (transaction, nano::dev_genesis_key.pub, info3));
|
||||
ASSERT_EQ (key3.pub, info3.representative);
|
||||
ASSERT_FALSE (ledger.rollback (transaction, change2.hash ()));
|
||||
nano::account_info info4;
|
||||
ASSERT_FALSE (store->account_get (transaction, nano::dev_genesis_key.pub, info4));
|
||||
ASSERT_FALSE (store->account.get (transaction, nano::dev_genesis_key.pub, info4));
|
||||
ASSERT_EQ (key5.pub, info4.representative);
|
||||
ASSERT_EQ (nano::genesis_amount, ledger.weight (key5.pub));
|
||||
ASSERT_EQ (0, ledger.weight (key3.pub));
|
||||
|
@ -381,7 +381,7 @@ TEST (ledger, process_duplicate)
|
|||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::account_info info1;
|
||||
ASSERT_FALSE (store->account_get (transaction, nano::dev_genesis_key.pub, info1));
|
||||
ASSERT_FALSE (store->account.get (transaction, nano::dev_genesis_key.pub, info1));
|
||||
nano::keypair key2;
|
||||
nano::send_block send (info1.head, key2.pub, 50, nano::dev_genesis_key.prv, nano::dev_genesis_key.pub, *pool.generate (info1.head));
|
||||
nano::block_hash hash1 (send.hash ());
|
||||
|
@ -435,7 +435,7 @@ TEST (ledger, representative_change)
|
|||
ASSERT_EQ (nano::genesis_amount, ledger.weight (nano::dev_genesis_key.pub));
|
||||
ASSERT_EQ (0, ledger.weight (key2.pub));
|
||||
nano::account_info info1;
|
||||
ASSERT_FALSE (store->account_get (transaction, nano::dev_genesis_key.pub, info1));
|
||||
ASSERT_FALSE (store->account.get (transaction, nano::dev_genesis_key.pub, info1));
|
||||
nano::change_block block (info1.head, key2.pub, nano::dev_genesis_key.prv, nano::dev_genesis_key.pub, *pool.generate (info1.head));
|
||||
ASSERT_EQ (nano::dev_genesis_key.pub, store->frontier.get (transaction, info1.head));
|
||||
auto return1 (ledger.process (transaction, block));
|
||||
|
@ -447,13 +447,13 @@ TEST (ledger, representative_change)
|
|||
ASSERT_EQ (0, ledger.weight (nano::dev_genesis_key.pub));
|
||||
ASSERT_EQ (nano::genesis_amount, ledger.weight (key2.pub));
|
||||
nano::account_info info2;
|
||||
ASSERT_FALSE (store->account_get (transaction, nano::dev_genesis_key.pub, info2));
|
||||
ASSERT_FALSE (store->account.get (transaction, nano::dev_genesis_key.pub, info2));
|
||||
ASSERT_EQ (block.hash (), info2.head);
|
||||
ASSERT_FALSE (ledger.rollback (transaction, info2.head));
|
||||
ASSERT_EQ (nano::dev_genesis_key.pub, store->frontier.get (transaction, info1.head));
|
||||
ASSERT_TRUE (store->frontier.get (transaction, block.hash ()).is_zero ());
|
||||
nano::account_info info3;
|
||||
ASSERT_FALSE (store->account_get (transaction, nano::dev_genesis_key.pub, info3));
|
||||
ASSERT_FALSE (store->account.get (transaction, nano::dev_genesis_key.pub, info3));
|
||||
ASSERT_EQ (info1.head, info3.head);
|
||||
ASSERT_EQ (nano::genesis_amount, ledger.weight (nano::dev_genesis_key.pub));
|
||||
ASSERT_EQ (0, ledger.weight (key2.pub));
|
||||
|
@ -473,7 +473,7 @@ TEST (ledger, send_fork)
|
|||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::account_info info1;
|
||||
ASSERT_FALSE (store->account_get (transaction, nano::dev_genesis_key.pub, info1));
|
||||
ASSERT_FALSE (store->account.get (transaction, nano::dev_genesis_key.pub, info1));
|
||||
nano::send_block block (info1.head, key2.pub, 100, nano::dev_genesis_key.prv, nano::dev_genesis_key.pub, *pool.generate (info1.head));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, block).code);
|
||||
nano::send_block block2 (info1.head, key3.pub, 0, nano::dev_genesis_key.prv, nano::dev_genesis_key.pub, *pool.generate (info1.head));
|
||||
|
@ -494,7 +494,7 @@ TEST (ledger, receive_fork)
|
|||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::account_info info1;
|
||||
ASSERT_FALSE (store->account_get (transaction, nano::dev_genesis_key.pub, info1));
|
||||
ASSERT_FALSE (store->account.get (transaction, nano::dev_genesis_key.pub, info1));
|
||||
nano::send_block block (info1.head, key2.pub, 100, nano::dev_genesis_key.prv, nano::dev_genesis_key.pub, *pool.generate (info1.head));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, block).code);
|
||||
nano::open_block block2 (block.hash (), key2.pub, key2.pub, key2.prv, key2.pub, *pool.generate (key2.pub));
|
||||
|
@ -521,7 +521,7 @@ TEST (ledger, open_fork)
|
|||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::account_info info1;
|
||||
ASSERT_FALSE (store->account_get (transaction, nano::dev_genesis_key.pub, info1));
|
||||
ASSERT_FALSE (store->account.get (transaction, nano::dev_genesis_key.pub, info1));
|
||||
nano::send_block block (info1.head, key2.pub, 100, nano::dev_genesis_key.prv, nano::dev_genesis_key.pub, *pool.generate (info1.head));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, block).code);
|
||||
nano::open_block block2 (block.hash (), key2.pub, key2.pub, key2.prv, key2.pub, *pool.generate (key2.pub));
|
||||
|
@ -541,7 +541,7 @@ TEST (system, DISABLED_generate_send_existing)
|
|||
nano::account_info info1;
|
||||
{
|
||||
auto transaction (node1.store.tx_begin_read ());
|
||||
ASSERT_FALSE (node1.store.account_get (transaction, nano::dev_genesis_key.pub, info1));
|
||||
ASSERT_FALSE (node1.store.account.get (transaction, nano::dev_genesis_key.pub, info1));
|
||||
}
|
||||
std::vector<nano::account> accounts;
|
||||
accounts.push_back (nano::dev_genesis_key.pub);
|
||||
|
@ -557,7 +557,7 @@ TEST (system, DISABLED_generate_send_existing)
|
|||
nano::account_info info2;
|
||||
{
|
||||
auto transaction (node1.store.tx_begin_read ());
|
||||
ASSERT_FALSE (node1.store.account_get (transaction, nano::dev_genesis_key.pub, info2));
|
||||
ASSERT_FALSE (node1.store.account.get (transaction, nano::dev_genesis_key.pub, info2));
|
||||
}
|
||||
ASSERT_NE (info1.head, info2.head);
|
||||
system.deadline_set (15s);
|
||||
|
@ -565,7 +565,7 @@ TEST (system, DISABLED_generate_send_existing)
|
|||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
auto transaction (node1.store.tx_begin_read ());
|
||||
ASSERT_FALSE (node1.store.account_get (transaction, nano::dev_genesis_key.pub, info2));
|
||||
ASSERT_FALSE (node1.store.account.get (transaction, nano::dev_genesis_key.pub, info2));
|
||||
}
|
||||
ASSERT_EQ (info1.block_count + 2, info2.block_count);
|
||||
ASSERT_EQ (info2.balance, nano::genesis_amount / 3);
|
||||
|
@ -585,10 +585,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.accounts_begin (transaction));
|
||||
ASSERT_NE (node1.store.accounts_end (), iterator1);
|
||||
auto iterator1 (node1.store.account.begin (transaction));
|
||||
ASSERT_NE (node1.store.account.end (), iterator1);
|
||||
++iterator1;
|
||||
ASSERT_EQ (node1.store.accounts_end (), iterator1);
|
||||
ASSERT_EQ (node1.store.account.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));
|
||||
|
@ -1259,7 +1259,7 @@ TEST (ledger, fail_open_fork_previous)
|
|||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, block3).code);
|
||||
nano::open_block block4 (block2.hash (), 1, key1.pub, key1.prv, key1.pub, *pool.generate (key1.pub));
|
||||
ASSERT_EQ (nano::process_result::fork, ledger.process (transaction, block4).code);
|
||||
ASSERT_EQ (store->account_count (transaction), ledger.cache.account_count);
|
||||
ASSERT_EQ (store->account.count (transaction), ledger.cache.account_count);
|
||||
}
|
||||
|
||||
TEST (ledger, fail_open_account_mismatch)
|
||||
|
@ -1279,7 +1279,7 @@ TEST (ledger, fail_open_account_mismatch)
|
|||
nano::keypair badkey;
|
||||
nano::open_block block2 (block1.hash (), 1, badkey.pub, badkey.prv, badkey.pub, *pool.generate (badkey.pub));
|
||||
ASSERT_NE (nano::process_result::progress, ledger.process (transaction, block2).code);
|
||||
ASSERT_EQ (store->account_count (transaction), ledger.cache.account_count);
|
||||
ASSERT_EQ (store->account.count (transaction), ledger.cache.account_count);
|
||||
}
|
||||
|
||||
TEST (ledger, fail_receive_old)
|
||||
|
@ -1565,7 +1565,7 @@ TEST (ledger, send_open_receive_rollback)
|
|||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::account_info info1;
|
||||
ASSERT_FALSE (store->account_get (transaction, nano::dev_genesis_key.pub, info1));
|
||||
ASSERT_FALSE (store->account.get (transaction, nano::dev_genesis_key.pub, info1));
|
||||
nano::keypair key1;
|
||||
nano::send_block send1 (info1.head, key1.pub, nano::genesis_amount - 50, nano::dev_genesis_key.prv, nano::dev_genesis_key.pub, *pool.generate (info1.head));
|
||||
auto return1 (ledger.process (transaction, send1));
|
||||
|
@ -1626,7 +1626,7 @@ TEST (ledger, bootstrap_rep_weight)
|
|||
{
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
ASSERT_FALSE (store->account_get (transaction, nano::dev_genesis_key.pub, info1));
|
||||
ASSERT_FALSE (store->account.get (transaction, nano::dev_genesis_key.pub, info1));
|
||||
nano::send_block send (info1.head, key2.pub, std::numeric_limits<nano::uint128_t>::max () - 50, nano::dev_genesis_key.prv, nano::dev_genesis_key.pub, *pool.generate (info1.head));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send).code);
|
||||
}
|
||||
|
@ -1638,7 +1638,7 @@ TEST (ledger, bootstrap_rep_weight)
|
|||
}
|
||||
{
|
||||
auto transaction (store->tx_begin_write ());
|
||||
ASSERT_FALSE (store->account_get (transaction, nano::dev_genesis_key.pub, info1));
|
||||
ASSERT_FALSE (store->account.get (transaction, nano::dev_genesis_key.pub, info1));
|
||||
nano::send_block send (info1.head, key2.pub, std::numeric_limits<nano::uint128_t>::max () - 100, nano::dev_genesis_key.prv, nano::dev_genesis_key.pub, *pool.generate (info1.head));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send).code);
|
||||
}
|
||||
|
@ -1746,7 +1746,7 @@ TEST (ledger, state_send_receive)
|
|||
ASSERT_EQ (nano::Gxrb_ratio, ledger.amount (transaction, receive1.hash ()));
|
||||
ASSERT_EQ (nano::genesis_amount, ledger.weight (nano::genesis_account));
|
||||
ASSERT_FALSE (store->pending.exists (transaction, nano::pending_key (nano::genesis_account, send1.hash ())));
|
||||
ASSERT_EQ (store->account_count (transaction), ledger.cache.account_count);
|
||||
ASSERT_EQ (store->account.count (transaction), ledger.cache.account_count);
|
||||
ASSERT_EQ (3, receive2->sideband ().height);
|
||||
ASSERT_FALSE (receive2->sideband ().details.is_send);
|
||||
ASSERT_TRUE (receive2->sideband ().details.is_receive);
|
||||
|
@ -1848,7 +1848,7 @@ TEST (ledger, state_open)
|
|||
ASSERT_EQ (nano::Gxrb_ratio, ledger.balance (transaction, open1.hash ()));
|
||||
ASSERT_EQ (nano::Gxrb_ratio, ledger.amount (transaction, open1.hash ()));
|
||||
ASSERT_EQ (nano::genesis_amount, ledger.weight (nano::genesis_account));
|
||||
ASSERT_EQ (ledger.cache.account_count, store->account_count (transaction));
|
||||
ASSERT_EQ (ledger.cache.account_count, store->account.count (transaction));
|
||||
ASSERT_EQ (1, open2->sideband ().height);
|
||||
ASSERT_FALSE (open2->sideband ().details.is_send);
|
||||
ASSERT_TRUE (open2->sideband ().details.is_receive);
|
||||
|
@ -2041,7 +2041,7 @@ TEST (ledger, state_state_open_fork)
|
|||
nano::state_block open2 (destination.pub, 0, nano::genesis_account, nano::Gxrb_ratio, send1.hash (), destination.prv, destination.pub, *pool.generate (destination.pub));
|
||||
ASSERT_EQ (nano::process_result::fork, ledger.process (transaction, open2).code);
|
||||
ASSERT_EQ (open1.root (), open2.root ());
|
||||
ASSERT_EQ (store->account_count (transaction), ledger.cache.account_count);
|
||||
ASSERT_EQ (store->account.count (transaction), ledger.cache.account_count);
|
||||
}
|
||||
|
||||
TEST (ledger, state_open_previous_fail)
|
||||
|
@ -2220,7 +2220,7 @@ TEST (ledger, state_rollback_send)
|
|||
ASSERT_EQ (nano::genesis_amount, ledger.weight (nano::genesis_account));
|
||||
ASSERT_FALSE (store->pending.exists (transaction, nano::pending_key (nano::genesis_account, send1.hash ())));
|
||||
ASSERT_TRUE (store->block_successor (transaction, genesis.hash ()).is_zero ());
|
||||
ASSERT_EQ (store->account_count (transaction), ledger.cache.account_count);
|
||||
ASSERT_EQ (store->account.count (transaction), ledger.cache.account_count);
|
||||
}
|
||||
|
||||
TEST (ledger, state_rollback_receive)
|
||||
|
@ -2247,7 +2247,7 @@ TEST (ledger, state_rollback_receive)
|
|||
ASSERT_FALSE (store->block_exists (transaction, receive1.hash ()));
|
||||
ASSERT_EQ (nano::genesis_amount - nano::Gxrb_ratio, ledger.account_balance (transaction, nano::genesis_account));
|
||||
ASSERT_EQ (nano::genesis_amount - nano::Gxrb_ratio, ledger.weight (nano::genesis_account));
|
||||
ASSERT_EQ (store->account_count (transaction), ledger.cache.account_count);
|
||||
ASSERT_EQ (store->account.count (transaction), ledger.cache.account_count);
|
||||
}
|
||||
|
||||
TEST (ledger, state_rollback_received_send)
|
||||
|
@ -2275,7 +2275,7 @@ TEST (ledger, state_rollback_received_send)
|
|||
ASSERT_EQ (nano::genesis_amount, ledger.weight (nano::genesis_account));
|
||||
ASSERT_EQ (0, ledger.account_balance (transaction, key.pub));
|
||||
ASSERT_EQ (0, ledger.weight (key.pub));
|
||||
ASSERT_EQ (store->account_count (transaction), ledger.cache.account_count);
|
||||
ASSERT_EQ (store->account.count (transaction), ledger.cache.account_count);
|
||||
}
|
||||
|
||||
TEST (ledger, state_rep_change_rollback)
|
||||
|
@ -2323,7 +2323,7 @@ TEST (ledger, state_open_rollback)
|
|||
ASSERT_FALSE (store->pending.get (transaction, nano::pending_key (destination.pub, send1.hash ()), info));
|
||||
ASSERT_EQ (nano::genesis_account, info.source);
|
||||
ASSERT_EQ (nano::Gxrb_ratio, info.amount.number ());
|
||||
ASSERT_EQ (store->account_count (transaction), ledger.cache.account_count);
|
||||
ASSERT_EQ (store->account.count (transaction), ledger.cache.account_count);
|
||||
}
|
||||
|
||||
TEST (ledger, state_send_change_rollback)
|
||||
|
@ -2345,7 +2345,7 @@ TEST (ledger, state_send_change_rollback)
|
|||
ASSERT_EQ (nano::genesis_amount, ledger.account_balance (transaction, nano::genesis_account));
|
||||
ASSERT_EQ (nano::genesis_amount, ledger.weight (nano::genesis_account));
|
||||
ASSERT_EQ (0, ledger.weight (rep.pub));
|
||||
ASSERT_EQ (store->account_count (transaction), ledger.cache.account_count);
|
||||
ASSERT_EQ (store->account.count (transaction), ledger.cache.account_count);
|
||||
}
|
||||
|
||||
TEST (ledger, state_receive_change_rollback)
|
||||
|
@ -2369,7 +2369,7 @@ TEST (ledger, state_receive_change_rollback)
|
|||
ASSERT_EQ (nano::genesis_amount - nano::Gxrb_ratio, ledger.account_balance (transaction, nano::genesis_account));
|
||||
ASSERT_EQ (nano::genesis_amount - nano::Gxrb_ratio, ledger.weight (nano::genesis_account));
|
||||
ASSERT_EQ (0, ledger.weight (rep.pub));
|
||||
ASSERT_EQ (store->account_count (transaction), ledger.cache.account_count);
|
||||
ASSERT_EQ (store->account.count (transaction), ledger.cache.account_count);
|
||||
}
|
||||
|
||||
TEST (ledger, epoch_blocks_v1_general)
|
||||
|
@ -2394,13 +2394,13 @@ TEST (ledger, epoch_blocks_v1_general)
|
|||
nano::state_block epoch2 (nano::genesis_account, epoch1.hash (), nano::genesis_account, nano::genesis_amount, ledger.epoch_link (nano::epoch::epoch_1), nano::dev_genesis_key.prv, nano::dev_genesis_key.pub, *pool.generate (epoch1.hash ()));
|
||||
ASSERT_EQ (nano::process_result::block_position, ledger.process (transaction, epoch2).code);
|
||||
nano::account_info genesis_info;
|
||||
ASSERT_FALSE (ledger.store.account_get (transaction, nano::genesis_account, genesis_info));
|
||||
ASSERT_FALSE (ledger.store.account.get (transaction, nano::genesis_account, genesis_info));
|
||||
ASSERT_EQ (genesis_info.epoch (), nano::epoch::epoch_1);
|
||||
ASSERT_FALSE (ledger.rollback (transaction, epoch1.hash ()));
|
||||
ASSERT_FALSE (ledger.store.account_get (transaction, nano::genesis_account, genesis_info));
|
||||
ASSERT_FALSE (ledger.store.account.get (transaction, nano::genesis_account, genesis_info));
|
||||
ASSERT_EQ (genesis_info.epoch (), nano::epoch::epoch_0);
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, epoch1).code);
|
||||
ASSERT_FALSE (ledger.store.account_get (transaction, nano::genesis_account, genesis_info));
|
||||
ASSERT_FALSE (ledger.store.account.get (transaction, nano::genesis_account, genesis_info));
|
||||
ASSERT_EQ (genesis_info.epoch (), nano::epoch::epoch_1);
|
||||
ASSERT_FALSE (epoch1.sideband ().details.is_send);
|
||||
ASSERT_FALSE (epoch1.sideband ().details.is_receive);
|
||||
|
@ -2470,13 +2470,13 @@ TEST (ledger, epoch_blocks_v2_general)
|
|||
nano::state_block epoch3 (nano::genesis_account, epoch2.hash (), nano::genesis_account, nano::genesis_amount, ledger.epoch_link (nano::epoch::epoch_2), nano::dev_genesis_key.prv, nano::dev_genesis_key.pub, *pool.generate (epoch2.hash ()));
|
||||
ASSERT_EQ (nano::process_result::block_position, ledger.process (transaction, epoch3).code);
|
||||
nano::account_info genesis_info;
|
||||
ASSERT_FALSE (ledger.store.account_get (transaction, nano::genesis_account, genesis_info));
|
||||
ASSERT_FALSE (ledger.store.account.get (transaction, nano::genesis_account, genesis_info));
|
||||
ASSERT_EQ (genesis_info.epoch (), nano::epoch::epoch_2);
|
||||
ASSERT_FALSE (ledger.rollback (transaction, epoch1.hash ()));
|
||||
ASSERT_FALSE (ledger.store.account_get (transaction, nano::genesis_account, genesis_info));
|
||||
ASSERT_FALSE (ledger.store.account.get (transaction, nano::genesis_account, genesis_info));
|
||||
ASSERT_EQ (genesis_info.epoch (), nano::epoch::epoch_0);
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, epoch1).code);
|
||||
ASSERT_FALSE (ledger.store.account_get (transaction, nano::genesis_account, genesis_info));
|
||||
ASSERT_FALSE (ledger.store.account.get (transaction, nano::genesis_account, genesis_info));
|
||||
ASSERT_EQ (genesis_info.epoch (), nano::epoch::epoch_1);
|
||||
nano::change_block change1 (epoch1.hash (), nano::genesis_account, nano::dev_genesis_key.prv, nano::dev_genesis_key.pub, *pool.generate (epoch1.hash ()));
|
||||
ASSERT_EQ (nano::process_result::block_position, ledger.process (transaction, change1).code);
|
||||
|
@ -2540,10 +2540,10 @@ TEST (ledger, epoch_blocks_receive_upgrade)
|
|||
ASSERT_EQ (nano::epoch::epoch_1, receive2.sideband ().details.epoch);
|
||||
ASSERT_EQ (nano::epoch::epoch_1, receive2.sideband ().source_epoch);
|
||||
nano::account_info destination_info;
|
||||
ASSERT_FALSE (ledger.store.account_get (transaction, destination.pub, destination_info));
|
||||
ASSERT_FALSE (ledger.store.account.get (transaction, destination.pub, destination_info));
|
||||
ASSERT_EQ (destination_info.epoch (), nano::epoch::epoch_1);
|
||||
ASSERT_FALSE (ledger.rollback (transaction, receive2.hash ()));
|
||||
ASSERT_FALSE (ledger.store.account_get (transaction, destination.pub, destination_info));
|
||||
ASSERT_FALSE (ledger.store.account.get (transaction, destination.pub, destination_info));
|
||||
ASSERT_EQ (destination_info.epoch (), nano::epoch::epoch_0);
|
||||
nano::pending_info pending_send2;
|
||||
ASSERT_FALSE (ledger.store.pending.get (transaction, nano::pending_key (destination.pub, send2.hash ()), pending_send2));
|
||||
|
@ -2553,7 +2553,7 @@ TEST (ledger, epoch_blocks_receive_upgrade)
|
|||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, receive2).code);
|
||||
ASSERT_EQ (nano::epoch::epoch_1, receive2.sideband ().details.epoch);
|
||||
ASSERT_EQ (nano::epoch::epoch_1, receive2.sideband ().source_epoch);
|
||||
ASSERT_FALSE (ledger.store.account_get (transaction, destination.pub, destination_info));
|
||||
ASSERT_FALSE (ledger.store.account.get (transaction, destination.pub, destination_info));
|
||||
ASSERT_EQ (destination_info.epoch (), nano::epoch::epoch_1);
|
||||
nano::keypair destination2;
|
||||
nano::state_block send3 (destination.pub, receive2.hash (), destination.pub, nano::Gxrb_ratio, destination2.pub, destination.prv, destination.pub, *pool.generate (receive2.hash ()));
|
||||
|
@ -2571,13 +2571,13 @@ TEST (ledger, epoch_blocks_receive_upgrade)
|
|||
// Send it to an epoch 1 account
|
||||
nano::state_block send5 (nano::genesis_account, send4.hash (), nano::genesis_account, nano::genesis_amount - nano::Gxrb_ratio * 4, destination.pub, nano::dev_genesis_key.prv, nano::dev_genesis_key.pub, *pool.generate (send4.hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send5).code);
|
||||
ASSERT_FALSE (ledger.store.account_get (transaction, destination.pub, destination_info));
|
||||
ASSERT_FALSE (ledger.store.account.get (transaction, destination.pub, destination_info));
|
||||
ASSERT_EQ (destination_info.epoch (), nano::epoch::epoch_1);
|
||||
nano::state_block receive3 (destination.pub, send3.hash (), destination.pub, nano::Gxrb_ratio * 2, send5.hash (), destination.prv, destination.pub, *pool.generate (send3.hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, receive3).code);
|
||||
ASSERT_EQ (nano::epoch::epoch_2, receive3.sideband ().details.epoch);
|
||||
ASSERT_EQ (nano::epoch::epoch_2, receive3.sideband ().source_epoch);
|
||||
ASSERT_FALSE (ledger.store.account_get (transaction, destination.pub, destination_info));
|
||||
ASSERT_FALSE (ledger.store.account.get (transaction, destination.pub, destination_info));
|
||||
ASSERT_EQ (destination_info.epoch (), nano::epoch::epoch_2);
|
||||
// Upgrade an unopened account straight to epoch 2
|
||||
nano::keypair destination4;
|
||||
|
@ -2587,7 +2587,7 @@ TEST (ledger, epoch_blocks_receive_upgrade)
|
|||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, epoch4).code);
|
||||
ASSERT_EQ (nano::epoch::epoch_2, epoch4.sideband ().details.epoch);
|
||||
ASSERT_EQ (nano::epoch::epoch_0, epoch4.sideband ().source_epoch); // Not used for epoch blocks
|
||||
ASSERT_EQ (store->account_count (transaction), ledger.cache.account_count);
|
||||
ASSERT_EQ (store->account.count (transaction), ledger.cache.account_count);
|
||||
}
|
||||
|
||||
TEST (ledger, epoch_blocks_fork)
|
||||
|
@ -2869,7 +2869,7 @@ TEST (ledger, unchecked_epoch)
|
|||
ASSERT_EQ (unchecked_count, 0);
|
||||
ASSERT_EQ (unchecked_count, node1.store.unchecked_count (transaction));
|
||||
nano::account_info info;
|
||||
ASSERT_FALSE (node1.store.account_get (transaction, destination.pub, info));
|
||||
ASSERT_FALSE (node1.store.account.get (transaction, destination.pub, info));
|
||||
ASSERT_EQ (info.epoch (), nano::epoch::epoch_1);
|
||||
}
|
||||
}
|
||||
|
@ -2917,7 +2917,7 @@ TEST (ledger, unchecked_epoch_invalid)
|
|||
ASSERT_EQ (unchecked_count, 0);
|
||||
ASSERT_EQ (unchecked_count, node1.store.unchecked_count (transaction));
|
||||
nano::account_info info;
|
||||
ASSERT_FALSE (node1.store.account_get (transaction, destination.pub, info));
|
||||
ASSERT_FALSE (node1.store.account.get (transaction, destination.pub, info));
|
||||
ASSERT_NE (info.epoch (), nano::epoch::epoch_1);
|
||||
auto epoch2_store (node1.store.block_get (transaction, epoch2->hash ()));
|
||||
ASSERT_NE (nullptr, epoch2_store);
|
||||
|
@ -3027,7 +3027,7 @@ TEST (ledger, confirmation_height_not_updated)
|
|||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::account_info account_info;
|
||||
ASSERT_FALSE (store->account_get (transaction, nano::dev_genesis_key.pub, account_info));
|
||||
ASSERT_FALSE (store->account.get (transaction, nano::dev_genesis_key.pub, account_info));
|
||||
nano::keypair key;
|
||||
nano::send_block send1 (account_info.head, key.pub, 50, nano::dev_genesis_key.prv, nano::dev_genesis_key.pub, *pool.generate (account_info.head));
|
||||
nano::confirmation_height_info confirmation_height_info;
|
||||
|
@ -3494,7 +3494,7 @@ TEST (ledger, pruning_action)
|
|||
ASSERT_EQ (1, ledger.pruning_action (transaction, send2.hash (), 1));
|
||||
ASSERT_TRUE (store->pruned_exists (transaction, send2.hash ()));
|
||||
ASSERT_FALSE (store->block_exists (transaction, send2.hash ()));
|
||||
ASSERT_EQ (store->account_count (transaction), ledger.cache.account_count);
|
||||
ASSERT_EQ (store->account.count (transaction), ledger.cache.account_count);
|
||||
ASSERT_EQ (store->pruned_count (transaction), ledger.cache.pruned_count);
|
||||
ASSERT_EQ (store->block_count (transaction), ledger.cache.block_count - ledger.cache.pruned_count);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ TEST (processor_service, bad_send_signature)
|
|||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::account_info info1;
|
||||
ASSERT_FALSE (store->account_get (transaction, nano::dev_genesis_key.pub, info1));
|
||||
ASSERT_FALSE (store->account.get (transaction, nano::dev_genesis_key.pub, info1));
|
||||
nano::keypair key2;
|
||||
nano::send_block send (info1.head, nano::dev_genesis_key.pub, 50, nano::dev_genesis_key.prv, nano::dev_genesis_key.pub, *pool.generate (info1.head));
|
||||
send.signature.bytes[32] ^= 0x1;
|
||||
|
@ -38,12 +38,12 @@ TEST (processor_service, bad_receive_signature)
|
|||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::account_info info1;
|
||||
ASSERT_FALSE (store->account_get (transaction, nano::dev_genesis_key.pub, info1));
|
||||
ASSERT_FALSE (store->account.get (transaction, nano::dev_genesis_key.pub, info1));
|
||||
nano::send_block send (info1.head, nano::dev_genesis_key.pub, 50, nano::dev_genesis_key.prv, nano::dev_genesis_key.pub, *pool.generate (info1.head));
|
||||
nano::block_hash hash1 (send.hash ());
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send).code);
|
||||
nano::account_info info2;
|
||||
ASSERT_FALSE (store->account_get (transaction, nano::dev_genesis_key.pub, info2));
|
||||
ASSERT_FALSE (store->account.get (transaction, nano::dev_genesis_key.pub, info2));
|
||||
nano::receive_block receive (hash1, hash1, nano::dev_genesis_key.prv, nano::dev_genesis_key.pub, *pool.generate (hash1));
|
||||
receive.signature.bytes[32] ^= 0x1;
|
||||
ASSERT_EQ (nano::process_result::bad_signature, ledger.process (transaction, receive).code);
|
||||
|
|
|
@ -183,7 +183,7 @@ TEST (wallet, spend_all_one)
|
|||
nano::account_info info2;
|
||||
{
|
||||
auto transaction (node1.store.tx_begin_read ());
|
||||
node1.store.account_get (transaction, nano::dev_genesis_key.pub, info2);
|
||||
node1.store.account.get (transaction, nano::dev_genesis_key.pub, info2);
|
||||
ASSERT_NE (latest1, info2.head);
|
||||
auto block (node1.store.block_get (transaction, info2.head));
|
||||
ASSERT_NE (nullptr, block);
|
||||
|
@ -220,7 +220,7 @@ TEST (wallet, spend)
|
|||
nano::account_info info2;
|
||||
{
|
||||
auto transaction (node1.store.tx_begin_read ());
|
||||
node1.store.account_get (transaction, nano::dev_genesis_key.pub, info2);
|
||||
node1.store.account.get (transaction, nano::dev_genesis_key.pub, info2);
|
||||
ASSERT_NE (latest1, info2.head);
|
||||
auto block (node1.store.block_get (transaction, info2.head));
|
||||
ASSERT_NE (nullptr, block);
|
||||
|
@ -259,7 +259,7 @@ TEST (wallet, spend_no_previous)
|
|||
system.wallet (0)->insert_adhoc (nano::dev_genesis_key.prv);
|
||||
auto transaction (system.nodes[0]->store.tx_begin_read ());
|
||||
nano::account_info info1;
|
||||
ASSERT_FALSE (system.nodes[0]->store.account_get (transaction, nano::dev_genesis_key.pub, info1));
|
||||
ASSERT_FALSE (system.nodes[0]->store.account.get (transaction, nano::dev_genesis_key.pub, info1));
|
||||
for (auto i (0); i < 50; ++i)
|
||||
{
|
||||
nano::keypair key;
|
||||
|
|
|
@ -415,7 +415,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.accounts_begin (transaction)), n (node->store.accounts_end ()); i != n; ++i)
|
||||
for (auto i (node->store.account.begin (transaction)), n (node->store.account.end ()); i != n; ++i)
|
||||
{
|
||||
frontier_hashes.insert (i->second.head);
|
||||
}
|
||||
|
@ -1631,7 +1631,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.accounts_begin (transaction)), n (node->store.accounts_end ()); i != n; ++i)
|
||||
for (auto i (node->store.account.begin (transaction)), n (node->store.account.end ()); i != n; ++i)
|
||||
{
|
||||
{
|
||||
nano::unique_lock<nano::mutex> lock (mutex);
|
||||
|
@ -1800,7 +1800,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.accounts_begin (transaction)), n (source_node->store.accounts_end ()); i != n; ++i)
|
||||
for (auto i (source_node->store.account.begin (transaction)), n (source_node->store.account.end ()); i != n; ++i)
|
||||
{
|
||||
nano::account const & account (i->first);
|
||||
nano::account_info const & info (i->second);
|
||||
|
@ -1911,7 +1911,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.accounts_for_each_par (
|
||||
node->store.account.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);
|
||||
|
|
|
@ -132,7 +132,7 @@ void nano::active_transactions::confirm_prioritized_frontiers (nano::transaction
|
|||
{
|
||||
lk.unlock ();
|
||||
nano::account_info info;
|
||||
auto error = this->node.store.account_get (transaction_a, cementable_account.account, info);
|
||||
auto error = this->node.store.account.get (transaction_a, cementable_account.account, info);
|
||||
if (!error)
|
||||
{
|
||||
if (!this->confirmation_height_processor.is_processing_block (info.head))
|
||||
|
@ -473,8 +473,8 @@ void nano::active_transactions::frontiers_confirmation (nano::unique_lock<nano::
|
|||
*/
|
||||
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.accounts_begin (transaction_a, next_frontier_account) };
|
||||
auto n{ node.store.accounts_end () };
|
||||
auto i{ node.store.account.begin (transaction_a, next_frontier_account) };
|
||||
auto n{ node.store.account.end () };
|
||||
nano::timer<std::chrono::milliseconds> timer (nano::timer_state::started);
|
||||
nano::confirmation_height_info confirmation_height_info;
|
||||
|
||||
|
@ -490,7 +490,7 @@ void nano::active_transactions::confirm_expired_frontiers_pessimistically (nano:
|
|||
auto const & account{ i->account };
|
||||
nano::account_info account_info;
|
||||
bool should_delete{ true };
|
||||
if (!node.store.account_get (transaction_a, account, account_info))
|
||||
if (!node.store.account.get (transaction_a, account, account_info))
|
||||
{
|
||||
node.store.confirmation_height_get (transaction_a, account, confirmation_height_info);
|
||||
if (account_info.block_count > confirmation_height_info.height)
|
||||
|
@ -692,7 +692,7 @@ void nano::active_transactions::prioritize_frontiers_for_confirmation (nano::tra
|
|||
for (; i != n && should_iterate (); ++i)
|
||||
{
|
||||
auto const & account (i->first);
|
||||
if (expired_optimistic_election_infos.get<tag_account> ().count (account) == 0 && !node.store.account_get (transaction_a, account, info))
|
||||
if (expired_optimistic_election_infos.get<tag_account> ().count (account) == 0 && !node.store.account.get (transaction_a, account, info))
|
||||
{
|
||||
nano::confirmation_height_info confirmation_height_info;
|
||||
node.store.confirmation_height_get (transaction_a, account, confirmation_height_info);
|
||||
|
@ -736,8 +736,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.accounts_begin (transaction_a, next_frontier_account));
|
||||
auto n (node.store.accounts_end ());
|
||||
auto i (node.store.account.begin (transaction_a, next_frontier_account));
|
||||
auto n (node.store.account.end ());
|
||||
for (; i != n && should_iterate (); ++i)
|
||||
{
|
||||
auto const & account (i->first);
|
||||
|
|
|
@ -441,7 +441,7 @@ void nano::bulk_pull_server::set_current_end ()
|
|||
else
|
||||
{
|
||||
nano::account_info info;
|
||||
auto no_address (connection->node->store.account_get (transaction, request->start.as_account (), info));
|
||||
auto no_address (connection->node->store.account.get (transaction, request->start.as_account (), info));
|
||||
if (no_address)
|
||||
{
|
||||
if (connection->node->config.logging.bulk_pull_logging ())
|
||||
|
|
|
@ -218,7 +218,7 @@ 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.accounts_begin (transaction, current.number () + 1)), n (connection->node->store.accounts_end ()); i != n && accounts.size () != max_size; ++i)
|
||||
for (auto i (connection->node->store.account.begin (transaction, current.number () + 1)), n (connection->node->store.account.end ()); i != n && accounts.size () != max_size; ++i)
|
||||
{
|
||||
nano::account_info const & info (i->second);
|
||||
nano::account const & account (i->first);
|
||||
|
@ -337,7 +337,7 @@ void nano::frontier_req_server::next ()
|
|||
auto transaction (connection->node->store.tx_begin_read ());
|
||||
if (!send_confirmed ())
|
||||
{
|
||||
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)
|
||||
for (auto i (connection->node->store.account.begin (transaction, current.number () + 1)), n (connection->node->store.account.end ()); i != n && accounts.size () != max_size; ++i)
|
||||
{
|
||||
nano::account_info const & info (i->second);
|
||||
if (disable_age_filter || (now - info.modified) <= request->age)
|
||||
|
|
|
@ -239,7 +239,7 @@ nano::block_hash nano::confirmation_height_bounded::get_least_unconfirmed_hash_f
|
|||
{
|
||||
// No blocks have been confirmed, so the first block will be the open block
|
||||
nano::account_info account_info;
|
||||
release_assert (!ledger.store.account_get (transaction_a, account_a, account_info));
|
||||
release_assert (!ledger.store.account.get (transaction_a, account_a, account_info));
|
||||
least_unconfirmed_hash = account_info.open_block;
|
||||
block_height_a = 1;
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ void nano::election_scheduler::activate (nano::account const & account_a, nano::
|
|||
{
|
||||
debug_assert (!account_a.is_zero ());
|
||||
nano::account_info account_info;
|
||||
if (!node.store.account_get (transaction, account_a, account_info))
|
||||
if (!node.store.account.get (transaction, account_a, account_info))
|
||||
{
|
||||
nano::confirmation_height_info conf_info;
|
||||
node.store.confirmation_height_get (transaction, account_a, conf_info);
|
||||
|
|
|
@ -251,7 +251,7 @@ nano::account_info nano::json_handler::account_info_impl (nano::transaction cons
|
|||
nano::account_info result;
|
||||
if (!ec)
|
||||
{
|
||||
if (node.store.account_get (transaction_a, account_a, result))
|
||||
if (node.store.account.get (transaction_a, account_a, result))
|
||||
{
|
||||
ec = nano::error_common::account_not_found;
|
||||
node.bootstrap_initiator.bootstrap_lazy (account_a, false, false, account_a.to_account ());
|
||||
|
@ -2073,7 +2073,7 @@ void nano::json_handler::delegators ()
|
|||
{
|
||||
boost::property_tree::ptree delegators;
|
||||
auto transaction (node.store.tx_begin_read ());
|
||||
for (auto i (node.store.accounts_begin (transaction)), n (node.store.accounts_end ()); i != n; ++i)
|
||||
for (auto i (node.store.account.begin (transaction)), n (node.store.account.end ()); i != n; ++i)
|
||||
{
|
||||
nano::account_info const & info (i->second);
|
||||
if (info.representative == account)
|
||||
|
@ -2096,7 +2096,7 @@ void nano::json_handler::delegators_count ()
|
|||
{
|
||||
uint64_t count (0);
|
||||
auto transaction (node.store.tx_begin_read ());
|
||||
for (auto i (node.store.accounts_begin (transaction)), n (node.store.accounts_end ()); i != n; ++i)
|
||||
for (auto i (node.store.account.begin (transaction)), n (node.store.account.end ()); i != n; ++i)
|
||||
{
|
||||
nano::account_info const & info (i->second);
|
||||
if (info.representative == account)
|
||||
|
@ -2207,7 +2207,7 @@ void nano::json_handler::frontiers ()
|
|||
{
|
||||
boost::property_tree::ptree frontiers;
|
||||
auto transaction (node.store.tx_begin_read ());
|
||||
for (auto i (node.store.accounts_begin (transaction, start)), n (node.store.accounts_end ()); i != n && frontiers.size () < count; ++i)
|
||||
for (auto i (node.store.account.begin (transaction, start)), n (node.store.account.end ()); i != n && frontiers.size () < count; ++i)
|
||||
{
|
||||
frontiers.put (i->first.to_account (), i->second.head.to_string ());
|
||||
}
|
||||
|
@ -2610,7 +2610,7 @@ void nano::json_handler::ledger ()
|
|||
auto transaction (node.store.tx_begin_read ());
|
||||
if (!ec && !sorting) // Simple
|
||||
{
|
||||
for (auto i (node.store.accounts_begin (transaction, start)), n (node.store.accounts_end ()); i != n && accounts.size () < count; ++i)
|
||||
for (auto i (node.store.account.begin (transaction, start)), n (node.store.account.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 ()))
|
||||
|
@ -2650,7 +2650,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.accounts_begin (transaction, start)), n (node.store.accounts_end ()); i != n; ++i)
|
||||
for (auto i (node.store.account.begin (transaction, start)), n (node.store.account.end ()); i != n; ++i)
|
||||
{
|
||||
nano::account_info const & info (i->second);
|
||||
nano::uint128_union balance (info.balance);
|
||||
|
@ -2664,7 +2664,7 @@ void nano::json_handler::ledger ()
|
|||
nano::account_info info;
|
||||
for (auto i (ledger_l.begin ()), n (ledger_l.end ()); i != n && accounts.size () < count; ++i)
|
||||
{
|
||||
node.store.account_get (transaction, i->second, info);
|
||||
node.store.account.get (transaction, i->second, info);
|
||||
if (pending || info.balance.number () >= threshold.number ())
|
||||
{
|
||||
nano::account const & account (i->second);
|
||||
|
@ -3208,7 +3208,7 @@ void nano::json_handler::receive ()
|
|||
nano::account_info info;
|
||||
nano::root head;
|
||||
nano::epoch epoch = pending_info.epoch;
|
||||
if (!node.store.account_get (block_transaction, account, info))
|
||||
if (!node.store.account.get (block_transaction, account, info))
|
||||
{
|
||||
head = info.head;
|
||||
// When receiving, epoch version is the higher between the previous and the source blocks
|
||||
|
@ -4071,7 +4071,7 @@ void nano::json_handler::unopened ()
|
|||
nano::pending_key key (iterator->first);
|
||||
nano::account account (key.account);
|
||||
nano::pending_info info (iterator->second);
|
||||
if (node.store.account_exists (transaction, account))
|
||||
if (node.store.account.exists (transaction, account))
|
||||
{
|
||||
if (account.number () == std::numeric_limits<nano::uint256_t>::max ())
|
||||
{
|
||||
|
@ -4220,7 +4220,7 @@ void nano::json_handler::wallet_info ()
|
|||
nano::account const & account (i->first);
|
||||
|
||||
nano::account_info account_info{};
|
||||
if (!node.store.account_get (block_transaction, account, account_info))
|
||||
if (!node.store.account.get (block_transaction, account, account_info))
|
||||
{
|
||||
block_count += account_info.block_count;
|
||||
}
|
||||
|
@ -4455,7 +4455,7 @@ void nano::json_handler::wallet_history ()
|
|||
{
|
||||
nano::account const & account (i->first);
|
||||
nano::account_info info;
|
||||
if (!node.store.account_get (block_transaction, account, info))
|
||||
if (!node.store.account.get (block_transaction, account, info))
|
||||
{
|
||||
auto timestamp (info.modified);
|
||||
auto hash (info.head);
|
||||
|
@ -4528,7 +4528,7 @@ void nano::json_handler::wallet_ledger ()
|
|||
{
|
||||
nano::account const & account (i->first);
|
||||
nano::account_info info;
|
||||
if (!node.store.account_get (block_transaction, account, info))
|
||||
if (!node.store.account.get (block_transaction, account, info))
|
||||
{
|
||||
if (info.modified >= modified_since)
|
||||
{
|
||||
|
@ -4687,7 +4687,7 @@ void nano::json_handler::wallet_representative_set ()
|
|||
{
|
||||
nano::account const & account (i->first);
|
||||
nano::account_info info;
|
||||
if (!rpc_l->node.store.account_get (block_transaction, account, info))
|
||||
if (!rpc_l->node.store.account.get (block_transaction, account, info))
|
||||
{
|
||||
if (info.representative != representative)
|
||||
{
|
||||
|
|
|
@ -428,8 +428,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 = accounts_begin (transaction_a);
|
||||
auto account_info_n = accounts_end ();
|
||||
auto account_info_i = account.begin (transaction_a);
|
||||
auto account_info_n = account.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;
|
||||
|
|
|
@ -341,7 +341,7 @@ nano::node::node (boost::asio::io_context & io_ctx_a, boost::filesystem::path co
|
|||
auto is_initialized (false);
|
||||
{
|
||||
auto transaction (store.tx_begin_read ());
|
||||
is_initialized = (store.accounts_begin (transaction) != store.accounts_end ());
|
||||
is_initialized = (store.account.begin (transaction) != store.account.end ());
|
||||
}
|
||||
|
||||
nano::genesis genesis;
|
||||
|
@ -733,7 +733,7 @@ nano::block_hash nano::node::rep_block (nano::account const & account_a)
|
|||
auto transaction (store.tx_begin_read ());
|
||||
nano::account_info info;
|
||||
nano::block_hash result (0);
|
||||
if (!store.account_get (transaction, account_a, info))
|
||||
if (!store.account.get (transaction, account_a, info))
|
||||
{
|
||||
result = ledger.representative (transaction, info.head);
|
||||
}
|
||||
|
@ -1515,7 +1515,7 @@ void nano::node::epoch_upgrader_impl (nano::raw_key const & prv_a, nano::epoch e
|
|||
{
|
||||
auto transaction (store.tx_begin_read ());
|
||||
// Collect accounts to upgrade
|
||||
for (auto i (store.accounts_begin (transaction)), n (store.accounts_end ()); i != n && accounts_list.size () < count_limit; ++i)
|
||||
for (auto i (store.account.begin (transaction)), n (store.account.end ()); i != n && accounts_list.size () < count_limit; ++i)
|
||||
{
|
||||
nano::account const & account (i->first);
|
||||
nano::account_info const & info (i->second);
|
||||
|
@ -1537,7 +1537,7 @@ void nano::node::epoch_upgrader_impl (nano::raw_key const & prv_a, nano::epoch e
|
|||
auto transaction (store.tx_begin_read ());
|
||||
nano::account_info info;
|
||||
nano::account const & account (i->account);
|
||||
if (!store.account_get (transaction, account, info) && info.epoch () < epoch_a)
|
||||
if (!store.account.get (transaction, account, info) && info.epoch () < epoch_a)
|
||||
{
|
||||
++attempts;
|
||||
auto difficulty (nano::work_threshold (nano::work_version::work_1, nano::block_details (epoch_a, false, false, true)));
|
||||
|
@ -1611,7 +1611,7 @@ void nano::node::epoch_upgrader_impl (nano::raw_key const & prv_a, nano::epoch e
|
|||
{
|
||||
bool to_next_account (false);
|
||||
nano::pending_key const & key (i->first);
|
||||
if (!store.account_exists (transaction, key.account))
|
||||
if (!store.account.exists (transaction, key.account))
|
||||
{
|
||||
nano::pending_info const & info (i->second);
|
||||
if (info.epoch < epoch_a)
|
||||
|
@ -1745,13 +1745,13 @@ void nano::node::populate_backlog ()
|
|||
{
|
||||
auto transaction = store.tx_begin_read ();
|
||||
auto count = 0;
|
||||
for (auto i = store.accounts_begin (transaction, next), n = store.accounts_end (); !stopped && i != n && count < chunk_size; ++i, ++count, ++total)
|
||||
for (auto i = store.account.begin (transaction, next), n = store.account.end (); !stopped && i != n && count < chunk_size; ++i, ++count, ++total)
|
||||
{
|
||||
auto const & account = i->first;
|
||||
scheduler.activate (account, transaction);
|
||||
next = account.number () + 1;
|
||||
}
|
||||
done = store.accounts_begin (transaction, next) == store.accounts_end ();
|
||||
done = store.account.begin (transaction, next) == store.account.end ();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -231,7 +231,7 @@ std::pair<std::vector<std::shared_ptr<nano::block>>, std::vector<std::shared_ptr
|
|||
if (successor.is_zero ())
|
||||
{
|
||||
nano::account_info info;
|
||||
auto error (ledger.store.account_get (transaction, root.as_account (), info));
|
||||
auto error (ledger.store.account.get (transaction, root.as_account (), info));
|
||||
if (!error)
|
||||
{
|
||||
successor = info.open_block;
|
||||
|
|
|
@ -515,7 +515,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 (accounts_begin (transaction_a)), n (accounts_end ()); i != n; ++i)
|
||||
for (auto i (account.begin (transaction_a)), n (account.end ()); i != n; ++i)
|
||||
{
|
||||
++sum;
|
||||
}
|
||||
|
|
|
@ -325,7 +325,7 @@ void nano::system::generate_rollback (nano::node & node_a, std::vector<nano::acc
|
|||
auto index (random_pool::generate_word32 (0, static_cast<CryptoPP::word32> (accounts_a.size () - 1)));
|
||||
auto account (accounts_a[index]);
|
||||
nano::account_info info;
|
||||
auto error (node_a.store.account_get (transaction, account, info));
|
||||
auto error (node_a.store.account.get (transaction, account, info));
|
||||
if (!error)
|
||||
{
|
||||
auto hash (info.open_block);
|
||||
|
@ -421,12 +421,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.accounts_begin (transaction, account));
|
||||
if (entry == node_a.store.accounts_end ())
|
||||
nano::store_iterator<nano::account, nano::account_info> entry (node_a.store.account.begin (transaction, account));
|
||||
if (entry == node_a.store.account.end ())
|
||||
{
|
||||
entry = node_a.store.accounts_begin (transaction);
|
||||
entry = node_a.store.account.begin (transaction);
|
||||
}
|
||||
debug_assert (entry != node_a.store.accounts_end ());
|
||||
debug_assert (entry != node_a.store.account.end ());
|
||||
destination = nano::account (entry->first);
|
||||
source = get_random_account (accounts_a);
|
||||
amount = get_random_amount (transaction, node_a, source);
|
||||
|
|
|
@ -851,7 +851,7 @@ std::shared_ptr<nano::block> nano::wallet::receive_action (nano::block_hash cons
|
|||
store.work_get (transaction, account_a, work_a);
|
||||
}
|
||||
nano::account_info info;
|
||||
auto new_account (wallets.node.ledger.store.account_get (block_transaction, account_a, info));
|
||||
auto new_account (wallets.node.ledger.store.account.get (block_transaction, account_a, info));
|
||||
if (!new_account)
|
||||
{
|
||||
block = std::make_shared<nano::state_block> (account_a, info.head, info.representative, info.balance.number () + pending_info.amount.number (), send_hash_a, prv, account_a, work_a);
|
||||
|
@ -907,7 +907,7 @@ std::shared_ptr<nano::block> nano::wallet::change_action (nano::account const &
|
|||
if (existing != store.end () && !wallets.node.ledger.latest (block_transaction, source_a).is_zero ())
|
||||
{
|
||||
nano::account_info info;
|
||||
auto error1 (wallets.node.ledger.store.account_get (block_transaction, source_a, info));
|
||||
auto error1 (wallets.node.ledger.store.account.get (block_transaction, source_a, info));
|
||||
(void)error1;
|
||||
debug_assert (!error1);
|
||||
nano::raw_key prv;
|
||||
|
@ -979,7 +979,7 @@ std::shared_ptr<nano::block> nano::wallet::send_action (nano::account const & so
|
|||
if (!balance.is_zero () && balance >= amount_a)
|
||||
{
|
||||
nano::account_info info;
|
||||
auto error1 (wallets.node.ledger.store.account_get (block_transaction, source_a, info));
|
||||
auto error1 (wallets.node.ledger.store.account.get (block_transaction, source_a, info));
|
||||
(void)error1;
|
||||
debug_assert (!error1);
|
||||
nano::raw_key prv;
|
||||
|
|
|
@ -1697,7 +1697,7 @@ void nano_qt::settings::refresh_representative ()
|
|||
{
|
||||
auto transaction (this->wallet.wallet_m->wallets.node.store.tx_begin_read ());
|
||||
nano::account_info info;
|
||||
auto error (wallet.node.store.account_get (transaction, this->wallet.account, info));
|
||||
auto error (wallet.node.store.account.get (transaction, this->wallet.account, info));
|
||||
if (!error)
|
||||
{
|
||||
current_representative->setText (QString (info.representative.to_account ().c_str ()));
|
||||
|
@ -1982,7 +1982,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.accounts_begin (transaction)), j (wallet.node.ledger.store.accounts_end ()); i != j; ++i)
|
||||
for (auto i (wallet.node.ledger.store.account.begin (transaction)), j (wallet.node.ledger.store.account.end ()); i != j; ++i)
|
||||
{
|
||||
QList<QStandardItem *> items;
|
||||
items.push_back (new QStandardItem (QString (i->first.to_account ().c_str ())));
|
||||
|
@ -2259,7 +2259,7 @@ void nano_qt::block_creation::create_send ()
|
|||
if (amount_l.number () <= balance)
|
||||
{
|
||||
nano::account_info info;
|
||||
auto error (wallet.node.store.account_get (block_transaction, account_l, info));
|
||||
auto error (wallet.node.store.account.get (block_transaction, account_l, info));
|
||||
(void)error;
|
||||
debug_assert (!error);
|
||||
nano::state_block send (account_l, info.head, info.representative, balance - amount_l.number (), destination_l, key, account_l, 0);
|
||||
|
@ -2339,7 +2339,7 @@ void nano_qt::block_creation::create_receive ()
|
|||
if (!wallet.node.store.pending.get (block_transaction, pending_key, pending))
|
||||
{
|
||||
nano::account_info info;
|
||||
auto error (wallet.node.store.account_get (block_transaction, pending_key.account, info));
|
||||
auto error (wallet.node.store.account.get (block_transaction, pending_key.account, info));
|
||||
if (!error)
|
||||
{
|
||||
nano::raw_key key;
|
||||
|
@ -2423,7 +2423,7 @@ void nano_qt::block_creation::create_change ()
|
|||
auto transaction (wallet.node.wallets.tx_begin_read ());
|
||||
auto block_transaction (wallet.node.store.tx_begin_read ());
|
||||
nano::account_info info;
|
||||
auto error (wallet.node.store.account_get (block_transaction, account_l, info));
|
||||
auto error (wallet.node.store.account.get (block_transaction, account_l, info));
|
||||
if (!error)
|
||||
{
|
||||
nano::raw_key key;
|
||||
|
@ -2504,7 +2504,7 @@ void nano_qt::block_creation::create_open ()
|
|||
if (!wallet.node.store.pending.get (block_transaction, pending_key, pending))
|
||||
{
|
||||
nano::account_info info;
|
||||
auto error (wallet.node.store.account_get (block_transaction, pending_key.account, info));
|
||||
auto error (wallet.node.store.account.get (block_transaction, pending_key.account, info));
|
||||
if (error)
|
||||
{
|
||||
nano::raw_key key;
|
||||
|
|
|
@ -881,7 +881,7 @@ TEST (rpc, wallet_representative_set_force)
|
|||
{
|
||||
auto transaction (node->store.tx_begin_read ());
|
||||
nano::account_info info;
|
||||
if (!node->store.account_get (transaction, nano::dev_genesis_key.pub, info))
|
||||
if (!node->store.account.get (transaction, nano::dev_genesis_key.pub, info))
|
||||
{
|
||||
representative = info.representative;
|
||||
}
|
||||
|
@ -1275,7 +1275,7 @@ TEST (rpc, frontier)
|
|||
nano::random_pool::generate_block (hash.bytes.data (), hash.bytes.size ());
|
||||
source[key.pub] = hash;
|
||||
node->store.confirmation_height_put (transaction, key.pub, { 0, nano::block_hash (0) });
|
||||
node->store.account_put (transaction, key.pub, nano::account_info (hash, 0, 0, 0, 0, 0, nano::epoch::epoch_0));
|
||||
node->store.account.put (transaction, key.pub, nano::account_info (hash, 0, 0, 0, 0, 0, nano::epoch::epoch_0));
|
||||
}
|
||||
}
|
||||
scoped_io_thread_name_change scoped_thread_name_io;
|
||||
|
@ -1322,7 +1322,7 @@ TEST (rpc, frontier_limited)
|
|||
nano::random_pool::generate_block (hash.bytes.data (), hash.bytes.size ());
|
||||
source[key.pub] = hash;
|
||||
node->store.confirmation_height_put (transaction, key.pub, { 0, nano::block_hash (0) });
|
||||
node->store.account_put (transaction, key.pub, nano::account_info (hash, 0, 0, 0, 0, 0, nano::epoch::epoch_0));
|
||||
node->store.account.put (transaction, key.pub, nano::account_info (hash, 0, 0, 0, 0, 0, nano::epoch::epoch_0));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1360,7 +1360,7 @@ TEST (rpc, frontier_startpoint)
|
|||
nano::random_pool::generate_block (hash.bytes.data (), hash.bytes.size ());
|
||||
source[key.pub] = hash;
|
||||
node->store.confirmation_height_put (transaction, key.pub, { 0, nano::block_hash (0) });
|
||||
node->store.account_put (transaction, key.pub, nano::account_info (hash, 0, 0, 0, 0, 0, nano::epoch::epoch_0));
|
||||
node->store.account.put (transaction, key.pub, nano::account_info (hash, 0, 0, 0, 0, 0, nano::epoch::epoch_0));
|
||||
}
|
||||
}
|
||||
scoped_io_thread_name_change scoped_thread_name_io;
|
||||
|
@ -7177,8 +7177,8 @@ TEST (rpc, epoch_upgrade)
|
|||
// Check accounts epochs
|
||||
{
|
||||
auto transaction (node->store.tx_begin_read ());
|
||||
ASSERT_EQ (2, node->store.account_count (transaction));
|
||||
for (auto i (node->store.accounts_begin (transaction)); i != node->store.accounts_end (); ++i)
|
||||
ASSERT_EQ (2, node->store.account.count (transaction));
|
||||
for (auto i (node->store.account.begin (transaction)); i != node->store.account.end (); ++i)
|
||||
{
|
||||
nano::account_info info (i->second);
|
||||
ASSERT_EQ (info.epoch (), nano::epoch::epoch_0);
|
||||
|
@ -7203,20 +7203,20 @@ TEST (rpc, epoch_upgrade)
|
|||
ASSERT_TIMELY (5s, response_fail.status != 0);
|
||||
ASSERT_EQ (200, response_fail.status);
|
||||
ASSERT_EQ ("0", response_fail.json.get<std::string> ("started"));
|
||||
ASSERT_TIMELY (10s, 4 == node->store.account_count (node->store.tx_begin_read ()));
|
||||
ASSERT_TIMELY (10s, 4 == node->store.account.count (node->store.tx_begin_read ()));
|
||||
// Check upgrade
|
||||
{
|
||||
auto transaction (node->store.tx_begin_read ());
|
||||
ASSERT_EQ (4, node->store.account_count (transaction));
|
||||
for (auto i (node->store.accounts_begin (transaction)); i != node->store.accounts_end (); ++i)
|
||||
ASSERT_EQ (4, node->store.account.count (transaction));
|
||||
for (auto i (node->store.account.begin (transaction)); i != node->store.account.end (); ++i)
|
||||
{
|
||||
nano::account_info info (i->second);
|
||||
ASSERT_EQ (info.epoch (), nano::epoch::epoch_1);
|
||||
}
|
||||
ASSERT_TRUE (node->store.account_exists (transaction, key1.pub));
|
||||
ASSERT_TRUE (node->store.account_exists (transaction, key2.pub));
|
||||
ASSERT_TRUE (node->store.account_exists (transaction, std::numeric_limits<nano::uint256_t>::max ()));
|
||||
ASSERT_FALSE (node->store.account_exists (transaction, 0));
|
||||
ASSERT_TRUE (node->store.account.exists (transaction, key1.pub));
|
||||
ASSERT_TRUE (node->store.account.exists (transaction, key2.pub));
|
||||
ASSERT_TRUE (node->store.account.exists (transaction, std::numeric_limits<nano::uint256_t>::max ()));
|
||||
ASSERT_FALSE (node->store.account.exists (transaction, 0));
|
||||
}
|
||||
|
||||
// Epoch 2 upgrade
|
||||
|
@ -7241,21 +7241,21 @@ TEST (rpc, epoch_upgrade)
|
|||
ASSERT_TIMELY (5s, response2.status != 0);
|
||||
ASSERT_EQ (200, response2.status);
|
||||
ASSERT_EQ ("1", response2.json.get<std::string> ("started"));
|
||||
ASSERT_TIMELY (10s, 5 == node->store.account_count (node->store.tx_begin_read ()));
|
||||
ASSERT_TIMELY (10s, 5 == node->store.account.count (node->store.tx_begin_read ()));
|
||||
// Check upgrade
|
||||
{
|
||||
auto transaction (node->store.tx_begin_read ());
|
||||
ASSERT_EQ (5, node->store.account_count (transaction));
|
||||
for (auto i (node->store.accounts_begin (transaction)); i != node->store.accounts_end (); ++i)
|
||||
ASSERT_EQ (5, node->store.account.count (transaction));
|
||||
for (auto i (node->store.account.begin (transaction)); i != node->store.account.end (); ++i)
|
||||
{
|
||||
nano::account_info info (i->second);
|
||||
ASSERT_EQ (info.epoch (), nano::epoch::epoch_2);
|
||||
}
|
||||
ASSERT_TRUE (node->store.account_exists (transaction, key1.pub));
|
||||
ASSERT_TRUE (node->store.account_exists (transaction, key2.pub));
|
||||
ASSERT_TRUE (node->store.account_exists (transaction, key3.pub));
|
||||
ASSERT_TRUE (node->store.account_exists (transaction, std::numeric_limits<nano::uint256_t>::max ()));
|
||||
ASSERT_FALSE (node->store.account_exists (transaction, 0));
|
||||
ASSERT_TRUE (node->store.account.exists (transaction, key1.pub));
|
||||
ASSERT_TRUE (node->store.account.exists (transaction, key2.pub));
|
||||
ASSERT_TRUE (node->store.account.exists (transaction, key3.pub));
|
||||
ASSERT_TRUE (node->store.account.exists (transaction, std::numeric_limits<nano::uint256_t>::max ()));
|
||||
ASSERT_FALSE (node->store.account.exists (transaction, 0));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7281,8 +7281,8 @@ TEST (rpc, epoch_upgrade_multithreaded)
|
|||
// Check accounts epochs
|
||||
{
|
||||
auto transaction (node->store.tx_begin_read ());
|
||||
ASSERT_EQ (2, node->store.account_count (transaction));
|
||||
for (auto i (node->store.accounts_begin (transaction)); i != node->store.accounts_end (); ++i)
|
||||
ASSERT_EQ (2, node->store.account.count (transaction));
|
||||
for (auto i (node->store.account.begin (transaction)); i != node->store.account.end (); ++i)
|
||||
{
|
||||
nano::account_info info (i->second);
|
||||
ASSERT_EQ (info.epoch (), nano::epoch::epoch_0);
|
||||
|
@ -7304,20 +7304,20 @@ TEST (rpc, epoch_upgrade_multithreaded)
|
|||
ASSERT_TIMELY (5s, response.status != 0);
|
||||
ASSERT_EQ (200, response.status);
|
||||
ASSERT_EQ ("1", response.json.get<std::string> ("started"));
|
||||
ASSERT_TIMELY (5s, 4 == node->store.account_count (node->store.tx_begin_read ()));
|
||||
ASSERT_TIMELY (5s, 4 == node->store.account.count (node->store.tx_begin_read ()));
|
||||
// Check upgrade
|
||||
{
|
||||
auto transaction (node->store.tx_begin_read ());
|
||||
ASSERT_EQ (4, node->store.account_count (transaction));
|
||||
for (auto i (node->store.accounts_begin (transaction)); i != node->store.accounts_end (); ++i)
|
||||
ASSERT_EQ (4, node->store.account.count (transaction));
|
||||
for (auto i (node->store.account.begin (transaction)); i != node->store.account.end (); ++i)
|
||||
{
|
||||
nano::account_info info (i->second);
|
||||
ASSERT_EQ (info.epoch (), nano::epoch::epoch_1);
|
||||
}
|
||||
ASSERT_TRUE (node->store.account_exists (transaction, key1.pub));
|
||||
ASSERT_TRUE (node->store.account_exists (transaction, key2.pub));
|
||||
ASSERT_TRUE (node->store.account_exists (transaction, std::numeric_limits<nano::uint256_t>::max ()));
|
||||
ASSERT_FALSE (node->store.account_exists (transaction, 0));
|
||||
ASSERT_TRUE (node->store.account.exists (transaction, key1.pub));
|
||||
ASSERT_TRUE (node->store.account.exists (transaction, key2.pub));
|
||||
ASSERT_TRUE (node->store.account.exists (transaction, std::numeric_limits<nano::uint256_t>::max ()));
|
||||
ASSERT_FALSE (node->store.account.exists (transaction, 0));
|
||||
}
|
||||
|
||||
// Epoch 2 upgrade
|
||||
|
@ -7342,21 +7342,21 @@ TEST (rpc, epoch_upgrade_multithreaded)
|
|||
ASSERT_TIMELY (5s, response2.status != 0);
|
||||
ASSERT_EQ (200, response2.status);
|
||||
ASSERT_EQ ("1", response2.json.get<std::string> ("started"));
|
||||
ASSERT_TIMELY (5s, 5 == node->store.account_count (node->store.tx_begin_read ()));
|
||||
ASSERT_TIMELY (5s, 5 == node->store.account.count (node->store.tx_begin_read ()));
|
||||
// Check upgrade
|
||||
{
|
||||
auto transaction (node->store.tx_begin_read ());
|
||||
ASSERT_EQ (5, node->store.account_count (transaction));
|
||||
for (auto i (node->store.accounts_begin (transaction)); i != node->store.accounts_end (); ++i)
|
||||
ASSERT_EQ (5, node->store.account.count (transaction));
|
||||
for (auto i (node->store.account.begin (transaction)); i != node->store.account.end (); ++i)
|
||||
{
|
||||
nano::account_info info (i->second);
|
||||
ASSERT_EQ (info.epoch (), nano::epoch::epoch_2);
|
||||
}
|
||||
ASSERT_TRUE (node->store.account_exists (transaction, key1.pub));
|
||||
ASSERT_TRUE (node->store.account_exists (transaction, key2.pub));
|
||||
ASSERT_TRUE (node->store.account_exists (transaction, key3.pub));
|
||||
ASSERT_TRUE (node->store.account_exists (transaction, std::numeric_limits<nano::uint256_t>::max ()));
|
||||
ASSERT_FALSE (node->store.account_exists (transaction, 0));
|
||||
ASSERT_TRUE (node->store.account.exists (transaction, key1.pub));
|
||||
ASSERT_TRUE (node->store.account.exists (transaction, key2.pub));
|
||||
ASSERT_TRUE (node->store.account.exists (transaction, key3.pub));
|
||||
ASSERT_TRUE (node->store.account.exists (transaction, std::numeric_limits<nano::uint256_t>::max ()));
|
||||
ASSERT_FALSE (node->store.account.exists (transaction, 0));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7414,7 +7414,7 @@ TEST (rpc, receive)
|
|||
wallet->insert_adhoc (key1.prv);
|
||||
auto send1 (wallet->send_action (nano::dev_genesis_key.pub, key1.pub, node.config.receive_minimum.number (), *node.work_generate_blocking (nano::genesis_hash)));
|
||||
ASSERT_TIMELY (5s, node.balance (nano::dev_genesis_key.pub) != nano::genesis_amount);
|
||||
ASSERT_TIMELY (10s, !node.store.account_exists (node.store.tx_begin_read (), key1.pub));
|
||||
ASSERT_TIMELY (10s, !node.store.account.exists (node.store.tx_begin_read (), key1.pub));
|
||||
// Send below minimum receive amount
|
||||
auto send2 (wallet->send_action (nano::dev_genesis_key.pub, key1.pub, node.config.receive_minimum.number () - 1, *node.work_generate_blocking (send1->hash ())));
|
||||
scoped_io_thread_name_change scoped_thread_name_io;
|
||||
|
@ -7436,7 +7436,7 @@ TEST (rpc, receive)
|
|||
ASSERT_EQ (200, response.status);
|
||||
auto receive_text (response.json.get<std::string> ("block"));
|
||||
nano::account_info info;
|
||||
ASSERT_FALSE (node.store.account_get (node.store.tx_begin_read (), key1.pub, info));
|
||||
ASSERT_FALSE (node.store.account.get (node.store.tx_begin_read (), key1.pub, info));
|
||||
ASSERT_EQ (info.head, receive_text);
|
||||
}
|
||||
// Trying to receive the same block should fail with unreceivable
|
||||
|
@ -7468,7 +7468,7 @@ TEST (rpc, receive_unopened)
|
|||
nano::keypair key1;
|
||||
auto send1 (wallet->send_action (nano::dev_genesis_key.pub, key1.pub, node.config.receive_minimum.number () - 1, *node.work_generate_blocking (nano::genesis_hash)));
|
||||
ASSERT_TIMELY (5s, !node.balance (nano::dev_genesis_key.pub) != nano::genesis_amount);
|
||||
ASSERT_FALSE (node.store.account_exists (node.store.tx_begin_read (), key1.pub));
|
||||
ASSERT_FALSE (node.store.account.exists (node.store.tx_begin_read (), key1.pub));
|
||||
ASSERT_TRUE (node.store.block_exists (node.store.tx_begin_read (), send1->hash ()));
|
||||
wallet->insert_adhoc (key1.prv); // should not auto receive, amount sent was lower than minimum
|
||||
scoped_io_thread_name_change scoped_thread_name_io;
|
||||
|
@ -7490,7 +7490,7 @@ TEST (rpc, receive_unopened)
|
|||
ASSERT_EQ (200, response.status);
|
||||
auto receive_text (response.json.get<std::string> ("block"));
|
||||
nano::account_info info;
|
||||
ASSERT_FALSE (node.store.account_get (node.store.tx_begin_read (), key1.pub, info));
|
||||
ASSERT_FALSE (node.store.account.get (node.store.tx_begin_read (), key1.pub, info));
|
||||
ASSERT_EQ (info.head, info.open_block);
|
||||
ASSERT_EQ (info.head.to_string (), receive_text);
|
||||
ASSERT_EQ (info.representative, nano::dev_genesis_key.pub);
|
||||
|
@ -7502,7 +7502,7 @@ TEST (rpc, receive_unopened)
|
|||
auto prev_amount (node.balance (nano::dev_genesis_key.pub));
|
||||
auto send2 (wallet->send_action (nano::dev_genesis_key.pub, key2.pub, node.config.receive_minimum.number () - 1, *node.work_generate_blocking (send1->hash ())));
|
||||
ASSERT_TIMELY (5s, !node.balance (nano::dev_genesis_key.pub) != prev_amount);
|
||||
ASSERT_FALSE (node.store.account_exists (node.store.tx_begin_read (), key2.pub));
|
||||
ASSERT_FALSE (node.store.account.exists (node.store.tx_begin_read (), key2.pub));
|
||||
ASSERT_TRUE (node.store.block_exists (node.store.tx_begin_read (), send2->hash ()));
|
||||
nano::public_key rep;
|
||||
wallet->store.representative_set (node.wallets.tx_begin_write (), rep);
|
||||
|
@ -7516,7 +7516,7 @@ TEST (rpc, receive_unopened)
|
|||
ASSERT_EQ (200, response.status);
|
||||
auto receive_text (response.json.get<std::string> ("block"));
|
||||
nano::account_info info;
|
||||
ASSERT_FALSE (node.store.account_get (node.store.tx_begin_read (), key2.pub, info));
|
||||
ASSERT_FALSE (node.store.account.get (node.store.tx_begin_read (), key2.pub, info));
|
||||
ASSERT_EQ (info.head, info.open_block);
|
||||
ASSERT_EQ (info.head.to_string (), receive_text);
|
||||
ASSERT_EQ (info.representative, rep);
|
||||
|
@ -7541,7 +7541,7 @@ TEST (rpc, receive_work_disabled)
|
|||
auto send1 (wallet->send_action (nano::dev_genesis_key.pub, key1.pub, node.config.receive_minimum.number () - 1, *worker_node.work_generate_blocking (genesis.hash ()), false));
|
||||
ASSERT_TRUE (send1 != nullptr);
|
||||
ASSERT_TIMELY (5s, node.balance (nano::dev_genesis_key.pub) != nano::genesis_amount);
|
||||
ASSERT_FALSE (node.store.account_exists (node.store.tx_begin_read (), key1.pub));
|
||||
ASSERT_FALSE (node.store.account.exists (node.store.tx_begin_read (), key1.pub));
|
||||
ASSERT_TRUE (node.store.block_exists (node.store.tx_begin_read (), send1->hash ()));
|
||||
wallet->insert_adhoc (key1.prv);
|
||||
scoped_io_thread_name_change scoped_thread_name_io;
|
||||
|
@ -7583,7 +7583,7 @@ TEST (rpc, receive_pruned)
|
|||
wallet2->insert_adhoc (key1.prv);
|
||||
auto send1 (wallet1->send_action (nano::dev_genesis_key.pub, key1.pub, node2.config.receive_minimum.number (), *node2.work_generate_blocking (nano::genesis_hash)));
|
||||
ASSERT_TIMELY (5s, node2.balance (nano::dev_genesis_key.pub) != nano::genesis_amount);
|
||||
ASSERT_TIMELY (10s, !node2.store.account_exists (node2.store.tx_begin_read (), key1.pub));
|
||||
ASSERT_TIMELY (10s, !node2.store.account.exists (node2.store.tx_begin_read (), key1.pub));
|
||||
// Send below minimum receive amount
|
||||
auto send2 (wallet1->send_action (nano::dev_genesis_key.pub, key1.pub, node2.config.receive_minimum.number () - 1, *node2.work_generate_blocking (send1->hash ())));
|
||||
// Extra send frontier
|
||||
|
@ -7620,7 +7620,7 @@ TEST (rpc, receive_pruned)
|
|||
ASSERT_EQ (200, response.status);
|
||||
auto receive_text (response.json.get<std::string> ("block"));
|
||||
nano::account_info info;
|
||||
ASSERT_FALSE (node2.store.account_get (node2.store.tx_begin_read (), key1.pub, info));
|
||||
ASSERT_FALSE (node2.store.account.get (node2.store.tx_begin_read (), key1.pub, info));
|
||||
ASSERT_EQ (info.head, receive_text);
|
||||
}
|
||||
// Trying to receive the same block should fail with unreceivable
|
||||
|
|
|
@ -55,6 +55,7 @@ add_library(
|
|||
versioning.cpp
|
||||
working.hpp
|
||||
store/frontier_store_partial.hpp
|
||||
store/account_store_partial.hpp
|
||||
store/pending_store_partial.hpp
|
||||
store/online_weight_partial.hpp)
|
||||
|
||||
|
|
|
@ -105,8 +105,9 @@ bool nano::write_transaction::contains (nano::tables table_a) const
|
|||
return impl->contains (table_a);
|
||||
}
|
||||
|
||||
nano::block_store::block_store (nano::frontier_store & frontier_store_a, nano::pending_store & pending_store_a, nano::online_weight_store & online_weight_store_a) :
|
||||
nano::block_store::block_store (nano::frontier_store & frontier_store_a, nano::account_store & account_store_a, nano::pending_store & pending_store_a, nano::online_weight_store & online_weight_store_a) :
|
||||
frontier (frontier_store_a),
|
||||
account (account_store_a),
|
||||
pending (pending_store_a),
|
||||
online_weight (online_weight_store_a)
|
||||
{
|
||||
|
|
|
@ -635,6 +635,24 @@ public:
|
|||
virtual void for_each_par (std::function<void (nano::read_transaction const &, nano::store_iterator<nano::block_hash, nano::account>, nano::store_iterator<nano::block_hash, nano::account>)> const & action_a) const = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Manages account storage and iteration
|
||||
*/
|
||||
class account_store
|
||||
{
|
||||
public:
|
||||
virtual void put (nano::write_transaction const &, nano::account const &, nano::account_info const &) = 0;
|
||||
virtual bool get (nano::transaction const &, nano::account const &, nano::account_info &) = 0;
|
||||
virtual void del (nano::write_transaction const &, nano::account const &) = 0;
|
||||
virtual bool exists (nano::transaction const &, nano::account const &) = 0;
|
||||
virtual size_t count (nano::transaction const &) = 0;
|
||||
virtual nano::store_iterator<nano::account, nano::account_info> begin (nano::transaction const &, nano::account const &) const = 0;
|
||||
virtual nano::store_iterator<nano::account, nano::account_info> begin (nano::transaction const &) const = 0;
|
||||
virtual nano::store_iterator<nano::account, nano::account_info> rbegin (nano::transaction const &) const = 0;
|
||||
virtual nano::store_iterator<nano::account, nano::account_info> end () const = 0;
|
||||
virtual void 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 &) const = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Manages pending storage and iteration
|
||||
*/
|
||||
|
@ -673,7 +691,7 @@ public:
|
|||
class block_store
|
||||
{
|
||||
public:
|
||||
explicit block_store (nano::frontier_store &, nano::pending_store &, nano::online_weight_store &);
|
||||
explicit block_store (nano::frontier_store &, nano::account_store &, nano::pending_store &, nano::online_weight_store &);
|
||||
virtual ~block_store () = default;
|
||||
virtual void initialize (nano::write_transaction const &, nano::genesis const &, nano::ledger_cache &) = 0;
|
||||
virtual void block_put (nano::write_transaction const &, nano::block_hash const &, nano::block const &) = 0;
|
||||
|
@ -694,17 +712,7 @@ public:
|
|||
virtual nano::store_iterator<nano::block_hash, block_w_sideband> blocks_end () const = 0;
|
||||
|
||||
frontier_store & frontier;
|
||||
|
||||
virtual void account_put (nano::write_transaction const &, nano::account const &, nano::account_info const &) = 0;
|
||||
virtual bool account_get (nano::transaction const &, nano::account const &, nano::account_info &) = 0;
|
||||
virtual void account_del (nano::write_transaction const &, nano::account const &) = 0;
|
||||
virtual bool account_exists (nano::transaction const &, nano::account const &) = 0;
|
||||
virtual size_t account_count (nano::transaction 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_rbegin (nano::transaction const &) const = 0;
|
||||
virtual nano::store_iterator<nano::account, nano::account_info> accounts_end () const = 0;
|
||||
|
||||
account_store & account;
|
||||
pending_store & pending;
|
||||
|
||||
virtual nano::uint128_t block_balance (nano::transaction const &, nano::block_hash const &) = 0;
|
||||
|
@ -756,7 +764,6 @@ public:
|
|||
virtual nano::store_iterator<nano::account, nano::confirmation_height_info> confirmation_height_begin (nano::transaction const & transaction_a) const = 0;
|
||||
virtual nano::store_iterator<nano::account, nano::confirmation_height_info> confirmation_height_end () 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 &) 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 &) const = 0;
|
||||
virtual void unchecked_for_each_par (std::function<void (nano::read_transaction const &, nano::store_iterator<nano::unchecked_key, nano::unchecked_info>, nano::store_iterator<nano::unchecked_key, nano::unchecked_info>)> const & action_a) const = 0;
|
||||
virtual void pruned_for_each_par (std::function<void (nano::read_transaction const &, nano::store_iterator<nano::block_hash, std::nullptr_t>, nano::store_iterator<nano::block_hash, std::nullptr_t>)> const & action_a) const = 0;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <nano/lib/timer.hpp>
|
||||
#include <nano/secure/blockstore.hpp>
|
||||
#include <nano/secure/buffer.hpp>
|
||||
#include <nano/secure/store/account_store_partial.hpp>
|
||||
#include <nano/secure/store/frontier_store_partial.hpp>
|
||||
#include <nano/secure/store/online_weight_partial.hpp>
|
||||
#include <nano/secure/store/pending_store_partial.hpp>
|
||||
|
@ -39,6 +40,7 @@ template <typename Val, typename Derived_Store>
|
|||
class block_store_partial : public block_store
|
||||
{
|
||||
nano::frontier_store_partial<Val, Derived_Store> frontier_store_partial;
|
||||
nano::account_store_partial<Val, Derived_Store> account_store_partial;
|
||||
nano::pending_store_partial<Val, Derived_Store> pending_store_partial;
|
||||
nano::online_weight_store_partial<Val, Derived_Store> online_weight_store_partial;
|
||||
|
||||
|
@ -50,12 +52,14 @@ public:
|
|||
|
||||
friend class nano::block_predecessor_set<Val, Derived_Store>;
|
||||
friend class nano::frontier_store_partial<Val, Derived_Store>;
|
||||
friend class nano::account_store_partial<Val, Derived_Store>;
|
||||
friend class nano::pending_store_partial<Val, Derived_Store>;
|
||||
friend class nano::online_weight_store_partial<Val, Derived_Store>;
|
||||
|
||||
block_store_partial () :
|
||||
block_store{ frontier_store_partial, pending_store_partial, online_weight_store_partial },
|
||||
block_store{ frontier_store_partial, account_store_partial, pending_store_partial, online_weight_store_partial },
|
||||
frontier_store_partial{ *this },
|
||||
account_store_partial{ *this },
|
||||
pending_store_partial{ *this },
|
||||
online_weight_store_partial{ *this }
|
||||
{
|
||||
|
@ -68,14 +72,14 @@ 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 (accounts_begin (transaction_a) == accounts_end ());
|
||||
debug_assert (account.begin (transaction_a) == account.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;
|
||||
confirmation_height_put (transaction_a, network_params.ledger.genesis_account, nano::confirmation_height_info{ 1, genesis_a.hash () });
|
||||
++ledger_cache_a.cemented_count;
|
||||
ledger_cache_a.final_votes_confirmation_canary = (network_params.ledger.final_votes_canary_account == network_params.ledger.genesis_account && 1 >= network_params.ledger.final_votes_canary_height);
|
||||
account_put (transaction_a, network_params.ledger.genesis_account, { hash_l, network_params.ledger.genesis_account, genesis_a.open->hash (), std::numeric_limits<nano::uint128_t>::max (), nano::seconds_since_epoch (), 1, nano::epoch::epoch_0 });
|
||||
account.put (transaction_a, network_params.ledger.genesis_account, { hash_l, network_params.ledger.genesis_account, genesis_a.open->hash (), std::numeric_limits<nano::uint128_t>::max (), nano::seconds_since_epoch (), 1, nano::epoch::epoch_0 });
|
||||
++ledger_cache_a.account_count;
|
||||
ledger_cache_a.rep_weights.representation_put (network_params.ledger.genesis_account, std::numeric_limits<nano::uint128_t>::max ());
|
||||
frontier.put (transaction_a, hash_l, network_params.ledger.genesis_account);
|
||||
|
@ -152,7 +156,7 @@ public:
|
|||
|
||||
bool root_exists (nano::transaction const & transaction_a, nano::root const & root_a) override
|
||||
{
|
||||
return block_exists (transaction_a, root_a.as_block_hash ()) || account_exists (transaction_a, root_a.as_account ());
|
||||
return block_exists (transaction_a, root_a.as_block_hash ()) || account.exists (transaction_a, root_a.as_account ());
|
||||
}
|
||||
|
||||
nano::account block_account (nano::transaction const & transaction_a, nano::block_hash const & hash_a) const override
|
||||
|
@ -238,11 +242,6 @@ public:
|
|||
return nano::store_iterator<nano::endpoint_key, nano::no_value> (nullptr);
|
||||
}
|
||||
|
||||
nano::store_iterator<nano::account, nano::account_info> accounts_end () const override
|
||||
{
|
||||
return nano::store_iterator<nano::account, nano::account_info> (nullptr);
|
||||
}
|
||||
|
||||
nano::store_iterator<nano::block_hash, nano::block_w_sideband> blocks_end () const override
|
||||
{
|
||||
return nano::store_iterator<nano::block_hash, nano::block_w_sideband> (nullptr);
|
||||
|
@ -336,41 +335,6 @@ public:
|
|||
release_assert_success (*this, status);
|
||||
}
|
||||
|
||||
void account_put (nano::write_transaction const & transaction_a, nano::account const & account_a, nano::account_info const & info_a) override
|
||||
{
|
||||
// Check we are still in sync with other tables
|
||||
nano::db_val<Val> info (info_a);
|
||||
auto status = put (transaction_a, tables::accounts, account_a, info);
|
||||
release_assert_success (*this, status);
|
||||
}
|
||||
|
||||
void account_del (nano::write_transaction const & transaction_a, nano::account const & account_a) override
|
||||
{
|
||||
auto status = del (transaction_a, tables::accounts, account_a);
|
||||
release_assert_success (*this, status);
|
||||
}
|
||||
|
||||
bool account_get (nano::transaction const & transaction_a, nano::account const & account_a, nano::account_info & info_a) override
|
||||
{
|
||||
nano::db_val<Val> value;
|
||||
nano::db_val<Val> account (account_a);
|
||||
auto status1 (get (transaction_a, tables::accounts, account, value));
|
||||
release_assert (success (status1) || not_found (status1));
|
||||
bool result (true);
|
||||
if (success (status1))
|
||||
{
|
||||
nano::bufferstream stream (reinterpret_cast<uint8_t const *> (value.data ()), value.size ());
|
||||
result = info_a.deserialize (stream);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool account_exists (nano::transaction const & transaction_a, nano::account const & account_a) override
|
||||
{
|
||||
auto iterator (accounts_begin (transaction_a, account_a));
|
||||
return iterator != accounts_end () && nano::account (iterator->first) == account_a;
|
||||
}
|
||||
|
||||
void pruned_put (nano::write_transaction const & transaction_a, nano::block_hash const & hash_a) override
|
||||
{
|
||||
auto status = put_key (transaction_a, tables::pruned, hash_a);
|
||||
|
@ -437,11 +401,6 @@ public:
|
|||
return count (transaction_a, tables::blocks);
|
||||
}
|
||||
|
||||
size_t account_count (nano::transaction const & transaction_a) override
|
||||
{
|
||||
return count (transaction_a, tables::accounts);
|
||||
}
|
||||
|
||||
std::shared_ptr<nano::block> block_random (nano::transaction const & transaction_a) override
|
||||
{
|
||||
nano::block_hash hash;
|
||||
|
@ -581,16 +540,6 @@ public:
|
|||
drop (transaction_a, nano::tables::confirmation_height);
|
||||
}
|
||||
|
||||
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> accounts_begin (nano::transaction const & transaction_a) const override
|
||||
{
|
||||
return make_iterator<nano::account, nano::account_info> (transaction_a, tables::accounts);
|
||||
}
|
||||
|
||||
nano::store_iterator<nano::block_hash, nano::block_w_sideband> blocks_begin (nano::transaction const & transaction_a) const override
|
||||
{
|
||||
return make_iterator<nano::block_hash, nano::block_w_sideband> (transaction_a, tables::blocks);
|
||||
|
@ -646,25 +595,11 @@ public:
|
|||
return make_iterator<nano::qualified_root, nano::block_hash> (transaction_a, tables::final_votes);
|
||||
}
|
||||
|
||||
nano::store_iterator<nano::account, nano::account_info> accounts_rbegin (nano::transaction const & transaction_a) const override
|
||||
{
|
||||
return make_iterator<nano::account, nano::account_info> (transaction_a, tables::accounts, false);
|
||||
}
|
||||
|
||||
size_t unchecked_count (nano::transaction const & transaction_a) override
|
||||
{
|
||||
return count (transaction_a, tables::unchecked);
|
||||
}
|
||||
|
||||
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) const 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->accounts_begin (transaction, start), !is_last ? this->accounts_begin (transaction, end) : this->accounts_end ());
|
||||
});
|
||||
}
|
||||
|
||||
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 & action_a) const override
|
||||
{
|
||||
parallel_traversal<nano::uint256_t> (
|
||||
|
|
|
@ -35,7 +35,7 @@ public:
|
|||
if (!error)
|
||||
{
|
||||
nano::account_info info;
|
||||
[[maybe_unused]] auto error (ledger.store.account_get (transaction, pending.source, info));
|
||||
[[maybe_unused]] auto error (ledger.store.account.get (transaction, pending.source, info));
|
||||
debug_assert (!error);
|
||||
ledger.store.pending.del (transaction, key);
|
||||
ledger.cache.rep_weights.representation_add (info.representative, pending.amount.number ());
|
||||
|
@ -57,7 +57,7 @@ public:
|
|||
[[maybe_unused]] bool is_pruned (false);
|
||||
auto source_account (ledger.account_safe (transaction, block_a.hashables.source, is_pruned));
|
||||
nano::account_info info;
|
||||
[[maybe_unused]] auto error (ledger.store.account_get (transaction, destination_account, info));
|
||||
[[maybe_unused]] auto error (ledger.store.account.get (transaction, destination_account, info));
|
||||
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);
|
||||
|
@ -91,7 +91,7 @@ public:
|
|||
auto rep_block (ledger.representative (transaction, block_a.hashables.previous));
|
||||
auto account (ledger.account (transaction, block_a.hashables.previous));
|
||||
nano::account_info info;
|
||||
[[maybe_unused]] auto error (ledger.store.account_get (transaction, account, info));
|
||||
[[maybe_unused]] auto error (ledger.store.account.get (transaction, account, info));
|
||||
debug_assert (!error);
|
||||
auto balance (ledger.balance (transaction, block_a.hashables.previous));
|
||||
auto block = ledger.store.block_get (transaction, rep_block);
|
||||
|
@ -132,7 +132,7 @@ public:
|
|||
}
|
||||
|
||||
nano::account_info info;
|
||||
auto error (ledger.store.account_get (transaction, block_a.hashables.account, info));
|
||||
auto error (ledger.store.account.get (transaction, block_a.hashables.account, info));
|
||||
|
||||
if (is_send)
|
||||
{
|
||||
|
@ -286,7 +286,7 @@ void ledger_processor::state_block_impl (nano::state_block & block_a)
|
|||
nano::amount amount (block_a.hashables.balance);
|
||||
auto is_send (false);
|
||||
auto is_receive (false);
|
||||
auto account_error (ledger.store.account_get (transaction, block_a.hashables.account, info));
|
||||
auto account_error (ledger.store.account.get (transaction, block_a.hashables.account, info));
|
||||
if (!account_error)
|
||||
{
|
||||
// Account already exists
|
||||
|
@ -408,7 +408,7 @@ void ledger_processor::epoch_block_impl (nano::state_block & block_a)
|
|||
if (result.code == nano::process_result::progress)
|
||||
{
|
||||
nano::account_info info;
|
||||
auto account_error (ledger.store.account_get (transaction, block_a.hashables.account, info));
|
||||
auto account_error (ledger.store.account.get (transaction, block_a.hashables.account, info));
|
||||
if (!account_error)
|
||||
{
|
||||
// Account already exists
|
||||
|
@ -486,7 +486,7 @@ void ledger_processor::change_block (nano::change_block & block_a)
|
|||
if (result.code == nano::process_result::progress)
|
||||
{
|
||||
nano::account_info info;
|
||||
auto latest_error (ledger.store.account_get (transaction, account, info));
|
||||
auto latest_error (ledger.store.account.get (transaction, account, info));
|
||||
(void)latest_error;
|
||||
debug_assert (!latest_error);
|
||||
debug_assert (info.head == block_a.hashables.previous);
|
||||
|
@ -553,7 +553,7 @@ void ledger_processor::send_block (nano::send_block & block_a)
|
|||
debug_assert (!validate_message (account, hash, block_a.signature));
|
||||
result.verified = nano::signature_verification::valid;
|
||||
nano::account_info info;
|
||||
auto latest_error (ledger.store.account_get (transaction, account, info));
|
||||
auto latest_error (ledger.store.account.get (transaction, account, info));
|
||||
(void)latest_error;
|
||||
debug_assert (!latest_error);
|
||||
debug_assert (info.head == block_a.hashables.previous);
|
||||
|
@ -611,7 +611,7 @@ void ledger_processor::receive_block (nano::receive_block & block_a)
|
|||
if (result.code == nano::process_result::progress)
|
||||
{
|
||||
nano::account_info info;
|
||||
ledger.store.account_get (transaction, account, info);
|
||||
ledger.store.account.get (transaction, account, info);
|
||||
result.code = info.head == block_a.hashables.previous ? nano::process_result::progress : nano::process_result::gap_previous; // Block doesn't immediately follow latest block (Harmless)
|
||||
if (result.code == nano::process_result::progress)
|
||||
{
|
||||
|
@ -632,7 +632,7 @@ void ledger_processor::receive_block (nano::receive_block & block_a)
|
|||
if (ledger.store.block_exists (transaction, block_a.hashables.source))
|
||||
{
|
||||
nano::account_info source_info;
|
||||
[[maybe_unused]] auto error (ledger.store.account_get (transaction, pending.source, source_info));
|
||||
[[maybe_unused]] auto error (ledger.store.account.account_get (transaction, pending.source, source_info));
|
||||
debug_assert (!error);
|
||||
}
|
||||
#endif
|
||||
|
@ -682,7 +682,7 @@ void ledger_processor::open_block (nano::open_block & block_a)
|
|||
if (result.code == nano::process_result::progress)
|
||||
{
|
||||
nano::account_info info;
|
||||
result.code = ledger.store.account_get (transaction, block_a.hashables.account, info) ? nano::process_result::progress : nano::process_result::fork; // Has this account already been opened? (Malicious)
|
||||
result.code = ledger.store.account.get (transaction, block_a.hashables.account, info) ? nano::process_result::progress : nano::process_result::fork; // Has this account already been opened? (Malicious)
|
||||
if (result.code == nano::process_result::progress)
|
||||
{
|
||||
nano::pending_key key (block_a.hashables.account, block_a.hashables.source);
|
||||
|
@ -704,7 +704,7 @@ void ledger_processor::open_block (nano::open_block & block_a)
|
|||
if (ledger.store.block_exists (transaction, block_a.hashables.source))
|
||||
{
|
||||
nano::account_info source_info;
|
||||
[[maybe_unused]] auto error (ledger.store.account_get (transaction, pending.source, source_info));
|
||||
[[maybe_unused]] auto error (ledger.store.account.account_get (transaction, pending.source, source_info));
|
||||
debug_assert (!error);
|
||||
}
|
||||
#endif
|
||||
|
@ -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.block_count)
|
||||
{
|
||||
store.accounts_for_each_par (
|
||||
store.account.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 };
|
||||
|
@ -829,7 +829,7 @@ nano::uint128_t nano::ledger::account_balance (nano::transaction const & transac
|
|||
else
|
||||
{
|
||||
nano::account_info info;
|
||||
auto none (store.account_get (transaction_a, account_a, info));
|
||||
auto none (store.account.get (transaction_a, account_a, info));
|
||||
if (!none)
|
||||
{
|
||||
result = info.balance.number ();
|
||||
|
@ -1047,7 +1047,7 @@ bool nano::ledger::rollback (nano::write_transaction const & transaction_a, nano
|
|||
store.confirmation_height_get (transaction_a, account_l, confirmation_height_info);
|
||||
if (block_account_height > confirmation_height_info.height)
|
||||
{
|
||||
auto latest_error = store.account_get (transaction_a, account_l, account_info);
|
||||
auto latest_error = store.account.get (transaction_a, account_l, account_info);
|
||||
debug_assert (!latest_error);
|
||||
auto block (store.block_get (transaction_a, account_info.head));
|
||||
list_a.push_back (block);
|
||||
|
@ -1127,7 +1127,7 @@ nano::uint128_t nano::ledger::amount_safe (nano::transaction const & transaction
|
|||
nano::block_hash nano::ledger::latest (nano::transaction const & transaction_a, nano::account const & account_a)
|
||||
{
|
||||
nano::account_info info;
|
||||
auto latest_error (store.account_get (transaction_a, account_a, info));
|
||||
auto latest_error (store.account.get (transaction_a, account_a, info));
|
||||
return latest_error ? 0 : info.head;
|
||||
}
|
||||
|
||||
|
@ -1135,7 +1135,7 @@ nano::block_hash nano::ledger::latest (nano::transaction const & transaction_a,
|
|||
nano::root nano::ledger::latest_root (nano::transaction const & transaction_a, nano::account const & account_a)
|
||||
{
|
||||
nano::account_info info;
|
||||
if (store.account_get (transaction_a, account_a, info))
|
||||
if (store.account.get (transaction_a, account_a, info))
|
||||
{
|
||||
return account_a;
|
||||
}
|
||||
|
@ -1255,15 +1255,15 @@ void nano::ledger::update_account (nano::write_transaction const & transaction_a
|
|||
}
|
||||
if (!old_a.head.is_zero () && old_a.epoch () != new_a.epoch ())
|
||||
{
|
||||
// store.account_put won't erase existing entries if they're in different tables
|
||||
store.account_del (transaction_a, account_a);
|
||||
// store.account.put won't erase existing entries if they're in different tables
|
||||
store.account.del (transaction_a, account_a);
|
||||
}
|
||||
store.account_put (transaction_a, account_a, new_a);
|
||||
store.account.put (transaction_a, account_a, new_a);
|
||||
}
|
||||
else
|
||||
{
|
||||
debug_assert (!store.confirmation_height_exists (transaction_a, account_a));
|
||||
store.account_del (transaction_a, account_a);
|
||||
store.account.del (transaction_a, account_a);
|
||||
debug_assert (cache.account_count > 0);
|
||||
--cache.account_count;
|
||||
}
|
||||
|
@ -1276,7 +1276,7 @@ std::shared_ptr<nano::block> nano::ledger::successor (nano::transaction const &
|
|||
if (root_a.previous ().is_zero ())
|
||||
{
|
||||
nano::account_info info;
|
||||
if (!store.account_get (transaction_a, root_a.root ().as_account (), info))
|
||||
if (!store.account.get (transaction_a, root_a.root ().as_account (), info))
|
||||
{
|
||||
successor = info.open_block;
|
||||
}
|
||||
|
@ -1307,12 +1307,12 @@ std::shared_ptr<nano::block> nano::ledger::forked_block (nano::transaction const
|
|||
{
|
||||
debug_assert (!store.block_exists (transaction_a, block_a.hash ()));
|
||||
auto root (block_a.root ());
|
||||
debug_assert (store.block_exists (transaction_a, root.as_block_hash ()) || store.account_exists (transaction_a, root.as_account ()));
|
||||
debug_assert (store.block_exists (transaction_a, root.as_block_hash ()) || store.account.exists (transaction_a, root.as_account ()));
|
||||
auto result (store.block_get (transaction_a, store.block_successor (transaction_a, root.as_block_hash ())));
|
||||
if (result == nullptr)
|
||||
{
|
||||
nano::account_info info;
|
||||
auto error (store.account_get (transaction_a, root.as_account (), info));
|
||||
auto error (store.account.get (transaction_a, root.as_account (), info));
|
||||
(void)error;
|
||||
debug_assert (!error);
|
||||
result = store.block_get (transaction_a, info.open_block);
|
||||
|
@ -1376,7 +1376,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.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) {
|
||||
store.account.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)
|
||||
{
|
||||
|
@ -1463,12 +1463,12 @@ bool nano::ledger::migrate_lmdb_to_rocksdb (boost::filesystem::path const & data
|
|||
}
|
||||
});
|
||||
|
||||
store.accounts_for_each_par (
|
||||
store.account.for_each_par (
|
||||
[&rocksdb_store] (nano::read_transaction const & /*unused*/, auto i, auto n) {
|
||||
for (; i != n; ++i)
|
||||
{
|
||||
auto rocksdb_transaction (rocksdb_store->tx_begin_write ({}, { nano::tables::accounts }));
|
||||
rocksdb_store->account_put (rocksdb_transaction, i->first, i->second);
|
||||
rocksdb_store->account.put (rocksdb_transaction, i->first, i->second);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1528,7 +1528,7 @@ bool nano::ledger::migrate_lmdb_to_rocksdb (boost::filesystem::path const & data
|
|||
|
||||
auto account = random_block->account ().is_zero () ? random_block->sideband ().account : random_block->account ();
|
||||
nano::account_info account_info;
|
||||
error |= rocksdb_store->account_get (rocksdb_transaction, account, account_info);
|
||||
error |= rocksdb_store->account.get (rocksdb_transaction, account, account_info);
|
||||
|
||||
// If confirmation height exists in the lmdb ledger for this account it should exist in the rocksdb ledger
|
||||
nano::confirmation_height_info confirmation_height_info;
|
||||
|
|
101
nano/secure/store/account_store_partial.hpp
Normal file
101
nano/secure/store/account_store_partial.hpp
Normal file
|
@ -0,0 +1,101 @@
|
|||
#pragma once
|
||||
|
||||
#include <nano/secure/blockstore_partial.hpp>
|
||||
|
||||
namespace
|
||||
{
|
||||
template <typename T>
|
||||
void parallel_traversal (std::function<void (T const &, T const &, bool const)> const & action);
|
||||
}
|
||||
|
||||
namespace nano
|
||||
{
|
||||
template <typename Val, typename Derived_Store>
|
||||
class block_store_partial;
|
||||
|
||||
template <typename Val, typename Derived_Store>
|
||||
void release_assert_success (block_store_partial<Val, Derived_Store> const & block_store, const int status);
|
||||
|
||||
template <typename Val, typename Derived_Store>
|
||||
class account_store_partial : public account_store
|
||||
{
|
||||
private:
|
||||
nano::block_store_partial<Val, Derived_Store> & block_store;
|
||||
|
||||
friend void release_assert_success<Val, Derived_Store> (block_store_partial<Val, Derived_Store> const & block_store, const int status);
|
||||
|
||||
public:
|
||||
explicit account_store_partial (nano::block_store_partial<Val, Derived_Store> & block_store_a) :
|
||||
block_store (block_store_a){};
|
||||
|
||||
void put (nano::write_transaction const & transaction_a, nano::account const & account_a, nano::account_info const & info_a) override
|
||||
{
|
||||
// Check we are still in sync with other tables
|
||||
nano::db_val<Val> info (info_a);
|
||||
auto status = block_store.put (transaction_a, tables::accounts, account_a, info);
|
||||
release_assert_success (block_store, status);
|
||||
}
|
||||
|
||||
bool get (nano::transaction const & transaction_a, nano::account const & account_a, nano::account_info & info_a) override
|
||||
{
|
||||
nano::db_val<Val> value;
|
||||
nano::db_val<Val> account (account_a);
|
||||
auto status1 (block_store.get (transaction_a, tables::accounts, account, value));
|
||||
release_assert (block_store.success (status1) || block_store.not_found (status1));
|
||||
bool result (true);
|
||||
if (block_store.success (status1))
|
||||
{
|
||||
nano::bufferstream stream (reinterpret_cast<uint8_t const *> (value.data ()), value.size ());
|
||||
result = info_a.deserialize (stream);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void del (nano::write_transaction const & transaction_a, nano::account const & account_a) override
|
||||
{
|
||||
auto status = block_store.del (transaction_a, tables::accounts, account_a);
|
||||
release_assert_success (block_store, status);
|
||||
}
|
||||
|
||||
bool exists (nano::transaction const & transaction_a, nano::account const & account_a) override
|
||||
{
|
||||
auto iterator (begin (transaction_a, account_a));
|
||||
return iterator != end () && nano::account (iterator->first) == account_a;
|
||||
}
|
||||
|
||||
size_t count (nano::transaction const & transaction_a) override
|
||||
{
|
||||
return block_store.count (transaction_a, tables::accounts);
|
||||
}
|
||||
|
||||
nano::store_iterator<nano::account, nano::account_info> begin (nano::transaction const & transaction_a, nano::account const & account_a) const override
|
||||
{
|
||||
return block_store.template 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> begin (nano::transaction const & transaction_a) const override
|
||||
{
|
||||
return block_store.template make_iterator<nano::account, nano::account_info> (transaction_a, tables::accounts);
|
||||
}
|
||||
|
||||
nano::store_iterator<nano::account, nano::account_info> rbegin (nano::transaction const & transaction_a) const override
|
||||
{
|
||||
return block_store.template make_iterator<nano::account, nano::account_info> (transaction_a, tables::accounts, false);
|
||||
}
|
||||
|
||||
nano::store_iterator<nano::account, nano::account_info> end () const override
|
||||
{
|
||||
return nano::store_iterator<nano::account, nano::account_info> (nullptr);
|
||||
}
|
||||
|
||||
void 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) const 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->block_store.tx_begin_read ());
|
||||
action_a (transaction, this->begin (transaction, start), !is_last ? this->begin (transaction, end) : this->end ());
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}
|
|
@ -26,7 +26,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.accounts_begin (transaction)), n (system.nodes[0]->store.accounts_end ()); i != n; ++i)
|
||||
for (auto i (system.nodes[0]->store.account.begin (transaction)), n (system.nodes[0]->store.account.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.accounts_begin (transaction)), n (system.nodes[0]->store.accounts_end ()); i != n; ++i)
|
||||
for (auto i (system.nodes[0]->store.account.begin (transaction)), n (system.nodes[0]->store.account.end ()); i != n; ++i)
|
||||
{
|
||||
}
|
||||
system.stop ();
|
||||
|
@ -169,7 +169,7 @@ TEST (store, load)
|
|||
nano::account account;
|
||||
nano::random_pool::generate_block (account.bytes.data (), account.bytes.size ());
|
||||
system.nodes[0]->store.confirmation_height_put (transaction, account, { 0, nano::block_hash (0) });
|
||||
system.nodes[0]->store.account_put (transaction, account, nano::account_info ());
|
||||
system.nodes[0]->store.account.put (transaction, account, nano::account_info ());
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
@ -544,7 +544,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.accounts_begin (transaction)), n (node->store.accounts_end ()); i != n; ++i)
|
||||
for (auto i (node->store.account.begin (transaction)), n (node->store.account.end ()); i != n; ++i)
|
||||
{
|
||||
auto & account = i->first;
|
||||
auto & account_info = i->second;
|
||||
|
@ -699,13 +699,13 @@ TEST (confirmation_height, long_chains)
|
|||
|
||||
auto transaction (node->store.tx_begin_read ());
|
||||
nano::account_info account_info;
|
||||
ASSERT_FALSE (node->store.account_get (transaction, nano::dev_genesis_key.pub, account_info));
|
||||
ASSERT_FALSE (node->store.account.get (transaction, nano::dev_genesis_key.pub, account_info));
|
||||
nano::confirmation_height_info confirmation_height_info;
|
||||
ASSERT_FALSE (node->store.confirmation_height_get (transaction, nano::dev_genesis_key.pub, confirmation_height_info));
|
||||
ASSERT_EQ (num_blocks + 2, confirmation_height_info.height);
|
||||
ASSERT_EQ (num_blocks + 3, account_info.block_count); // Includes the unpocketed send
|
||||
|
||||
ASSERT_FALSE (node->store.account_get (transaction, key1.pub, account_info));
|
||||
ASSERT_FALSE (node->store.account.get (transaction, key1.pub, account_info));
|
||||
ASSERT_FALSE (node->store.confirmation_height_get (transaction, key1.pub, confirmation_height_info));
|
||||
ASSERT_EQ (num_blocks + 1, confirmation_height_info.height);
|
||||
ASSERT_EQ (num_blocks + 1, account_info.block_count);
|
||||
|
@ -1674,7 +1674,7 @@ TEST (node, mass_epoch_upgrader)
|
|||
{
|
||||
auto transaction (node.store.tx_begin_read ());
|
||||
size_t block_count_sum = 0;
|
||||
for (auto i (node.store.accounts_begin (transaction)); i != node.store.accounts_end (); ++i)
|
||||
for (auto i (node.store.account.begin (transaction)); i != node.store.account.end (); ++i)
|
||||
{
|
||||
nano::account_info info (i->second);
|
||||
ASSERT_EQ (info.epoch (), nano::epoch::epoch_1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue