Cache unchecked count (#2458)
This commit is contained in:
parent
a4be4e6861
commit
d13ab81641
22 changed files with 238 additions and 216 deletions
|
@ -275,11 +275,9 @@ TEST (block_store, genesis)
|
|||
ASSERT_TRUE (!store->init_error ());
|
||||
nano::genesis genesis;
|
||||
auto hash (genesis.hash ());
|
||||
nano::rep_weights rep_weights;
|
||||
std::atomic<uint64_t> cemented_count{ 0 };
|
||||
std::atomic<uint64_t> block_count_cache{ 0 };
|
||||
nano::ledger_cache ledger_cache;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, rep_weights, cemented_count, block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger_cache);
|
||||
nano::account_info info;
|
||||
ASSERT_FALSE (store->account_get (transaction, nano::genesis_account, info));
|
||||
ASSERT_EQ (hash, info.head);
|
||||
|
@ -757,11 +755,9 @@ TEST (block_store, cemented_count_cache)
|
|||
ASSERT_TRUE (!store->init_error ());
|
||||
auto transaction (store->tx_begin_write ());
|
||||
nano::genesis genesis;
|
||||
nano::rep_weights rep_weights;
|
||||
std::atomic<uint64_t> cemented_count{ 0 };
|
||||
std::atomic<uint64_t> block_count_cache{ 0 };
|
||||
store->initialize (transaction, genesis, rep_weights, cemented_count, block_count_cache);
|
||||
ASSERT_EQ (1, cemented_count);
|
||||
nano::ledger_cache ledger_cache;
|
||||
store->initialize (transaction, genesis, ledger_cache);
|
||||
ASSERT_EQ (1, ledger_cache.cemented_count);
|
||||
}
|
||||
|
||||
TEST (block_store, sequence_increment)
|
||||
|
@ -808,7 +804,7 @@ TEST (mdb_block_store, upgrade_v2_v3)
|
|||
auto hash (genesis.hash ());
|
||||
nano::stat stats;
|
||||
nano::ledger ledger (store, stats);
|
||||
store.initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store.initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::change_block change (hash, key1.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (hash));
|
||||
change_hash = change.hash ();
|
||||
|
@ -816,10 +812,10 @@ TEST (mdb_block_store, upgrade_v2_v3)
|
|||
ASSERT_EQ (0, ledger.weight (nano::test_genesis_key.pub));
|
||||
ASSERT_EQ (nano::genesis_amount, ledger.weight (key1.pub));
|
||||
store.version_put (transaction, 2);
|
||||
ledger.rep_weights.representation_put (key1.pub, 7);
|
||||
ledger.cache.rep_weights.representation_put (key1.pub, 7);
|
||||
ASSERT_EQ (7, ledger.weight (key1.pub));
|
||||
ASSERT_EQ (2, store.version_get (transaction));
|
||||
ledger.rep_weights.representation_put (key2.pub, 6);
|
||||
ledger.cache.rep_weights.representation_put (key2.pub, 6);
|
||||
ASSERT_EQ (6, ledger.weight (key2.pub));
|
||||
nano::account_info info;
|
||||
ASSERT_FALSE (store.account_get (transaction, nano::test_genesis_key.pub, info));
|
||||
|
@ -888,7 +884,7 @@ TEST (mdb_block_store, upgrade_v4_v5)
|
|||
nano::genesis genesis;
|
||||
nano::stat stats;
|
||||
nano::ledger ledger (store, stats);
|
||||
store.initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store.initialize (transaction, genesis, ledger.cache);
|
||||
store.version_put (transaction, 4);
|
||||
nano::account_info info;
|
||||
ASSERT_FALSE (store.account_get (transaction, nano::test_genesis_key.pub, info));
|
||||
|
@ -920,11 +916,9 @@ TEST (block_store, block_random)
|
|||
ASSERT_TRUE (!store->init_error ());
|
||||
nano::genesis genesis;
|
||||
{
|
||||
nano::rep_weights rep_weights;
|
||||
std::atomic<uint64_t> cemented_count{ 0 };
|
||||
std::atomic<uint64_t> block_count_cache{ 0 };
|
||||
nano::ledger_cache ledger_cache;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, rep_weights, cemented_count, block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger_cache);
|
||||
}
|
||||
auto transaction (store->tx_begin_read ());
|
||||
auto block (store->block_random (transaction));
|
||||
|
@ -941,10 +935,8 @@ TEST (mdb_block_store, upgrade_v5_v6)
|
|||
ASSERT_FALSE (store.init_error ());
|
||||
auto transaction (store.tx_begin_write ());
|
||||
nano::genesis genesis;
|
||||
nano::rep_weights rep_weights;
|
||||
std::atomic<uint64_t> cemented_count{ 0 };
|
||||
std::atomic<uint64_t> block_count_cache{ 0 };
|
||||
store.initialize (transaction, genesis, rep_weights, cemented_count, block_count_cache);
|
||||
nano::ledger_cache ledger_cache;
|
||||
store.initialize (transaction, genesis, ledger_cache);
|
||||
store.version_put (transaction, 5);
|
||||
modify_genesis_account_info_to_v5 (store, transaction);
|
||||
}
|
||||
|
@ -966,10 +958,8 @@ TEST (mdb_block_store, upgrade_v6_v7)
|
|||
ASSERT_FALSE (store.init_error ());
|
||||
auto transaction (store.tx_begin_write ());
|
||||
nano::genesis genesis;
|
||||
nano::rep_weights rep_weights;
|
||||
std::atomic<uint64_t> cemented_count{ 0 };
|
||||
std::atomic<uint64_t> block_count_cache{ 0 };
|
||||
store.initialize (transaction, genesis, rep_weights, cemented_count, block_count_cache);
|
||||
nano::ledger_cache ledger_cache;
|
||||
store.initialize (transaction, genesis, ledger_cache);
|
||||
store.version_put (transaction, 6);
|
||||
modify_account_info_to_v13 (store, transaction, nano::genesis_account, genesis.open->hash ());
|
||||
auto send1 (std::make_shared<nano::send_block> (0, 0, 0, nano::test_genesis_key.prv, nano::test_genesis_key.pub, 0));
|
||||
|
@ -1129,11 +1119,9 @@ TEST (block_store, state_block)
|
|||
nano::keypair key1;
|
||||
nano::state_block block1 (1, genesis.hash (), 3, 4, 6, key1.prv, key1.pub, 7);
|
||||
{
|
||||
nano::ledger_cache ledger_cache;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
nano::rep_weights rep_weights;
|
||||
std::atomic<uint64_t> cemented_count{ 0 };
|
||||
std::atomic<uint64_t> block_count_cache{ 0 };
|
||||
store->initialize (transaction, genesis, rep_weights, cemented_count, block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger_cache);
|
||||
ASSERT_EQ (nano::block_type::state, block1.type ());
|
||||
nano::block_sideband sideband1 (nano::block_type::state, 0, 0, 0, 0, 0, nano::epoch::epoch_0);
|
||||
store->block_put (transaction, block1.hash (), block1, sideband1);
|
||||
|
@ -1164,10 +1152,8 @@ TEST (mdb_block_store, upgrade_sideband_genesis)
|
|||
ASSERT_FALSE (store.init_error ());
|
||||
auto transaction (store.tx_begin_write ());
|
||||
store.version_put (transaction, 11);
|
||||
nano::rep_weights rep_weights;
|
||||
std::atomic<uint64_t> cemented_count{ 0 };
|
||||
std::atomic<uint64_t> block_count_cache{ 0 };
|
||||
store.initialize (transaction, genesis, rep_weights, cemented_count, block_count_cache);
|
||||
nano::ledger_cache ledger_cache;
|
||||
store.initialize (transaction, genesis, ledger_cache);
|
||||
modify_account_info_to_v13 (store, transaction, nano::genesis_account, genesis.open->hash ());
|
||||
nano::block_sideband sideband;
|
||||
auto genesis_block (store.block_get (transaction, genesis.hash (), &sideband));
|
||||
|
@ -1204,7 +1190,7 @@ TEST (mdb_block_store, upgrade_sideband_two_blocks)
|
|||
nano::ledger ledger (store, stat);
|
||||
auto transaction (store.tx_begin_write ());
|
||||
store.version_put (transaction, 11);
|
||||
store.initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store.initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::state_block block (nano::test_genesis_key.pub, genesis.hash (), nano::test_genesis_key.pub, nano::genesis_amount - nano::Gxrb_ratio, nano::test_genesis_key.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
hash2 = block.hash ();
|
||||
|
@ -1247,7 +1233,7 @@ TEST (mdb_block_store, upgrade_sideband_two_accounts)
|
|||
nano::ledger ledger (store, stat);
|
||||
auto transaction (store.tx_begin_write ());
|
||||
store.version_put (transaction, 11);
|
||||
store.initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store.initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::state_block block1 (nano::test_genesis_key.pub, genesis.hash (), nano::test_genesis_key.pub, nano::genesis_amount - nano::Gxrb_ratio, key.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
hash2 = block1.hash ();
|
||||
|
@ -1294,7 +1280,7 @@ TEST (mdb_block_store, insert_after_legacy)
|
|||
nano::ledger ledger (store, stat);
|
||||
auto transaction (store.tx_begin_write ());
|
||||
store.version_put (transaction, 11);
|
||||
store.initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store.initialize (transaction, genesis, ledger.cache);
|
||||
mdb_dbi_open (store.env.tx (transaction), "state_v1", MDB_CREATE, &store.state_blocks_v1);
|
||||
write_sideband_v12 (store, transaction, *genesis.open, 0, store.open_blocks);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
|
@ -1312,7 +1298,7 @@ TEST (mdb_block_store, legacy_account_computed)
|
|||
nano::ledger ledger (store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store.tx_begin_write ());
|
||||
store.initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store.initialize (transaction, genesis, ledger.cache);
|
||||
store.version_put (transaction, 11);
|
||||
mdb_dbi_open (store.env.tx (transaction), "state_v1", MDB_CREATE, &store.state_blocks_v1);
|
||||
write_sideband_v12 (store, transaction, *genesis.open, 0, store.open_blocks);
|
||||
|
@ -1334,7 +1320,7 @@ TEST (mdb_block_store, upgrade_sideband_epoch)
|
|||
nano::ledger ledger (store, stat);
|
||||
auto transaction (store.tx_begin_write ());
|
||||
store.version_put (transaction, 11);
|
||||
store.initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store.initialize (transaction, genesis, ledger.cache);
|
||||
nano::state_block block1 (nano::test_genesis_key.pub, genesis.hash (), nano::test_genesis_key.pub, nano::genesis_amount, ledger.epoch_link (nano::epoch::epoch_1), nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
hash2 = block1.hash ();
|
||||
ASSERT_FALSE (mdb_dbi_open (store.env.tx (transaction), "state_v1", MDB_CREATE, &store.state_blocks_v1));
|
||||
|
@ -1381,7 +1367,7 @@ TEST (mdb_block_store, sideband_height)
|
|||
nano::stat stat;
|
||||
nano::ledger ledger (store, stat);
|
||||
auto transaction (store.tx_begin_write ());
|
||||
store.initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store.initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::send_block send (genesis.hash (), nano::test_genesis_key.pub, nano::genesis_amount - nano::Gxrb_ratio, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send).code);
|
||||
|
@ -1577,10 +1563,8 @@ TEST (mdb_block_store, upgrade_v13_v14)
|
|||
nano::genesis genesis;
|
||||
nano::mdb_store store (logger, path);
|
||||
auto transaction (store.tx_begin_write ());
|
||||
nano::rep_weights rep_weights;
|
||||
std::atomic<uint64_t> cemented_count{ 0 };
|
||||
std::atomic<uint64_t> block_count_cache{ 0 };
|
||||
store.initialize (transaction, genesis, rep_weights, cemented_count, block_count_cache);
|
||||
nano::ledger_cache ledger_cache;
|
||||
store.initialize (transaction, genesis, ledger_cache);
|
||||
nano::account_info account_info;
|
||||
ASSERT_FALSE (store.account_get (transaction, nano::genesis_account, account_info));
|
||||
uint64_t confirmation_height;
|
||||
|
@ -1638,7 +1622,7 @@ TEST (mdb_block_store, upgrade_v14_v15)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (store, stats);
|
||||
auto transaction (store.tx_begin_write ());
|
||||
store.initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store.initialize (transaction, genesis, ledger.cache);
|
||||
nano::account_info account_info;
|
||||
ASSERT_FALSE (store.account_get (transaction, nano::genesis_account, account_info));
|
||||
uint64_t confirmation_height;
|
||||
|
@ -1737,11 +1721,11 @@ TEST (mdb_block_store, upgrade_v15_v16)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (store, stats);
|
||||
auto transaction (store.tx_begin_write ());
|
||||
store.initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store.initialize (transaction, genesis, ledger.cache);
|
||||
// The representation table should get removed after, so readd it so that we can later confirm this actually happens
|
||||
auto txn = store.env.tx (transaction);
|
||||
ASSERT_FALSE (mdb_dbi_open (txn, "representation", MDB_CREATE, &store.representation));
|
||||
auto weight = ledger.rep_weights.representation_get (nano::genesis_account);
|
||||
auto weight = ledger.cache.rep_weights.representation_get (nano::genesis_account);
|
||||
ASSERT_EQ (MDB_SUCCESS, mdb_put (txn, store.representation, nano::mdb_val (nano::genesis_account), nano::mdb_val (nano::uint128_union (weight)), 0));
|
||||
// Lower the database to the previous version
|
||||
store.version_put (transaction, 15);
|
||||
|
@ -1852,10 +1836,8 @@ TEST (mdb_block_store, upgrade_confirmation_height_many)
|
|||
ASSERT_FALSE (error);
|
||||
auto transaction (store.tx_begin_write ());
|
||||
store.version_put (transaction, 13);
|
||||
nano::rep_weights rep_weights;
|
||||
std::atomic<uint64_t> cemented_count{ 0 };
|
||||
std::atomic<uint64_t> block_count_cache{ 0 };
|
||||
store.initialize (transaction, genesis, rep_weights, cemented_count, block_count_cache);
|
||||
nano::ledger_cache ledger_cache;
|
||||
store.initialize (transaction, genesis, ledger_cache);
|
||||
modify_account_info_to_v13 (store, transaction, nano::genesis_account, genesis.open->hash ());
|
||||
|
||||
// Add many accounts
|
||||
|
|
|
@ -425,7 +425,7 @@ TEST (confirmation_height, send_receive_between_2_accounts)
|
|||
|
||||
ASSERT_EQ (10, node->stats.count (nano::stat::type::confirmation_height, nano::stat::detail::blocks_confirmed, nano::stat::dir::in));
|
||||
ASSERT_EQ (10, node->stats.count (nano::stat::type::http_callback, nano::stat::detail::http_callback, nano::stat::dir::out));
|
||||
ASSERT_EQ (11, node->ledger.cemented_count);
|
||||
ASSERT_EQ (11, node->ledger.cache.cemented_count);
|
||||
}
|
||||
|
||||
TEST (confirmation_height, send_receive_self)
|
||||
|
@ -485,7 +485,7 @@ TEST (confirmation_height, send_receive_self)
|
|||
ASSERT_EQ (8, account_info.block_count);
|
||||
ASSERT_EQ (6, node->stats.count (nano::stat::type::confirmation_height, nano::stat::detail::blocks_confirmed, nano::stat::dir::in));
|
||||
ASSERT_EQ (6, node->stats.count (nano::stat::type::http_callback, nano::stat::detail::http_callback, nano::stat::dir::out));
|
||||
ASSERT_EQ (confirmation_height, node->ledger.cemented_count);
|
||||
ASSERT_EQ (confirmation_height, node->ledger.cache.cemented_count);
|
||||
}
|
||||
|
||||
TEST (confirmation_height, all_block_types)
|
||||
|
@ -590,7 +590,7 @@ TEST (confirmation_height, all_block_types)
|
|||
|
||||
ASSERT_EQ (15, node->stats.count (nano::stat::type::confirmation_height, nano::stat::detail::blocks_confirmed, nano::stat::dir::in));
|
||||
ASSERT_EQ (15, node->stats.count (nano::stat::type::http_callback, nano::stat::detail::http_callback, nano::stat::dir::out));
|
||||
ASSERT_EQ (16, node->ledger.cemented_count);
|
||||
ASSERT_EQ (16, node->ledger.cache.cemented_count);
|
||||
}
|
||||
|
||||
/* Bulk of the this test was taken from the node.fork_flip test */
|
||||
|
@ -772,7 +772,7 @@ TEST (confirmation_height, pending_observer_callbacks)
|
|||
// Confirm the callback is not called under this circumstance
|
||||
ASSERT_EQ (2, node->stats.count (nano::stat::type::confirmation_height, nano::stat::detail::blocks_confirmed, nano::stat::dir::in));
|
||||
ASSERT_EQ (0, node->stats.count (nano::stat::type::http_callback, nano::stat::detail::http_callback, nano::stat::dir::out));
|
||||
ASSERT_EQ (3, node->ledger.cemented_count);
|
||||
ASSERT_EQ (3, node->ledger.cache.cemented_count);
|
||||
}
|
||||
|
||||
TEST (confirmation_height, prioritize_frontiers)
|
||||
|
|
|
@ -42,7 +42,7 @@ TEST (ledger, genesis_balance)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
auto balance (ledger.account_balance (transaction, nano::genesis_account));
|
||||
ASSERT_EQ (nano::genesis_amount, balance);
|
||||
auto amount (ledger.amount (transaction, nano::genesis_account));
|
||||
|
@ -79,7 +79,7 @@ TEST (ledger, process_send)
|
|||
nano::ledger ledger (*store, stats);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
nano::genesis genesis;
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
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::test_genesis_key.pub, info1));
|
||||
|
@ -173,7 +173,7 @@ TEST (ledger, process_receive)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
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::test_genesis_key.pub, info1));
|
||||
|
@ -231,7 +231,7 @@ TEST (ledger, rollback_receiver)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
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::test_genesis_key.pub, info1));
|
||||
|
@ -270,7 +270,7 @@ TEST (ledger, rollback_representation)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::keypair key5;
|
||||
nano::change_block change1 (genesis.hash (), key5.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
|
@ -324,7 +324,7 @@ TEST (ledger, receive_rollback)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::send_block send (genesis.hash (), nano::test_genesis_key.pub, nano::genesis_amount - nano::Gxrb_ratio, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send).code);
|
||||
|
@ -342,7 +342,7 @@ TEST (ledger, process_duplicate)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
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::test_genesis_key.pub, info1));
|
||||
|
@ -365,7 +365,7 @@ TEST (ledger, representative_genesis)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
auto latest (ledger.latest (transaction, nano::test_genesis_key.pub));
|
||||
ASSERT_FALSE (latest.is_zero ());
|
||||
ASSERT_EQ (genesis.open->hash (), ledger.representative (transaction, latest));
|
||||
|
@ -380,7 +380,7 @@ TEST (ledger, weight)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
ASSERT_EQ (nano::genesis_amount, ledger.weight (nano::genesis_account));
|
||||
}
|
||||
|
||||
|
@ -394,7 +394,7 @@ TEST (ledger, representative_change)
|
|||
nano::keypair key2;
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
ASSERT_EQ (nano::genesis_amount, ledger.weight (nano::test_genesis_key.pub));
|
||||
ASSERT_EQ (0, ledger.weight (key2.pub));
|
||||
|
@ -434,7 +434,7 @@ TEST (ledger, send_fork)
|
|||
nano::keypair key3;
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
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::test_genesis_key.pub, info1));
|
||||
|
@ -455,7 +455,7 @@ TEST (ledger, receive_fork)
|
|||
nano::keypair key3;
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
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::test_genesis_key.pub, info1));
|
||||
|
@ -482,7 +482,7 @@ TEST (ledger, open_fork)
|
|||
nano::keypair key3;
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
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::test_genesis_key.pub, info1));
|
||||
|
@ -609,10 +609,10 @@ TEST (ledger, representation)
|
|||
ASSERT_TRUE (!store->init_error ());
|
||||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats);
|
||||
auto & rep_weights = ledger.rep_weights;
|
||||
auto & rep_weights = ledger.cache.rep_weights;
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
ASSERT_EQ (nano::genesis_amount, rep_weights.representation_get (nano::test_genesis_key.pub));
|
||||
nano::keypair key2;
|
||||
|
@ -686,7 +686,7 @@ TEST (ledger, double_open)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::keypair key2;
|
||||
nano::send_block send1 (genesis.hash (), key2.pub, 1, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
|
@ -706,7 +706,7 @@ TEST (ledger, double_receive)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::keypair key2;
|
||||
nano::send_block send1 (genesis.hash (), key2.pub, 1, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
|
@ -979,7 +979,7 @@ TEST (ledger, fail_change_old)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::keypair key1;
|
||||
nano::change_block block (genesis.hash (), key1.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
|
@ -998,7 +998,7 @@ TEST (ledger, fail_change_gap_previous)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::keypair key1;
|
||||
nano::change_block block (1, key1.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (nano::root (1)));
|
||||
|
@ -1015,7 +1015,7 @@ TEST (ledger, fail_change_bad_signature)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::keypair key1;
|
||||
nano::change_block block (genesis.hash (), key1.pub, nano::keypair ().prv, 0, *pool.generate (genesis.hash ()));
|
||||
|
@ -1032,7 +1032,7 @@ TEST (ledger, fail_change_fork)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::keypair key1;
|
||||
nano::change_block block1 (genesis.hash (), key1.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
|
@ -1053,7 +1053,7 @@ TEST (ledger, fail_send_old)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::keypair key1;
|
||||
nano::send_block block (genesis.hash (), key1.pub, 1, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
|
@ -1072,7 +1072,7 @@ TEST (ledger, fail_send_gap_previous)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::keypair key1;
|
||||
nano::send_block block (1, key1.pub, 1, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (nano::root (1)));
|
||||
|
@ -1089,7 +1089,7 @@ TEST (ledger, fail_send_bad_signature)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::keypair key1;
|
||||
nano::send_block block (genesis.hash (), key1.pub, 1, nano::keypair ().prv, 0, *pool.generate (genesis.hash ()));
|
||||
|
@ -1106,7 +1106,7 @@ TEST (ledger, fail_send_negative_spend)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::keypair key1;
|
||||
nano::send_block block1 (genesis.hash (), key1.pub, 1, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
|
@ -1125,7 +1125,7 @@ TEST (ledger, fail_send_fork)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::keypair key1;
|
||||
nano::send_block block1 (genesis.hash (), key1.pub, 1, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
|
@ -1144,7 +1144,7 @@ TEST (ledger, fail_open_old)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::keypair key1;
|
||||
nano::send_block block1 (genesis.hash (), key1.pub, 1, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
|
@ -1163,7 +1163,7 @@ TEST (ledger, fail_open_gap_source)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::keypair key1;
|
||||
nano::open_block block2 (1, 1, key1.pub, key1.prv, key1.pub, *pool.generate (key1.pub));
|
||||
|
@ -1180,7 +1180,7 @@ TEST (ledger, fail_open_bad_signature)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::keypair key1;
|
||||
nano::send_block block1 (genesis.hash (), key1.pub, 1, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
|
@ -1199,7 +1199,7 @@ TEST (ledger, fail_open_fork_previous)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::keypair key1;
|
||||
nano::send_block block1 (genesis.hash (), key1.pub, 1, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
|
@ -1221,7 +1221,7 @@ TEST (ledger, fail_open_account_mismatch)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::keypair key1;
|
||||
nano::send_block block1 (genesis.hash (), key1.pub, 1, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
|
@ -1240,7 +1240,7 @@ TEST (ledger, fail_receive_old)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::keypair key1;
|
||||
nano::send_block block1 (genesis.hash (), key1.pub, 1, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
|
@ -1263,7 +1263,7 @@ TEST (ledger, fail_receive_gap_source)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::keypair key1;
|
||||
nano::send_block block1 (genesis.hash (), key1.pub, 1, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
|
@ -1289,7 +1289,7 @@ TEST (ledger, fail_receive_overreceive)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::keypair key1;
|
||||
nano::send_block block1 (genesis.hash (), key1.pub, 1, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
|
@ -1312,7 +1312,7 @@ TEST (ledger, fail_receive_bad_signature)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::keypair key1;
|
||||
nano::send_block block1 (genesis.hash (), key1.pub, 1, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
|
@ -1338,7 +1338,7 @@ TEST (ledger, fail_receive_gap_previous_opened)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::keypair key1;
|
||||
nano::send_block block1 (genesis.hash (), key1.pub, 1, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
|
@ -1364,7 +1364,7 @@ TEST (ledger, fail_receive_gap_previous_unopened)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::keypair key1;
|
||||
nano::send_block block1 (genesis.hash (), key1.pub, 1, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
|
@ -1387,7 +1387,7 @@ TEST (ledger, fail_receive_fork_previous)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::keypair key1;
|
||||
nano::send_block block1 (genesis.hash (), key1.pub, 1, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
|
@ -1417,7 +1417,7 @@ TEST (ledger, fail_receive_received_source)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::keypair key1;
|
||||
nano::send_block block1 (genesis.hash (), key1.pub, 2, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
|
@ -1466,7 +1466,7 @@ TEST (ledger, latest_root)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::keypair key;
|
||||
ASSERT_EQ (key.pub, ledger.latest_root (transaction, key.pub));
|
||||
|
@ -1486,7 +1486,7 @@ TEST (ledger, change_representative_move_representation)
|
|||
nano::keypair key1;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
nano::genesis genesis;
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
auto hash1 (genesis.hash ());
|
||||
ASSERT_EQ (nano::genesis_amount, ledger.weight (nano::test_genesis_key.pub));
|
||||
|
@ -1511,7 +1511,7 @@ TEST (ledger, send_open_receive_rollback)
|
|||
nano::ledger ledger (*store, stats);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
nano::genesis genesis;
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
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::test_genesis_key.pub, info1));
|
||||
|
@ -1574,12 +1574,12 @@ TEST (ledger, bootstrap_rep_weight)
|
|||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
{
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
ASSERT_FALSE (store->account_get (transaction, nano::test_genesis_key.pub, info1));
|
||||
nano::send_block send (info1.head, key2.pub, std::numeric_limits<nano::uint128_t>::max () - 50, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (info1.head));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send).code);
|
||||
}
|
||||
ASSERT_EQ (2, ledger.block_count_cache);
|
||||
ASSERT_EQ (2, ledger.cache.block_count);
|
||||
{
|
||||
ledger.bootstrap_weight_max_blocks = 3;
|
||||
ledger.bootstrap_weights[key2.pub] = 1000;
|
||||
|
@ -1591,7 +1591,7 @@ TEST (ledger, bootstrap_rep_weight)
|
|||
nano::send_block send (info1.head, key2.pub, std::numeric_limits<nano::uint128_t>::max () - 100, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (info1.head));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send).code);
|
||||
}
|
||||
ASSERT_EQ (3, ledger.block_count_cache);
|
||||
ASSERT_EQ (3, ledger.cache.block_count);
|
||||
{
|
||||
auto transaction (store->tx_begin_read ());
|
||||
ASSERT_EQ (0, ledger.weight (key2.pub));
|
||||
|
@ -1607,7 +1607,7 @@ TEST (ledger, block_destination_source)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::keypair dest;
|
||||
nano::uint128_t balance (nano::genesis_amount);
|
||||
|
@ -1653,7 +1653,7 @@ TEST (ledger, state_account)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::state_block send1 (nano::genesis_account, genesis.hash (), nano::genesis_account, nano::genesis_amount - nano::Gxrb_ratio, nano::genesis_account, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code);
|
||||
|
@ -1669,7 +1669,7 @@ TEST (ledger, state_send_receive)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::state_block send1 (nano::genesis_account, genesis.hash (), nano::genesis_account, nano::genesis_amount - nano::Gxrb_ratio, nano::genesis_account, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code);
|
||||
|
@ -1702,7 +1702,7 @@ TEST (ledger, state_receive)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::send_block send1 (genesis.hash (), nano::genesis_account, nano::genesis_amount - nano::Gxrb_ratio, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code);
|
||||
|
@ -1733,7 +1733,7 @@ TEST (ledger, state_rep_change)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::keypair rep;
|
||||
nano::state_block change1 (nano::genesis_account, genesis.hash (), rep.pub, nano::genesis_amount, 0, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
|
@ -1757,7 +1757,7 @@ TEST (ledger, state_open)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::keypair destination;
|
||||
nano::state_block send1 (nano::genesis_account, genesis.hash (), nano::genesis_account, nano::genesis_amount - nano::Gxrb_ratio, destination.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
|
@ -1792,7 +1792,7 @@ TEST (ledger, send_after_state_fail)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::state_block send1 (nano::genesis_account, genesis.hash (), nano::genesis_account, nano::genesis_amount - nano::Gxrb_ratio, nano::genesis_account, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code);
|
||||
|
@ -1810,7 +1810,7 @@ TEST (ledger, receive_after_state_fail)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::state_block send1 (nano::genesis_account, genesis.hash (), nano::genesis_account, nano::genesis_amount - nano::Gxrb_ratio, nano::genesis_account, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code);
|
||||
|
@ -1828,7 +1828,7 @@ TEST (ledger, change_after_state_fail)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::state_block send1 (nano::genesis_account, genesis.hash (), nano::genesis_account, nano::genesis_amount - nano::Gxrb_ratio, nano::genesis_account, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code);
|
||||
|
@ -1846,7 +1846,7 @@ TEST (ledger, state_unreceivable_fail)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::send_block send1 (genesis.hash (), nano::genesis_account, nano::genesis_amount - nano::Gxrb_ratio, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code);
|
||||
|
@ -1870,7 +1870,7 @@ TEST (ledger, state_receive_bad_amount_fail)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::send_block send1 (genesis.hash (), nano::genesis_account, nano::genesis_amount - nano::Gxrb_ratio, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code);
|
||||
|
@ -1894,7 +1894,7 @@ TEST (ledger, state_no_link_amount_fail)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::state_block send1 (nano::genesis_account, genesis.hash (), nano::genesis_account, nano::genesis_amount - nano::Gxrb_ratio, nano::genesis_account, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code);
|
||||
|
@ -1912,7 +1912,7 @@ TEST (ledger, state_receive_wrong_account_fail)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::state_block send1 (nano::genesis_account, genesis.hash (), nano::genesis_account, nano::genesis_amount - nano::Gxrb_ratio, nano::genesis_account, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code);
|
||||
|
@ -1937,7 +1937,7 @@ TEST (ledger, state_open_state_fork)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::keypair destination;
|
||||
nano::state_block send1 (nano::genesis_account, genesis.hash (), nano::genesis_account, nano::genesis_amount - nano::Gxrb_ratio, destination.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
|
@ -1958,7 +1958,7 @@ TEST (ledger, state_state_open_fork)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::keypair destination;
|
||||
nano::state_block send1 (nano::genesis_account, genesis.hash (), nano::genesis_account, nano::genesis_amount - nano::Gxrb_ratio, destination.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
|
@ -1979,7 +1979,7 @@ TEST (ledger, state_open_previous_fail)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::keypair destination;
|
||||
nano::state_block send1 (nano::genesis_account, genesis.hash (), nano::genesis_account, nano::genesis_amount - nano::Gxrb_ratio, destination.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
|
@ -1997,7 +1997,7 @@ TEST (ledger, state_open_source_fail)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::keypair destination;
|
||||
nano::state_block send1 (nano::genesis_account, genesis.hash (), nano::genesis_account, nano::genesis_amount - nano::Gxrb_ratio, destination.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
|
@ -2015,7 +2015,7 @@ TEST (ledger, state_send_change)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::keypair rep;
|
||||
nano::state_block send1 (nano::genesis_account, genesis.hash (), rep.pub, nano::genesis_amount - nano::Gxrb_ratio, nano::genesis_account, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
|
@ -2039,7 +2039,7 @@ TEST (ledger, state_receive_change)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::state_block send1 (nano::genesis_account, genesis.hash (), nano::genesis_account, nano::genesis_amount - nano::Gxrb_ratio, nano::genesis_account, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code);
|
||||
|
@ -2072,7 +2072,7 @@ TEST (ledger, state_open_old)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::keypair destination;
|
||||
nano::state_block send1 (nano::genesis_account, genesis.hash (), nano::genesis_account, nano::genesis_amount - nano::Gxrb_ratio, destination.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
|
@ -2093,7 +2093,7 @@ TEST (ledger, state_receive_old)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::keypair destination;
|
||||
nano::state_block send1 (nano::genesis_account, genesis.hash (), nano::genesis_account, nano::genesis_amount - nano::Gxrb_ratio, destination.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
|
@ -2118,7 +2118,7 @@ TEST (ledger, state_rollback_send)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::state_block send1 (nano::genesis_account, genesis.hash (), nano::genesis_account, nano::genesis_amount - nano::Gxrb_ratio, nano::genesis_account, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code);
|
||||
|
@ -2149,7 +2149,7 @@ TEST (ledger, state_rollback_receive)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::state_block send1 (nano::genesis_account, genesis.hash (), nano::genesis_account, nano::genesis_amount - nano::Gxrb_ratio, nano::genesis_account, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code);
|
||||
|
@ -2175,7 +2175,7 @@ TEST (ledger, state_rollback_received_send)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::keypair key;
|
||||
nano::state_block send1 (nano::genesis_account, genesis.hash (), nano::genesis_account, nano::genesis_amount - nano::Gxrb_ratio, key.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
|
@ -2202,7 +2202,7 @@ TEST (ledger, state_rep_change_rollback)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::keypair rep;
|
||||
nano::state_block change1 (nano::genesis_account, genesis.hash (), rep.pub, nano::genesis_amount, 0, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
|
@ -2223,7 +2223,7 @@ TEST (ledger, state_open_rollback)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::keypair destination;
|
||||
nano::state_block send1 (nano::genesis_account, genesis.hash (), nano::genesis_account, nano::genesis_amount - nano::Gxrb_ratio, destination.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
|
@ -2249,7 +2249,7 @@ TEST (ledger, state_send_change_rollback)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::keypair rep;
|
||||
nano::state_block send1 (nano::genesis_account, genesis.hash (), rep.pub, nano::genesis_amount - nano::Gxrb_ratio, nano::genesis_account, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
|
@ -2270,7 +2270,7 @@ TEST (ledger, state_receive_change_rollback)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::state_block send1 (nano::genesis_account, genesis.hash (), nano::genesis_account, nano::genesis_amount - nano::Gxrb_ratio, nano::genesis_account, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code);
|
||||
|
@ -2293,7 +2293,7 @@ TEST (ledger, epoch_blocks_v1_general)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::keypair destination;
|
||||
nano::state_block epoch1 (nano::genesis_account, genesis.hash (), nano::genesis_account, nano::genesis_amount, ledger.epoch_link (nano::epoch::epoch_1), nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
|
@ -2339,7 +2339,7 @@ TEST (ledger, epoch_blocks_v2_general)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::keypair destination;
|
||||
nano::state_block epoch1 (nano::genesis_account, genesis.hash (), nano::genesis_account, nano::genesis_amount, ledger.epoch_link (nano::epoch::epoch_2), nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
|
@ -2393,7 +2393,7 @@ TEST (ledger, epoch_blocks_receive_upgrade)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::keypair destination;
|
||||
nano::state_block send1 (nano::genesis_account, genesis.hash (), nano::genesis_account, nano::genesis_amount - nano::Gxrb_ratio, destination.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
|
@ -2456,7 +2456,7 @@ TEST (ledger, epoch_blocks_fork)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::keypair destination;
|
||||
nano::send_block send1 (genesis.hash (), nano::account (0), nano::genesis_amount, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *pool.generate (genesis.hash ()));
|
||||
|
@ -2591,7 +2591,7 @@ TEST (ledger, could_fit)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::keypair destination;
|
||||
// Test legacy and state change blocks could_fit
|
||||
|
@ -2662,6 +2662,7 @@ TEST (ledger, unchecked_epoch)
|
|||
auto transaction (node1.store.tx_begin_read ());
|
||||
auto unchecked_count (node1.store.unchecked_count (transaction));
|
||||
ASSERT_EQ (unchecked_count, 1);
|
||||
ASSERT_EQ (unchecked_count, node1.ledger.cache.unchecked_count);
|
||||
auto blocks (node1.store.unchecked_get (transaction, epoch1->previous ()));
|
||||
ASSERT_EQ (blocks.size (), 1);
|
||||
ASSERT_EQ (blocks[0].verified, nano::signature_verification::valid_epoch);
|
||||
|
@ -2674,6 +2675,7 @@ TEST (ledger, unchecked_epoch)
|
|||
ASSERT_TRUE (node1.store.block_exists (transaction, epoch1->hash ()));
|
||||
auto unchecked_count (node1.store.unchecked_count (transaction));
|
||||
ASSERT_EQ (unchecked_count, 0);
|
||||
ASSERT_EQ (unchecked_count, node1.ledger.cache.unchecked_count);
|
||||
nano::account_info info;
|
||||
ASSERT_FALSE (node1.store.account_get (transaction, destination.pub, info));
|
||||
ASSERT_EQ (info.epoch (), nano::epoch::epoch_1);
|
||||
|
@ -2705,6 +2707,7 @@ TEST (ledger, unchecked_epoch_invalid)
|
|||
auto transaction (node1.store.tx_begin_read ());
|
||||
auto unchecked_count (node1.store.unchecked_count (transaction));
|
||||
ASSERT_EQ (unchecked_count, 2);
|
||||
ASSERT_EQ (unchecked_count, node1.ledger.cache.unchecked_count);
|
||||
auto blocks (node1.store.unchecked_get (transaction, epoch1->previous ()));
|
||||
ASSERT_EQ (blocks.size (), 2);
|
||||
ASSERT_EQ (blocks[0].verified, nano::signature_verification::valid);
|
||||
|
@ -2720,6 +2723,7 @@ TEST (ledger, unchecked_epoch_invalid)
|
|||
ASSERT_TRUE (node1.active.empty ());
|
||||
auto unchecked_count (node1.store.unchecked_count (transaction));
|
||||
ASSERT_EQ (unchecked_count, 0);
|
||||
ASSERT_EQ (unchecked_count, node1.ledger.cache.unchecked_count);
|
||||
nano::account_info info;
|
||||
ASSERT_FALSE (node1.store.account_get (transaction, destination.pub, info));
|
||||
ASSERT_NE (info.epoch (), nano::epoch::epoch_1);
|
||||
|
@ -2747,6 +2751,7 @@ TEST (ledger, unchecked_open)
|
|||
auto transaction (node1.store.tx_begin_read ());
|
||||
auto unchecked_count (node1.store.unchecked_count (transaction));
|
||||
ASSERT_EQ (unchecked_count, 1);
|
||||
ASSERT_EQ (unchecked_count, node1.ledger.cache.unchecked_count);
|
||||
auto blocks (node1.store.unchecked_get (transaction, open1->source ()));
|
||||
ASSERT_EQ (blocks.size (), 1);
|
||||
ASSERT_EQ (blocks[0].verified, nano::signature_verification::valid);
|
||||
|
@ -2758,6 +2763,7 @@ TEST (ledger, unchecked_open)
|
|||
ASSERT_TRUE (node1.store.block_exists (transaction, open1->hash ()));
|
||||
auto unchecked_count (node1.store.unchecked_count (transaction));
|
||||
ASSERT_EQ (unchecked_count, 0);
|
||||
ASSERT_EQ (unchecked_count, node1.ledger.cache.unchecked_count);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2783,6 +2789,7 @@ TEST (ledger, unchecked_receive)
|
|||
auto transaction (node1.store.tx_begin_read ());
|
||||
auto unchecked_count (node1.store.unchecked_count (transaction));
|
||||
ASSERT_EQ (unchecked_count, 1);
|
||||
ASSERT_EQ (unchecked_count, node1.ledger.cache.unchecked_count);
|
||||
auto blocks (node1.store.unchecked_get (transaction, receive1->previous ()));
|
||||
ASSERT_EQ (blocks.size (), 1);
|
||||
ASSERT_EQ (blocks[0].verified, nano::signature_verification::unknown);
|
||||
|
@ -2794,6 +2801,7 @@ TEST (ledger, unchecked_receive)
|
|||
auto transaction (node1.store.tx_begin_read ());
|
||||
auto unchecked_count (node1.store.unchecked_count (transaction));
|
||||
ASSERT_EQ (unchecked_count, 1);
|
||||
ASSERT_EQ (unchecked_count, node1.ledger.cache.unchecked_count);
|
||||
auto blocks (node1.store.unchecked_get (transaction, receive1->source ()));
|
||||
ASSERT_EQ (blocks.size (), 1);
|
||||
ASSERT_EQ (blocks[0].verified, nano::signature_verification::valid);
|
||||
|
@ -2805,6 +2813,7 @@ TEST (ledger, unchecked_receive)
|
|||
ASSERT_TRUE (node1.store.block_exists (transaction, receive1->hash ()));
|
||||
auto unchecked_count (node1.store.unchecked_count (transaction));
|
||||
ASSERT_EQ (unchecked_count, 0);
|
||||
ASSERT_EQ (unchecked_count, node1.ledger.cache.unchecked_count);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2817,7 +2826,7 @@ TEST (ledger, confirmation_height_not_updated)
|
|||
nano::ledger ledger (*store, stats);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
nano::genesis genesis;
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
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::test_genesis_key.pub, account_info));
|
||||
|
@ -2851,8 +2860,8 @@ TEST (ledger, zero_rep)
|
|||
.build ();
|
||||
auto transaction (system.nodes[0]->store.tx_begin_write ());
|
||||
ASSERT_EQ (nano::process_result::progress, system.nodes[0]->ledger.process (transaction, *block1).code);
|
||||
ASSERT_EQ (0, system.nodes[0]->ledger.rep_weights.representation_get (nano::test_genesis_key.pub));
|
||||
ASSERT_EQ (nano::genesis_amount, system.nodes[0]->ledger.rep_weights.representation_get (0));
|
||||
ASSERT_EQ (0, system.nodes[0]->ledger.cache.rep_weights.representation_get (nano::test_genesis_key.pub));
|
||||
ASSERT_EQ (nano::genesis_amount, system.nodes[0]->ledger.cache.rep_weights.representation_get (0));
|
||||
auto block2 = builder.state ()
|
||||
.account (nano::test_genesis_key.pub)
|
||||
.previous (block1->hash ())
|
||||
|
@ -2863,6 +2872,6 @@ TEST (ledger, zero_rep)
|
|||
.work (*system.work.generate (block1->hash ()))
|
||||
.build ();
|
||||
ASSERT_EQ (nano::process_result::progress, system.nodes[0]->ledger.process (transaction, *block2).code);
|
||||
ASSERT_EQ (nano::genesis_amount, system.nodes[0]->ledger.rep_weights.representation_get (nano::test_genesis_key.pub));
|
||||
ASSERT_EQ (0, system.nodes[0]->ledger.rep_weights.representation_get (0));
|
||||
ASSERT_EQ (nano::genesis_amount, system.nodes[0]->ledger.cache.rep_weights.representation_get (nano::test_genesis_key.pub));
|
||||
ASSERT_EQ (0, system.nodes[0]->ledger.cache.rep_weights.representation_get (0));
|
||||
}
|
||||
|
|
|
@ -265,13 +265,13 @@ TEST (node, auto_bootstrap)
|
|||
ASSERT_TRUE (node1->ledger.block_exists (send1->hash ()));
|
||||
// Wait block receive
|
||||
system.deadline_set (5s);
|
||||
while (node1->ledger.block_count_cache < 3)
|
||||
while (node1->ledger.cache.block_count < 3)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
// Confirmation for all blocks
|
||||
system.deadline_set (5s);
|
||||
while (node1->ledger.cemented_count < 3)
|
||||
while (node1->ledger.cache.cemented_count < 3)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
|
@ -3027,6 +3027,7 @@ TEST (node, unchecked_cleanup)
|
|||
auto transaction (node.store.tx_begin_read ());
|
||||
auto unchecked_count (node.store.unchecked_count (transaction));
|
||||
ASSERT_EQ (unchecked_count, 1);
|
||||
ASSERT_EQ (unchecked_count, node.ledger.cache.unchecked_count);
|
||||
}
|
||||
std::this_thread::sleep_for (std::chrono::seconds (1));
|
||||
node.unchecked_cleanup ();
|
||||
|
@ -3034,6 +3035,7 @@ TEST (node, unchecked_cleanup)
|
|||
auto transaction (node.store.tx_begin_read ());
|
||||
auto unchecked_count (node.store.unchecked_count (transaction));
|
||||
ASSERT_EQ (unchecked_count, 1);
|
||||
ASSERT_EQ (unchecked_count, node.ledger.cache.unchecked_count);
|
||||
}
|
||||
std::this_thread::sleep_for (std::chrono::seconds (2));
|
||||
node.unchecked_cleanup ();
|
||||
|
@ -3041,6 +3043,7 @@ TEST (node, unchecked_cleanup)
|
|||
auto transaction (node.store.tx_begin_read ());
|
||||
auto unchecked_count (node.store.unchecked_count (transaction));
|
||||
ASSERT_EQ (unchecked_count, 0);
|
||||
ASSERT_EQ (unchecked_count, node.ledger.cache.unchecked_count);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3057,11 +3060,9 @@ TEST (node, dont_write_lock_node)
|
|||
auto store = nano::make_store (logger, path, false, true);
|
||||
{
|
||||
nano::genesis genesis;
|
||||
nano::rep_weights rep_weights;
|
||||
std::atomic<uint64_t> cemented_count{ 0 };
|
||||
std::atomic<uint64_t> block_count_cache{ 0 };
|
||||
nano::ledger_cache ledger_cache;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, rep_weights, cemented_count, block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger_cache);
|
||||
}
|
||||
|
||||
// Hold write lock open until main thread is done needing it
|
||||
|
|
|
@ -22,7 +22,7 @@ TEST (processor_service, bad_send_signature)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
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::test_genesis_key.pub, info1));
|
||||
|
@ -41,7 +41,7 @@ TEST (processor_service, bad_receive_signature)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
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::test_genesis_key.pub, info1));
|
||||
|
|
|
@ -243,11 +243,11 @@ int main (int argc, char * const * argv)
|
|||
else if (vm.count ("debug_dump_representatives"))
|
||||
{
|
||||
auto node_flags = nano::inactive_node_flag_defaults ();
|
||||
node_flags.cache_representative_weights_from_frontiers = true;
|
||||
node_flags.generate_cache.reps = true;
|
||||
nano::inactive_node node (data_path, 24000, node_flags);
|
||||
auto transaction (node.node->store.tx_begin_read ());
|
||||
nano::uint128_t total;
|
||||
auto rep_amounts = node.node->ledger.rep_weights.get_rep_amounts ();
|
||||
auto rep_amounts = node.node->ledger.cache.rep_weights.get_rep_amounts ();
|
||||
std::map<nano::account, nano::uint128_t> ordered_reps (rep_amounts.begin (), rep_amounts.end ());
|
||||
for (auto const & rep : ordered_reps)
|
||||
{
|
||||
|
@ -1232,9 +1232,9 @@ int main (int argc, char * const * argv)
|
|||
else if (vm.count ("debug_cemented_block_count"))
|
||||
{
|
||||
auto node_flags = nano::inactive_node_flag_defaults ();
|
||||
node_flags.cache_cemented_count_from_frontiers = true;
|
||||
node_flags.generate_cache.cemented_count = true;
|
||||
nano::inactive_node node (data_path, 24000, node_flags);
|
||||
std::cout << "Total cemented block count: " << node.node->ledger.cemented_count << std::endl;
|
||||
std::cout << "Total cemented block count: " << node.node->ledger.cache.cemented_count << std::endl;
|
||||
}
|
||||
else if (vm.count ("debug_stacktrace"))
|
||||
{
|
||||
|
|
|
@ -313,8 +313,8 @@ void nano::active_transactions::request_confirm (nano::unique_lock<std::mutex> &
|
|||
// Due to the confirmation height processor working asynchronously and compressing several roots into one frontier, probably_unconfirmed_frontiers can be wrong
|
||||
{
|
||||
auto pending_confirmation_height_size (node.pending_confirmation_height.size ());
|
||||
bool probably_unconfirmed_frontiers (node.ledger.block_count_cache > node.ledger.cemented_count + roots.size () + pending_confirmation_height_size);
|
||||
bool bootstrap_weight_reached (node.ledger.block_count_cache >= node.ledger.bootstrap_weight_max_blocks);
|
||||
bool probably_unconfirmed_frontiers (node.ledger.cache.block_count > node.ledger.cache.cemented_count + roots.size () + pending_confirmation_height_size);
|
||||
bool bootstrap_weight_reached (node.ledger.cache.block_count >= node.ledger.bootstrap_weight_max_blocks);
|
||||
if (node.config.frontiers_confirmation != nano::frontiers_confirmation_mode::disabled && bootstrap_weight_reached && probably_unconfirmed_frontiers && pending_confirmation_height_size < confirmed_frontiers_max_pending_cut_off)
|
||||
{
|
||||
lock_a.unlock ();
|
||||
|
|
|
@ -411,6 +411,7 @@ nano::process_return nano::block_processor::process_one (nano::write_transaction
|
|||
info_a.modified = nano::seconds_since_epoch ();
|
||||
}
|
||||
node.store.unchecked_put (transaction_a, nano::unchecked_key (info_a.block->previous (), hash), info_a);
|
||||
++node.ledger.cache.unchecked_count;
|
||||
node.gap_cache.add (hash);
|
||||
break;
|
||||
}
|
||||
|
@ -426,6 +427,7 @@ nano::process_return nano::block_processor::process_one (nano::write_transaction
|
|||
info_a.modified = nano::seconds_since_epoch ();
|
||||
}
|
||||
node.store.unchecked_put (transaction_a, nano::unchecked_key (node.ledger.block_source (transaction_a, *(info_a.block)), hash), info_a);
|
||||
++node.ledger.cache.unchecked_count;
|
||||
node.gap_cache.add (hash);
|
||||
break;
|
||||
}
|
||||
|
@ -525,6 +527,7 @@ void nano::block_processor::queue_unchecked (nano::write_transaction const & tra
|
|||
if (!node.flags.fast_bootstrap)
|
||||
{
|
||||
node.store.unchecked_del (transaction_a, nano::unchecked_key (hash_a, info.block->hash ()));
|
||||
--node.ledger.cache.unchecked_count;
|
||||
}
|
||||
add (info);
|
||||
}
|
||||
|
|
|
@ -338,7 +338,7 @@ bool nano::confirmation_height_processor::write_pending (std::deque<conf_height_
|
|||
ledger.stats.add (nano::stat::type::confirmation_height, nano::stat::detail::blocks_confirmed, nano::stat::dir::in, pending.height - confirmation_height);
|
||||
assert (pending.num_blocks_confirmed == pending.height - confirmation_height);
|
||||
confirmation_height = pending.height;
|
||||
ledger.cemented_count += pending.num_blocks_confirmed;
|
||||
ledger.cache.cemented_count += pending.num_blocks_confirmed;
|
||||
ledger.store.confirmation_height_put (transaction, pending.account, confirmation_height);
|
||||
}
|
||||
total_pending_write_block_count -= pending.num_blocks_confirmed;
|
||||
|
|
|
@ -1212,8 +1212,8 @@ void nano::json_handler::block_count ()
|
|||
{
|
||||
auto transaction (node.store.tx_begin_read ());
|
||||
response_l.put ("count", std::to_string (node.store.block_count (transaction).sum ()));
|
||||
response_l.put ("unchecked", std::to_string (node.store.unchecked_count (transaction)));
|
||||
response_l.put ("cemented", std::to_string (node.ledger.cemented_count));
|
||||
response_l.put ("unchecked", std::to_string (node.ledger.cache.unchecked_count));
|
||||
response_l.put ("cemented", std::to_string (node.ledger.cache.cemented_count));
|
||||
response_errors ();
|
||||
}
|
||||
|
||||
|
@ -1873,7 +1873,7 @@ void nano::json_handler::confirmation_info ()
|
|||
if (i->second->hash () == ii->second.hash)
|
||||
{
|
||||
nano::account const & representative (ii->first);
|
||||
auto amount (node.ledger.rep_weights.representation_get (representative));
|
||||
auto amount (node.ledger.cache.rep_weights.representation_get (representative));
|
||||
representatives.emplace (std::move (amount), representative);
|
||||
}
|
||||
}
|
||||
|
@ -3439,7 +3439,7 @@ void nano::json_handler::representatives ()
|
|||
{
|
||||
const bool sorting = request.get<bool> ("sorting", false);
|
||||
boost::property_tree::ptree representatives;
|
||||
auto rep_amounts = node.ledger.rep_weights.get_rep_amounts ();
|
||||
auto rep_amounts = node.ledger.cache.rep_weights.get_rep_amounts ();
|
||||
if (!sorting) // Simple
|
||||
{
|
||||
std::map<nano::account, nano::uint128_t> ordered (rep_amounts.begin (), rep_amounts.end ());
|
||||
|
|
|
@ -125,7 +125,7 @@ store (*store_impl),
|
|||
wallets_store_impl (std::make_unique<nano::mdb_wallets_store> (application_path_a / "wallets.ldb", config_a.lmdb_max_dbs)),
|
||||
wallets_store (*wallets_store_impl),
|
||||
gap_cache (*this),
|
||||
ledger (store, stats, flags_a.cache_representative_weights_from_frontiers),
|
||||
ledger (store, stats, flags_a.generate_cache),
|
||||
checker (config.signature_checker_threads),
|
||||
network (*this, config.peering_port),
|
||||
bootstrap_initiator (*this),
|
||||
|
@ -395,7 +395,7 @@ startup_time (std::chrono::steady_clock::now ())
|
|||
release_assert (!flags.read_only);
|
||||
auto transaction (store.tx_begin_write ());
|
||||
// Store was empty meaning we just created it, add the genesis block
|
||||
store.initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store.initialize (transaction, genesis, ledger.cache);
|
||||
}
|
||||
|
||||
if (!ledger.block_exists (genesis.hash ()))
|
||||
|
@ -427,7 +427,7 @@ startup_time (std::chrono::steady_clock::now ())
|
|||
if (!nano::try_read (weight_stream, block_height))
|
||||
{
|
||||
auto max_blocks = (uint64_t)block_height.number ();
|
||||
use_bootstrap_weight = ledger.block_count_cache < max_blocks;
|
||||
use_bootstrap_weight = ledger.cache.block_count < max_blocks;
|
||||
if (use_bootstrap_weight)
|
||||
{
|
||||
ledger.bootstrap_weight_max_blocks = max_blocks;
|
||||
|
@ -913,7 +913,7 @@ void nano::node::unchecked_cleanup ()
|
|||
auto attempt (bootstrap_initiator.current_attempt ());
|
||||
bool long_attempt (attempt != nullptr && std::chrono::duration_cast<std::chrono::seconds> (std::chrono::steady_clock::now () - attempt->attempt_start).count () > config.unchecked_cutoff_time.count ());
|
||||
// Collect old unchecked keys
|
||||
if (!flags.disable_unchecked_cleanup && ledger.block_count_cache >= ledger.bootstrap_weight_max_blocks && !long_attempt)
|
||||
if (!flags.disable_unchecked_cleanup && ledger.cache.block_count >= ledger.bootstrap_weight_max_blocks && !long_attempt)
|
||||
{
|
||||
auto now (nano::seconds_since_epoch ());
|
||||
auto transaction (store.tx_begin_read ());
|
||||
|
@ -942,6 +942,7 @@ void nano::node::unchecked_cleanup ()
|
|||
auto key (cleaning_list.front ());
|
||||
cleaning_list.pop_front ();
|
||||
store.unchecked_del (transaction, key);
|
||||
--ledger.cache.unchecked_count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1372,8 +1373,9 @@ nano::node_flags const & nano::inactive_node_flag_defaults ()
|
|||
static nano::node_flags node_flags;
|
||||
node_flags.inactive_node = true;
|
||||
node_flags.read_only = true;
|
||||
node_flags.cache_representative_weights_from_frontiers = false;
|
||||
node_flags.cache_cemented_count_from_frontiers = false;
|
||||
node_flags.generate_cache.reps = false;
|
||||
node_flags.generate_cache.cemented_count = false;
|
||||
node_flags.generate_cache.unchecked_count = false;
|
||||
return node_flags;
|
||||
}
|
||||
|
||||
|
|
|
@ -124,10 +124,7 @@ public:
|
|||
bool disable_unchecked_drop{ true };
|
||||
bool fast_bootstrap{ false };
|
||||
bool read_only{ false };
|
||||
/** Whether to read all frontiers and construct the representative weights */
|
||||
bool cache_representative_weights_from_frontiers{ true };
|
||||
/** Whether to read all frontiers and construct the total cemented count */
|
||||
bool cache_cemented_count_from_frontiers{ true };
|
||||
nano::generate_cache generate_cache;
|
||||
bool inactive_node{ false };
|
||||
size_t sideband_batch_size{ 512 };
|
||||
size_t block_processor_batch_size{ 0 };
|
||||
|
|
|
@ -279,7 +279,6 @@ bool nano::rocksdb_store::is_caching_counts (nano::tables table_a) const
|
|||
switch (table_a)
|
||||
{
|
||||
case tables::accounts:
|
||||
case tables::unchecked:
|
||||
case tables::send_blocks:
|
||||
case tables::receive_blocks:
|
||||
case tables::open_blocks:
|
||||
|
@ -383,6 +382,13 @@ size_t nano::rocksdb_store::count (nano::transaction const & transaction_a, tabl
|
|||
++sum;
|
||||
}
|
||||
}
|
||||
else if (table_a == tables::unchecked)
|
||||
{
|
||||
for (auto i (unchecked_begin (transaction_a)), n (unchecked_end ()); i != n; ++i)
|
||||
{
|
||||
++sum;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return count (transaction_a, table_to_column_family (table_a));
|
||||
|
|
|
@ -281,7 +281,7 @@ void nano::vote_processor::calculate_weights ()
|
|||
representatives_2.clear ();
|
||||
representatives_3.clear ();
|
||||
auto supply (online_reps.online_stake ());
|
||||
auto rep_amounts = ledger.rep_weights.get_rep_amounts ();
|
||||
auto rep_amounts = ledger.cache.rep_weights.get_rep_amounts ();
|
||||
for (auto const & rep_amount : rep_amounts)
|
||||
{
|
||||
nano::account const & representative (rep_amount.first);
|
||||
|
|
|
@ -894,10 +894,9 @@ std::string nano_qt::status::text ()
|
|||
size_t unchecked (0);
|
||||
std::string count_string;
|
||||
{
|
||||
auto transaction (wallet.wallet_m->wallets.node.store.tx_begin_read ());
|
||||
auto size (wallet.wallet_m->wallets.node.store.block_count (transaction));
|
||||
unchecked = wallet.wallet_m->wallets.node.store.unchecked_count (transaction);
|
||||
count_string = std::to_string (size.sum ());
|
||||
auto size (wallet.wallet_m->wallets.node.ledger.cache.block_count.load ());
|
||||
unchecked = wallet.wallet_m->wallets.node.ledger.cache.unchecked_count;
|
||||
count_string = std::to_string (size);
|
||||
}
|
||||
|
||||
switch (*active.begin ())
|
||||
|
|
|
@ -481,7 +481,7 @@ TEST (history, short_text)
|
|||
nano::ledger ledger (store, system.nodes[0]->stats);
|
||||
{
|
||||
auto transaction (store.tx_begin_write ());
|
||||
store.initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store.initialize (transaction, genesis, ledger.cache);
|
||||
nano::keypair key;
|
||||
auto latest (ledger.latest (transaction, nano::test_genesis_key.pub));
|
||||
nano::send_block send (latest, nano::test_genesis_key.pub, 0, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (latest));
|
||||
|
|
|
@ -626,7 +626,7 @@ private:
|
|||
std::unique_ptr<nano::write_transaction_impl> impl;
|
||||
};
|
||||
|
||||
class rep_weights;
|
||||
class ledger_cache;
|
||||
|
||||
/**
|
||||
* Manages block storage and iteration
|
||||
|
@ -635,7 +635,7 @@ class block_store
|
|||
{
|
||||
public:
|
||||
virtual ~block_store () = default;
|
||||
virtual void initialize (nano::write_transaction const &, nano::genesis const &, nano::rep_weights &, std::atomic<uint64_t> &, std::atomic<uint64_t> &) = 0;
|
||||
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 &, nano::block_sideband const &) = 0;
|
||||
virtual nano::block_hash block_successor (nano::transaction const &, nano::block_hash const &) const = 0;
|
||||
virtual void block_successor_clear (nano::write_transaction const &, nano::block_hash const &) = 0;
|
||||
|
@ -683,9 +683,9 @@ public:
|
|||
virtual void unchecked_put (nano::write_transaction const &, nano::block_hash const &, std::shared_ptr<nano::block> const &) = 0;
|
||||
virtual std::vector<nano::unchecked_info> unchecked_get (nano::transaction const &, nano::block_hash const &) = 0;
|
||||
virtual void unchecked_del (nano::write_transaction const &, nano::unchecked_key const &) = 0;
|
||||
virtual nano::store_iterator<nano::unchecked_key, nano::unchecked_info> unchecked_begin (nano::transaction const &) = 0;
|
||||
virtual nano::store_iterator<nano::unchecked_key, nano::unchecked_info> unchecked_begin (nano::transaction const &, nano::unchecked_key const &) = 0;
|
||||
virtual nano::store_iterator<nano::unchecked_key, nano::unchecked_info> unchecked_end () = 0;
|
||||
virtual nano::store_iterator<nano::unchecked_key, nano::unchecked_info> unchecked_begin (nano::transaction const &) const = 0;
|
||||
virtual nano::store_iterator<nano::unchecked_key, nano::unchecked_info> unchecked_begin (nano::transaction const &, nano::unchecked_key const &) const = 0;
|
||||
virtual nano::store_iterator<nano::unchecked_key, nano::unchecked_info> unchecked_end () const = 0;
|
||||
virtual size_t unchecked_count (nano::transaction const &) = 0;
|
||||
|
||||
// Return latest vote for an account from store
|
||||
|
|
|
@ -27,17 +27,17 @@ public:
|
|||
* If using a different store version than the latest then you may need
|
||||
* to modify some of the objects in the store to be appropriate for the version before an upgrade.
|
||||
*/
|
||||
void initialize (nano::write_transaction const & transaction_a, nano::genesis const & genesis_a, nano::rep_weights & rep_weights, std::atomic<uint64_t> & cemented_count, std::atomic<uint64_t> & block_count_cache) override
|
||||
void initialize (nano::write_transaction const & transaction_a, nano::genesis const & genesis_a, nano::ledger_cache & ledge_cache_a) override
|
||||
{
|
||||
auto hash_l (genesis_a.hash ());
|
||||
assert (latest_begin (transaction_a) == latest_end ());
|
||||
nano::block_sideband sideband (nano::block_type::open, network_params.ledger.genesis_account, 0, network_params.ledger.genesis_amount, 1, nano::seconds_since_epoch (), nano::epoch::epoch_0);
|
||||
block_put (transaction_a, hash_l, *genesis_a.open, sideband);
|
||||
++block_count_cache;
|
||||
++ledge_cache_a.block_count;
|
||||
confirmation_height_put (transaction_a, network_params.ledger.genesis_account, 1);
|
||||
++cemented_count;
|
||||
++ledge_cache_a.cemented_count;
|
||||
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 });
|
||||
rep_weights.representation_put (network_params.ledger.genesis_account, std::numeric_limits<nano::uint128_t>::max ());
|
||||
ledge_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);
|
||||
}
|
||||
|
||||
|
@ -312,7 +312,7 @@ public:
|
|||
return result;
|
||||
}
|
||||
|
||||
nano::store_iterator<nano::unchecked_key, nano::unchecked_info> unchecked_end () override
|
||||
nano::store_iterator<nano::unchecked_key, nano::unchecked_info> unchecked_end () const override
|
||||
{
|
||||
return nano::store_iterator<nano::unchecked_key, nano::unchecked_info> (nullptr);
|
||||
}
|
||||
|
@ -726,12 +726,12 @@ public:
|
|||
return make_iterator<nano::pending_key, nano::pending_info> (transaction_a, tables::pending);
|
||||
}
|
||||
|
||||
nano::store_iterator<nano::unchecked_key, nano::unchecked_info> unchecked_begin (nano::transaction const & transaction_a) override
|
||||
nano::store_iterator<nano::unchecked_key, nano::unchecked_info> unchecked_begin (nano::transaction const & transaction_a) const override
|
||||
{
|
||||
return make_iterator<nano::unchecked_key, nano::unchecked_info> (transaction_a, tables::unchecked);
|
||||
}
|
||||
|
||||
nano::store_iterator<nano::unchecked_key, nano::unchecked_info> unchecked_begin (nano::transaction const & transaction_a, nano::unchecked_key const & key_a) override
|
||||
nano::store_iterator<nano::unchecked_key, nano::unchecked_info> unchecked_begin (nano::transaction const & transaction_a, nano::unchecked_key const & key_a) const override
|
||||
{
|
||||
return make_iterator<nano::unchecked_key, nano::unchecked_info> (transaction_a, tables::unchecked, nano::db_val<Val> (key_a));
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <nano/lib/blocks.hpp>
|
||||
#include <nano/lib/config.hpp>
|
||||
#include <nano/lib/numbers.hpp>
|
||||
#include <nano/lib/rep_weights.hpp>
|
||||
#include <nano/lib/utility.hpp>
|
||||
#include <nano/secure/epoch.hpp>
|
||||
|
||||
|
@ -452,5 +453,25 @@ public:
|
|||
bootstrap_constants bootstrap;
|
||||
};
|
||||
|
||||
/* Holds flags for various cacheable data. For most CLI operations caching is unnecessary
|
||||
* (e.g getting the checked block count) so it can be disabled for performance reasons. */
|
||||
class generate_cache
|
||||
{
|
||||
public:
|
||||
bool reps = true;
|
||||
bool cemented_count = true;
|
||||
bool unchecked_count = true;
|
||||
};
|
||||
|
||||
/* Holds an in-memory cache of various counts */
|
||||
class ledger_cache
|
||||
{
|
||||
public:
|
||||
nano::rep_weights rep_weights;
|
||||
std::atomic<uint64_t> cemented_count{ 0 };
|
||||
std::atomic<uint64_t> block_count{ 0 };
|
||||
std::atomic<uint64_t> unchecked_count{ 0 };
|
||||
};
|
||||
|
||||
nano::wallet_id random_wallet_id ();
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ public:
|
|||
(void)error;
|
||||
assert (!error);
|
||||
ledger.store.pending_del (transaction, key);
|
||||
ledger.rep_weights.representation_add (info.representative, pending.amount.number ());
|
||||
ledger.cache.rep_weights.representation_add (info.representative, pending.amount.number ());
|
||||
nano::account_info new_info (block_a.hashables.previous, info.representative, info.open_block, ledger.balance (transaction, block_a.hashables.previous), nano::seconds_since_epoch (), info.block_count - 1, nano::epoch::epoch_0);
|
||||
ledger.change_latest (transaction, pending.source, info, new_info);
|
||||
ledger.store.block_del (transaction, hash, block_a.type ());
|
||||
|
@ -56,7 +56,7 @@ public:
|
|||
auto error (ledger.store.account_get (transaction, destination_account, info));
|
||||
(void)error;
|
||||
assert (!error);
|
||||
ledger.rep_weights.representation_add (info.representative, 0 - amount);
|
||||
ledger.cache.rep_weights.representation_add (info.representative, 0 - amount);
|
||||
nano::account_info new_info (block_a.hashables.previous, info.representative, info.open_block, ledger.balance (transaction, block_a.hashables.previous), nano::seconds_since_epoch (), info.block_count - 1, nano::epoch::epoch_0);
|
||||
ledger.change_latest (transaction, destination_account, info, new_info);
|
||||
ledger.store.block_del (transaction, hash, block_a.type ());
|
||||
|
@ -72,7 +72,7 @@ public:
|
|||
auto amount (ledger.amount (transaction, block_a.hashables.source));
|
||||
auto destination_account (ledger.account (transaction, hash));
|
||||
auto source_account (ledger.account (transaction, block_a.hashables.source));
|
||||
ledger.rep_weights.representation_add (block_a.representative (), 0 - amount);
|
||||
ledger.cache.rep_weights.representation_add (block_a.representative (), 0 - amount);
|
||||
nano::account_info new_info;
|
||||
ledger.change_latest (transaction, destination_account, new_info, new_info);
|
||||
ledger.store.block_del (transaction, hash, block_a.type ());
|
||||
|
@ -93,8 +93,8 @@ public:
|
|||
auto block = ledger.store.block_get (transaction, rep_block);
|
||||
release_assert (block != nullptr);
|
||||
auto representative = block->representative ();
|
||||
ledger.rep_weights.representation_add (block_a.representative (), 0 - balance);
|
||||
ledger.rep_weights.representation_add (representative, balance);
|
||||
ledger.cache.rep_weights.representation_add (block_a.representative (), 0 - balance);
|
||||
ledger.cache.rep_weights.representation_add (representative, balance);
|
||||
ledger.store.block_del (transaction, hash, block_a.type ());
|
||||
nano::account_info new_info (block_a.hashables.previous, representative, info.open_block, info.balance, nano::seconds_since_epoch (), info.block_count - 1, nano::epoch::epoch_0);
|
||||
ledger.change_latest (transaction, account, info, new_info);
|
||||
|
@ -114,7 +114,7 @@ public:
|
|||
auto balance (ledger.balance (transaction, block_a.hashables.previous));
|
||||
auto is_send (block_a.hashables.balance < balance);
|
||||
// Add in amount delta
|
||||
ledger.rep_weights.representation_add (block_a.representative (), 0 - block_a.hashables.balance.number ());
|
||||
ledger.cache.rep_weights.representation_add (block_a.representative (), 0 - block_a.hashables.balance.number ());
|
||||
nano::account representative{ 0 };
|
||||
if (!rep_block_hash.is_zero ())
|
||||
{
|
||||
|
@ -122,7 +122,7 @@ public:
|
|||
auto block (ledger.store.block_get (transaction, rep_block_hash));
|
||||
assert (block != nullptr);
|
||||
representative = block->representative ();
|
||||
ledger.rep_weights.representation_add (representative, balance);
|
||||
ledger.cache.rep_weights.representation_add (representative, balance);
|
||||
}
|
||||
|
||||
nano::account_info info;
|
||||
|
@ -338,10 +338,10 @@ void ledger_processor::state_block_impl (nano::state_block const & block_a)
|
|||
if (!info.head.is_zero ())
|
||||
{
|
||||
// Move existing representation
|
||||
ledger.rep_weights.representation_add (info.representative, 0 - info.balance.number ());
|
||||
ledger.cache.rep_weights.representation_add (info.representative, 0 - info.balance.number ());
|
||||
}
|
||||
// Add in amount delta
|
||||
ledger.rep_weights.representation_add (block_a.representative (), block_a.hashables.balance.number ());
|
||||
ledger.cache.rep_weights.representation_add (block_a.representative (), block_a.hashables.balance.number ());
|
||||
|
||||
if (is_send)
|
||||
{
|
||||
|
@ -471,8 +471,8 @@ void ledger_processor::change_block (nano::change_block const & block_a)
|
|||
nano::block_sideband sideband (nano::block_type::change, account, 0, info.balance, info.block_count + 1, nano::seconds_since_epoch (), nano::epoch::epoch_0);
|
||||
ledger.store.block_put (transaction, hash, block_a, sideband);
|
||||
auto balance (ledger.balance (transaction, block_a.hashables.previous));
|
||||
ledger.rep_weights.representation_add (block_a.representative (), balance);
|
||||
ledger.rep_weights.representation_add (info.representative, 0 - balance);
|
||||
ledger.cache.rep_weights.representation_add (block_a.representative (), balance);
|
||||
ledger.cache.rep_weights.representation_add (info.representative, 0 - balance);
|
||||
nano::account_info new_info (hash, block_a.representative (), info.open_block, info.balance, nano::seconds_since_epoch (), info.block_count + 1, nano::epoch::epoch_0);
|
||||
ledger.change_latest (transaction, account, info, new_info);
|
||||
ledger.store.frontier_del (transaction, block_a.hashables.previous);
|
||||
|
@ -523,7 +523,7 @@ void ledger_processor::send_block (nano::send_block const & block_a)
|
|||
if (result.code == nano::process_result::progress)
|
||||
{
|
||||
auto amount (info.balance.number () - block_a.hashables.balance.number ());
|
||||
ledger.rep_weights.representation_add (info.representative, 0 - amount);
|
||||
ledger.cache.rep_weights.representation_add (info.representative, 0 - amount);
|
||||
nano::block_sideband sideband (nano::block_type::send, account, 0, block_a.hashables.balance /* unused */, info.block_count + 1, nano::seconds_since_epoch (), nano::epoch::epoch_0);
|
||||
ledger.store.block_put (transaction, hash, block_a, sideband);
|
||||
nano::account_info new_info (hash, info.representative, info.open_block, block_a.hashables.balance, nano::seconds_since_epoch (), info.block_count + 1, nano::epoch::epoch_0);
|
||||
|
@ -596,7 +596,7 @@ void ledger_processor::receive_block (nano::receive_block const & block_a)
|
|||
ledger.store.block_put (transaction, hash, block_a, sideband);
|
||||
nano::account_info new_info (hash, info.representative, info.open_block, new_balance, nano::seconds_since_epoch (), info.block_count + 1, nano::epoch::epoch_0);
|
||||
ledger.change_latest (transaction, account, info, new_info);
|
||||
ledger.rep_weights.representation_add (info.representative, pending.amount.number ());
|
||||
ledger.cache.rep_weights.representation_add (info.representative, pending.amount.number ());
|
||||
ledger.store.frontier_del (transaction, block_a.hashables.previous);
|
||||
ledger.store.frontier_put (transaction, hash, account);
|
||||
result.account = account;
|
||||
|
@ -660,7 +660,7 @@ void ledger_processor::open_block (nano::open_block const & block_a)
|
|||
ledger.store.block_put (transaction, hash, block_a, sideband);
|
||||
nano::account_info new_info (hash, block_a.representative (), hash, pending.amount.number (), nano::seconds_since_epoch (), 1, nano::epoch::epoch_0);
|
||||
ledger.change_latest (transaction, block_a.hashables.account, info, new_info);
|
||||
ledger.rep_weights.representation_add (block_a.representative (), pending.amount.number ());
|
||||
ledger.cache.rep_weights.representation_add (block_a.representative (), pending.amount.number ());
|
||||
ledger.store.frontier_put (transaction, hash, block_a.hashables.account);
|
||||
result.account = block_a.hashables.account;
|
||||
result.amount = pending.amount;
|
||||
|
@ -683,7 +683,7 @@ verification (verification_a)
|
|||
}
|
||||
} // namespace
|
||||
|
||||
nano::ledger::ledger (nano::block_store & store_a, nano::stat & stat_a, bool cache_reps_a, bool cache_cemented_count_a) :
|
||||
nano::ledger::ledger (nano::block_store & store_a, nano::stat & stat_a, nano::generate_cache const & generate_cache_a) :
|
||||
store (store_a),
|
||||
stats (stat_a),
|
||||
check_bootstrap_weights (true)
|
||||
|
@ -691,25 +691,29 @@ check_bootstrap_weights (true)
|
|||
if (!store.init_error ())
|
||||
{
|
||||
auto transaction = store.tx_begin_read ();
|
||||
if (cache_reps_a)
|
||||
if (generate_cache_a.reps)
|
||||
{
|
||||
for (auto i (store.latest_begin (transaction)), n (store.latest_end ()); i != n; ++i)
|
||||
{
|
||||
nano::account_info const & info (i->second);
|
||||
rep_weights.representation_add (info.representative, info.balance.number ());
|
||||
cache.rep_weights.representation_add (info.representative, info.balance.number ());
|
||||
}
|
||||
}
|
||||
|
||||
if (cache_cemented_count_a)
|
||||
if (generate_cache_a.cemented_count)
|
||||
{
|
||||
for (auto i (store.confirmation_height_begin (transaction)), n (store.confirmation_height_end ()); i != n; ++i)
|
||||
{
|
||||
cemented_count += i->second;
|
||||
cache.cemented_count += i->second;
|
||||
}
|
||||
}
|
||||
|
||||
// Cache block count
|
||||
block_count_cache = store.block_count (transaction).sum ();
|
||||
if (generate_cache_a.unchecked_count)
|
||||
{
|
||||
cache.unchecked_count = store.unchecked_count (transaction);
|
||||
}
|
||||
|
||||
cache.block_count = store.block_count (transaction).sum ();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -751,7 +755,7 @@ nano::process_return nano::ledger::process (nano::write_transaction const & tran
|
|||
block_a.visit (processor);
|
||||
if (processor.result.code == nano::process_result::progress)
|
||||
{
|
||||
++block_count_cache;
|
||||
++cache.block_count;
|
||||
}
|
||||
return processor.result;
|
||||
}
|
||||
|
@ -856,7 +860,7 @@ nano::uint128_t nano::ledger::weight (nano::account const & account_a)
|
|||
{
|
||||
if (check_bootstrap_weights.load ())
|
||||
{
|
||||
if (block_count_cache < bootstrap_weight_max_blocks)
|
||||
if (cache.block_count < bootstrap_weight_max_blocks)
|
||||
{
|
||||
auto weight = bootstrap_weights.find (account_a);
|
||||
if (weight != bootstrap_weights.end ())
|
||||
|
@ -869,7 +873,7 @@ nano::uint128_t nano::ledger::weight (nano::account const & account_a)
|
|||
check_bootstrap_weights = false;
|
||||
}
|
||||
}
|
||||
return rep_weights.representation_get (account_a);
|
||||
return cache.rep_weights.representation_get (account_a);
|
||||
}
|
||||
|
||||
// Rollback blocks until `block_a' doesn't exist or it tries to penetrate the confirmation height
|
||||
|
@ -897,7 +901,7 @@ bool nano::ledger::rollback (nano::write_transaction const & transaction_a, nano
|
|||
error = rollback.error;
|
||||
if (!error)
|
||||
{
|
||||
--block_count_cache;
|
||||
--cache.block_count;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1139,7 +1143,7 @@ std::unique_ptr<seq_con_info_component> collect_seq_con_info (ledger & ledger, c
|
|||
auto count = ledger.bootstrap_weights_size.load ();
|
||||
auto sizeof_element = sizeof (decltype (ledger.bootstrap_weights)::value_type);
|
||||
composite->add_component (std::make_unique<seq_con_info_leaf> (seq_con_info{ "bootstrap_weights", count, sizeof_element }));
|
||||
composite->add_component (collect_seq_con_info (ledger.rep_weights, "rep_weights"));
|
||||
composite->add_component (collect_seq_con_info (ledger.cache.rep_weights, "rep_weights"));
|
||||
return composite;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ using tally_t = std::map<nano::uint128_t, std::shared_ptr<nano::block>, std::gre
|
|||
class ledger final
|
||||
{
|
||||
public:
|
||||
ledger (nano::block_store &, nano::stat &, bool = true, bool = true);
|
||||
ledger (nano::block_store &, nano::stat &, nano::generate_cache const & = nano::generate_cache());
|
||||
nano::account account (nano::transaction const &, nano::block_hash const &) const;
|
||||
nano::uint128_t amount (nano::transaction const &, nano::account const &);
|
||||
nano::uint128_t amount (nano::transaction const &, nano::block_hash const &);
|
||||
|
@ -50,9 +50,7 @@ public:
|
|||
static nano::uint128_t const unit;
|
||||
nano::network_params network_params;
|
||||
nano::block_store & store;
|
||||
std::atomic<uint64_t> cemented_count{ 0 };
|
||||
std::atomic<uint64_t> block_count_cache{ 0 };
|
||||
nano::rep_weights rep_weights;
|
||||
nano::ledger_cache cache;
|
||||
nano::stat & stats;
|
||||
std::unordered_map<nano::account, nano::uint128_t> bootstrap_weights;
|
||||
std::atomic<size_t> bootstrap_weights_size{ 0 };
|
||||
|
|
|
@ -95,7 +95,7 @@ TEST (ledger, deep_account_compute)
|
|||
nano::ledger ledger (*store, stats);
|
||||
nano::genesis genesis;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, genesis, ledger.rep_weights, ledger.cemented_count, ledger.block_count_cache);
|
||||
store->initialize (transaction, genesis, ledger.cache);
|
||||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::keypair key;
|
||||
auto balance (nano::genesis_amount - 1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue