diff --git a/nano/core_test/block_store.cpp b/nano/core_test/block_store.cpp index ba4abd95df..f21771636e 100644 --- a/nano/core_test/block_store.cpp +++ b/nano/core_test/block_store.cpp @@ -242,13 +242,13 @@ TEST (block_store, add_pending) nano::pending_key key2 (0, 0); nano::pending_info pending1; auto transaction (store->tx_begin_write ()); - ASSERT_TRUE (store->pending_get (transaction, key2, pending1)); - store->pending_put (transaction, key2, pending1); + ASSERT_TRUE (store->pending.get (transaction, key2, pending1)); + store->pending.put (transaction, key2, pending1); nano::pending_info pending2; - ASSERT_FALSE (store->pending_get (transaction, key2, pending2)); + ASSERT_FALSE (store->pending.get (transaction, key2, pending2)); ASSERT_EQ (pending1, pending2); - store->pending_del (transaction, key2); - ASSERT_TRUE (store->pending_get (transaction, key2, pending2)); + store->pending.del (transaction, key2); + ASSERT_TRUE (store->pending.get (transaction, key2, pending2)); } TEST (block_store, pending_iterator) @@ -257,10 +257,10 @@ TEST (block_store, pending_iterator) auto store = nano::make_store (logger, nano::unique_path ()); ASSERT_TRUE (!store->init_error ()); auto transaction (store->tx_begin_write ()); - ASSERT_EQ (store->pending_end (), store->pending_begin (transaction)); - store->pending_put (transaction, nano::pending_key (1, 2), { 2, 3, nano::epoch::epoch_1 }); - auto current (store->pending_begin (transaction)); - ASSERT_NE (store->pending_end (), current); + ASSERT_EQ (store->pending.end (), store->pending.begin (transaction)); + store->pending.put (transaction, nano::pending_key (1, 2), { 2, 3, nano::epoch::epoch_1 }); + auto current (store->pending.begin (transaction)); + ASSERT_NE (store->pending.end (), current); nano::pending_key key1 (current->first); ASSERT_EQ (nano::account (1), key1.account); ASSERT_EQ (nano::block_hash (2), key1.hash); @@ -284,18 +284,18 @@ TEST (block_store, pending_iterator_comparison) nano::stat stats; auto transaction (store->tx_begin_write ()); // Populate pending - store->pending_put (transaction, nano::pending_key (nano::account (3), nano::block_hash (1)), nano::pending_info (nano::account (10), nano::amount (1), nano::epoch::epoch_0)); - store->pending_put (transaction, nano::pending_key (nano::account (3), nano::block_hash (4)), nano::pending_info (nano::account (10), nano::amount (0), nano::epoch::epoch_0)); + store->pending.put (transaction, nano::pending_key (nano::account (3), nano::block_hash (1)), nano::pending_info (nano::account (10), nano::amount (1), nano::epoch::epoch_0)); + store->pending.put (transaction, nano::pending_key (nano::account (3), nano::block_hash (4)), nano::pending_info (nano::account (10), nano::amount (0), nano::epoch::epoch_0)); // Populate pending_v1 - store->pending_put (transaction, nano::pending_key (nano::account (2), nano::block_hash (2)), nano::pending_info (nano::account (10), nano::amount (2), nano::epoch::epoch_1)); - store->pending_put (transaction, nano::pending_key (nano::account (2), nano::block_hash (3)), nano::pending_info (nano::account (10), nano::amount (3), nano::epoch::epoch_1)); + store->pending.put (transaction, nano::pending_key (nano::account (2), nano::block_hash (2)), nano::pending_info (nano::account (10), nano::amount (2), nano::epoch::epoch_1)); + store->pending.put (transaction, nano::pending_key (nano::account (2), nano::block_hash (3)), nano::pending_info (nano::account (10), nano::amount (3), nano::epoch::epoch_1)); // Iterate account 3 (pending) { size_t count = 0; nano::account begin (3); nano::account end (begin.number () + 1); - for (auto i (store->pending_begin (transaction, nano::pending_key (begin, 0))), n (store->pending_begin (transaction, nano::pending_key (end, 0))); i != n; ++i, ++count) + for (auto i (store->pending.begin (transaction, nano::pending_key (begin, 0))), n (store->pending.begin (transaction, nano::pending_key (end, 0))); i != n; ++i, ++count) { nano::pending_key key (i->first); ASSERT_EQ (key.account, begin); @@ -309,7 +309,7 @@ TEST (block_store, pending_iterator_comparison) size_t count = 0; nano::account begin (2); nano::account end (begin.number () + 1); - for (auto i (store->pending_begin (transaction, nano::pending_key (begin, 0))), n (store->pending_begin (transaction, nano::pending_key (end, 0))); i != n; ++i, ++count) + for (auto i (store->pending.begin (transaction, nano::pending_key (begin, 0))), n (store->pending.begin (transaction, nano::pending_key (end, 0))); i != n; ++i, ++count) { nano::pending_key key (i->first); ASSERT_EQ (key.account, begin); @@ -751,9 +751,9 @@ TEST (block_store, pending_exists) nano::pending_key two (2, 0); nano::pending_info pending; auto transaction (store->tx_begin_write ()); - store->pending_put (transaction, two, pending); + store->pending.put (transaction, two, pending); nano::pending_key one (1, 0); - ASSERT_FALSE (store->pending_exists (transaction, one)); + ASSERT_FALSE (store->pending.exists (transaction, one)); } TEST (block_store, latest_exists) @@ -1305,7 +1305,7 @@ TEST (mdb_block_store, upgrade_v14_v15) store.confirmation_height_del (transaction, nano::genesis_account); modify_account_info_to_v14 (store, transaction, nano::genesis_account, confirmation_height_info.height, state_send.hash ()); - store.pending_del (transaction, nano::pending_key (nano::genesis_account, state_send.hash ())); + store.pending.del (transaction, nano::pending_key (nano::genesis_account, state_send.hash ())); write_sideband_v14 (store, transaction, state_send, store.state_blocks_v1); write_sideband_v14 (store, transaction, epoch, store.state_blocks_v1); @@ -1366,9 +1366,9 @@ TEST (mdb_block_store, upgrade_v14_v15) ASSERT_EQ (block->sideband ().details.epoch, nano::epoch::epoch_0); ASSERT_EQ (info.epoch (), nano::epoch::epoch_1); nano::pending_info pending_info; - store.pending_get (transaction, nano::pending_key (nano::dev_genesis_key.pub, send.hash ()), pending_info); + store.pending.get (transaction, nano::pending_key (nano::dev_genesis_key.pub, send.hash ()), pending_info); ASSERT_EQ (pending_info.epoch, nano::epoch::epoch_0); - store.pending_get (transaction, nano::pending_key (nano::dev_genesis_key.pub, state_send.hash ()), pending_info); + store.pending.get (transaction, nano::pending_key (nano::dev_genesis_key.pub, state_send.hash ()), pending_info); ASSERT_EQ (pending_info.epoch, nano::epoch::epoch_1); // Version should be correct diff --git a/nano/core_test/ledger.cpp b/nano/core_test/ledger.cpp index 6041b8fa70..bf5e6591ae 100644 --- a/nano/core_test/ledger.cpp +++ b/nano/core_test/ledger.cpp @@ -167,7 +167,7 @@ TEST (ledger, process_send) nano::account_info info5; ASSERT_TRUE (ledger.store.account_get (transaction, key2.pub, info5)); nano::pending_info pending1; - ASSERT_FALSE (ledger.store.pending_get (transaction, nano::pending_key (key2.pub, hash1), pending1)); + ASSERT_FALSE (ledger.store.pending.get (transaction, nano::pending_key (key2.pub, hash1), pending1)); ASSERT_EQ (nano::dev_genesis_key.pub, pending1.source); ASSERT_EQ (nano::genesis_amount - 50, pending1.amount.number ()); ASSERT_EQ (0, ledger.account_balance (transaction, key2.pub)); @@ -187,7 +187,7 @@ TEST (ledger, process_send) ASSERT_EQ (1, info7.block_count); ASSERT_EQ (info1.head, info7.head); nano::pending_info pending2; - ASSERT_TRUE (ledger.store.pending_get (transaction, nano::pending_key (key2.pub, hash1), pending2)); + ASSERT_TRUE (ledger.store.pending.get (transaction, nano::pending_key (key2.pub, hash1), pending2)); ASSERT_EQ (nano::genesis_amount, ledger.account_balance (transaction, nano::dev_genesis_key.pub)); ASSERT_EQ (0, ledger.account_pending (transaction, key2.pub)); ASSERT_EQ (store->account_count (transaction), ledger.cache.account_count); @@ -251,7 +251,7 @@ TEST (ledger, process_receive) ASSERT_EQ (nano::genesis_amount - 50, ledger.weight (key3.pub)); ASSERT_EQ (hash2, ledger.latest (transaction, key2.pub)); nano::pending_info pending1; - ASSERT_FALSE (ledger.store.pending_get (transaction, nano::pending_key (key2.pub, hash3), pending1)); + ASSERT_FALSE (ledger.store.pending.get (transaction, nano::pending_key (key2.pub, hash3), pending1)); ASSERT_EQ (nano::dev_genesis_key.pub, pending1.source); ASSERT_EQ (25, pending1.amount.number ()); ASSERT_EQ (store->account_count (transaction), ledger.cache.account_count); @@ -294,7 +294,7 @@ TEST (ledger, rollback_receiver) ASSERT_TRUE (ledger.store.account_get (transaction, key2.pub, info2)); ASSERT_EQ (store->account_count (transaction), ledger.cache.account_count); nano::pending_info pending1; - ASSERT_TRUE (ledger.store.pending_get (transaction, nano::pending_key (key2.pub, info2.head), pending1)); + ASSERT_TRUE (ledger.store.pending.get (transaction, nano::pending_key (key2.pub, info2.head), pending1)); } TEST (ledger, rollback_representation) @@ -1731,7 +1731,7 @@ TEST (ledger, state_send_receive) ASSERT_EQ (nano::genesis_amount - nano::Gxrb_ratio, ledger.balance (transaction, send1.hash ())); ASSERT_EQ (nano::Gxrb_ratio, ledger.amount (transaction, send1.hash ())); ASSERT_EQ (nano::genesis_amount - nano::Gxrb_ratio, ledger.weight (nano::genesis_account)); - ASSERT_TRUE (store->pending_exists (transaction, nano::pending_key (nano::genesis_account, send1.hash ()))); + ASSERT_TRUE (store->pending.exists (transaction, nano::pending_key (nano::genesis_account, send1.hash ()))); ASSERT_EQ (2, send2->sideband ().height); ASSERT_TRUE (send2->sideband ().details.is_send); ASSERT_FALSE (send2->sideband ().details.is_receive); @@ -1745,7 +1745,7 @@ TEST (ledger, state_send_receive) ASSERT_EQ (nano::genesis_amount, ledger.balance (transaction, receive1.hash ())); ASSERT_EQ (nano::Gxrb_ratio, ledger.amount (transaction, receive1.hash ())); ASSERT_EQ (nano::genesis_amount, ledger.weight (nano::genesis_account)); - ASSERT_FALSE (store->pending_exists (transaction, nano::pending_key (nano::genesis_account, send1.hash ()))); + ASSERT_FALSE (store->pending.exists (transaction, nano::pending_key (nano::genesis_account, send1.hash ()))); ASSERT_EQ (store->account_count (transaction), ledger.cache.account_count); ASSERT_EQ (3, receive2->sideband ().height); ASSERT_FALSE (receive2->sideband ().details.is_send); @@ -1837,10 +1837,10 @@ TEST (ledger, state_open) ASSERT_EQ (nano::genesis_amount - nano::Gxrb_ratio, ledger.balance (transaction, send1.hash ())); ASSERT_EQ (nano::Gxrb_ratio, ledger.amount (transaction, send1.hash ())); ASSERT_EQ (nano::genesis_amount - nano::Gxrb_ratio, ledger.weight (nano::genesis_account)); - ASSERT_TRUE (store->pending_exists (transaction, nano::pending_key (destination.pub, send1.hash ()))); + ASSERT_TRUE (store->pending.exists (transaction, nano::pending_key (destination.pub, send1.hash ()))); nano::state_block open1 (destination.pub, 0, nano::genesis_account, nano::Gxrb_ratio, send1.hash (), destination.prv, destination.pub, *pool.generate (destination.pub)); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, open1).code); - ASSERT_FALSE (store->pending_exists (transaction, nano::pending_key (destination.pub, send1.hash ()))); + ASSERT_FALSE (store->pending.exists (transaction, nano::pending_key (destination.pub, send1.hash ()))); ASSERT_TRUE (store->block_exists (transaction, open1.hash ())); auto open2 (store->block_get (transaction, open1.hash ())); ASSERT_NE (nullptr, open2); @@ -2211,14 +2211,14 @@ TEST (ledger, state_rollback_send) ASSERT_EQ (nano::genesis_amount - nano::Gxrb_ratio, ledger.account_balance (transaction, nano::genesis_account)); ASSERT_EQ (nano::genesis_amount - nano::Gxrb_ratio, ledger.weight (nano::genesis_account)); nano::pending_info info; - ASSERT_FALSE (store->pending_get (transaction, nano::pending_key (nano::genesis_account, send1.hash ()), info)); + ASSERT_FALSE (store->pending.get (transaction, nano::pending_key (nano::genesis_account, send1.hash ()), info)); ASSERT_EQ (nano::genesis_account, info.source); ASSERT_EQ (nano::Gxrb_ratio, info.amount.number ()); ASSERT_FALSE (ledger.rollback (transaction, send1.hash ())); ASSERT_FALSE (store->block_exists (transaction, send1.hash ())); ASSERT_EQ (nano::genesis_amount, ledger.account_balance (transaction, nano::genesis_account)); ASSERT_EQ (nano::genesis_amount, ledger.weight (nano::genesis_account)); - ASSERT_FALSE (store->pending_exists (transaction, nano::pending_key (nano::genesis_account, send1.hash ()))); + ASSERT_FALSE (store->pending.exists (transaction, nano::pending_key (nano::genesis_account, send1.hash ()))); ASSERT_TRUE (store->block_successor (transaction, genesis.hash ()).is_zero ()); ASSERT_EQ (store->account_count (transaction), ledger.cache.account_count); } @@ -2238,10 +2238,10 @@ TEST (ledger, state_rollback_receive) ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code); nano::state_block receive1 (nano::genesis_account, send1.hash (), nano::genesis_account, nano::genesis_amount, send1.hash (), nano::dev_genesis_key.prv, nano::dev_genesis_key.pub, *pool.generate (send1.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, receive1).code); - ASSERT_FALSE (store->pending_exists (transaction, nano::pending_key (nano::genesis_account, receive1.hash ()))); + ASSERT_FALSE (store->pending.exists (transaction, nano::pending_key (nano::genesis_account, receive1.hash ()))); ASSERT_FALSE (ledger.rollback (transaction, receive1.hash ())); nano::pending_info info; - ASSERT_FALSE (store->pending_get (transaction, nano::pending_key (nano::genesis_account, send1.hash ()), info)); + ASSERT_FALSE (store->pending.get (transaction, nano::pending_key (nano::genesis_account, send1.hash ()), info)); ASSERT_EQ (nano::genesis_account, info.source); ASSERT_EQ (nano::Gxrb_ratio, info.amount.number ()); ASSERT_FALSE (store->block_exists (transaction, receive1.hash ())); @@ -2266,9 +2266,9 @@ TEST (ledger, state_rollback_received_send) ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code); nano::state_block receive1 (key.pub, 0, key.pub, nano::Gxrb_ratio, send1.hash (), key.prv, key.pub, *pool.generate (key.pub)); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, receive1).code); - ASSERT_FALSE (store->pending_exists (transaction, nano::pending_key (nano::genesis_account, receive1.hash ()))); + ASSERT_FALSE (store->pending.exists (transaction, nano::pending_key (nano::genesis_account, receive1.hash ()))); ASSERT_FALSE (ledger.rollback (transaction, send1.hash ())); - ASSERT_FALSE (store->pending_exists (transaction, nano::pending_key (nano::genesis_account, send1.hash ()))); + ASSERT_FALSE (store->pending.exists (transaction, nano::pending_key (nano::genesis_account, send1.hash ()))); ASSERT_FALSE (store->block_exists (transaction, send1.hash ())); ASSERT_FALSE (store->block_exists (transaction, receive1.hash ())); ASSERT_EQ (nano::genesis_amount, ledger.account_balance (transaction, nano::genesis_account)); @@ -2320,7 +2320,7 @@ TEST (ledger, state_open_rollback) ASSERT_EQ (0, ledger.account_balance (transaction, destination.pub)); ASSERT_EQ (nano::genesis_amount - nano::Gxrb_ratio, ledger.weight (nano::genesis_account)); nano::pending_info info; - ASSERT_FALSE (store->pending_get (transaction, nano::pending_key (destination.pub, send1.hash ()), info)); + ASSERT_FALSE (store->pending.get (transaction, nano::pending_key (destination.pub, send1.hash ()), info)); ASSERT_EQ (nano::genesis_account, info.source); ASSERT_EQ (nano::Gxrb_ratio, info.amount.number ()); ASSERT_EQ (store->account_count (transaction), ledger.cache.account_count); @@ -2546,7 +2546,7 @@ TEST (ledger, epoch_blocks_receive_upgrade) ASSERT_FALSE (ledger.store.account_get (transaction, destination.pub, destination_info)); ASSERT_EQ (destination_info.epoch (), nano::epoch::epoch_0); nano::pending_info pending_send2; - ASSERT_FALSE (ledger.store.pending_get (transaction, nano::pending_key (destination.pub, send2.hash ()), pending_send2)); + ASSERT_FALSE (ledger.store.pending.get (transaction, nano::pending_key (destination.pub, send2.hash ()), pending_send2)); ASSERT_EQ (nano::dev_genesis_key.pub, pending_send2.source); ASSERT_EQ (nano::Gxrb_ratio, pending_send2.amount.number ()); ASSERT_EQ (nano::epoch::epoch_1, pending_send2.epoch); @@ -3460,14 +3460,14 @@ TEST (ledger, pruning_action) auto send1_stored (store->block_get (transaction, send1.hash ())); ASSERT_NE (nullptr, send1_stored); ASSERT_EQ (send1, *send1_stored); - ASSERT_TRUE (store->pending_exists (transaction, nano::pending_key (nano::genesis_account, send1.hash ()))); + ASSERT_TRUE (store->pending.exists (transaction, nano::pending_key (nano::genesis_account, send1.hash ()))); nano::state_block send2 (nano::genesis_account, send1.hash (), nano::genesis_account, nano::genesis_amount - nano::Gxrb_ratio * 2, nano::genesis_account, nano::dev_genesis_key.prv, nano::dev_genesis_key.pub, *pool.generate (send1.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send2).code); ASSERT_TRUE (store->block_exists (transaction, send2.hash ())); // Pruning action ASSERT_EQ (1, ledger.pruning_action (transaction, send1.hash (), 1)); ASSERT_EQ (0, ledger.pruning_action (transaction, genesis.hash (), 1)); - ASSERT_TRUE (store->pending_exists (transaction, nano::pending_key (nano::genesis_account, send1.hash ()))); + ASSERT_TRUE (store->pending.exists (transaction, nano::pending_key (nano::genesis_account, send1.hash ()))); ASSERT_FALSE (store->block_exists (transaction, send1.hash ())); ASSERT_TRUE (ledger.block_or_pruned_exists (transaction, send1.hash ())); // Pruned ledger start without proper flags emulation @@ -3484,7 +3484,7 @@ TEST (ledger, pruning_action) auto receive1_stored (store->block_get (transaction, receive1.hash ())); ASSERT_NE (nullptr, receive1_stored); ASSERT_EQ (receive1, *receive1_stored); - ASSERT_FALSE (store->pending_exists (transaction, nano::pending_key (nano::genesis_account, send1.hash ()))); + ASSERT_FALSE (store->pending.exists (transaction, nano::pending_key (nano::genesis_account, send1.hash ()))); ASSERT_EQ (4, receive1_stored->sideband ().height); ASSERT_FALSE (receive1_stored->sideband ().details.is_send); ASSERT_TRUE (receive1_stored->sideband ().details.is_receive); @@ -3552,7 +3552,7 @@ TEST (ledger, pruning_source_rollback) ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, epoch1).code); nano::state_block send1 (nano::genesis_account, epoch1.hash (), nano::genesis_account, nano::genesis_amount - nano::Gxrb_ratio, nano::genesis_account, nano::dev_genesis_key.prv, nano::dev_genesis_key.pub, *pool.generate (epoch1.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code); - ASSERT_TRUE (store->pending_exists (transaction, nano::pending_key (nano::genesis_account, send1.hash ()))); + ASSERT_TRUE (store->pending.exists (transaction, nano::pending_key (nano::genesis_account, send1.hash ()))); nano::state_block send2 (nano::genesis_account, send1.hash (), nano::genesis_account, nano::genesis_amount - nano::Gxrb_ratio * 2, nano::genesis_account, nano::dev_genesis_key.prv, nano::dev_genesis_key.pub, *pool.generate (send1.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send2).code); ASSERT_TRUE (store->block_exists (transaction, send2.hash ())); @@ -3564,26 +3564,26 @@ TEST (ledger, pruning_source_rollback) ASSERT_TRUE (store->pruned_exists (transaction, epoch1.hash ())); ASSERT_TRUE (store->block_exists (transaction, genesis.hash ())); nano::pending_info info; - ASSERT_FALSE (store->pending_get (transaction, nano::pending_key (nano::genesis_account, send1.hash ()), info)); + ASSERT_FALSE (store->pending.get (transaction, nano::pending_key (nano::genesis_account, send1.hash ()), info)); ASSERT_EQ (nano::genesis_account, info.source); ASSERT_EQ (nano::Gxrb_ratio, info.amount.number ()); ASSERT_EQ (nano::epoch::epoch_1, info.epoch); // Receiving pruned block nano::state_block receive1 (nano::genesis_account, send2.hash (), nano::genesis_account, nano::genesis_amount - nano::Gxrb_ratio, send1.hash (), nano::dev_genesis_key.prv, nano::dev_genesis_key.pub, *pool.generate (send2.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, receive1).code); - ASSERT_FALSE (store->pending_exists (transaction, nano::pending_key (nano::genesis_account, send1.hash ()))); + ASSERT_FALSE (store->pending.exists (transaction, nano::pending_key (nano::genesis_account, send1.hash ()))); ASSERT_EQ (2, ledger.cache.pruned_count); ASSERT_EQ (5, ledger.cache.block_count); // Rollback receive block ASSERT_FALSE (ledger.rollback (transaction, receive1.hash ())); nano::pending_info info2; - ASSERT_FALSE (store->pending_get (transaction, nano::pending_key (nano::genesis_account, send1.hash ()), info2)); + ASSERT_FALSE (store->pending.get (transaction, nano::pending_key (nano::genesis_account, send1.hash ()), info2)); ASSERT_NE (nano::genesis_account, info2.source); // Tradeoff to not store pruned blocks accounts ASSERT_EQ (nano::Gxrb_ratio, info2.amount.number ()); ASSERT_EQ (nano::epoch::epoch_1, info2.epoch); // Process receive block again ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, receive1).code); - ASSERT_FALSE (store->pending_exists (transaction, nano::pending_key (nano::genesis_account, send1.hash ()))); + ASSERT_FALSE (store->pending.exists (transaction, nano::pending_key (nano::genesis_account, send1.hash ()))); ASSERT_EQ (2, ledger.cache.pruned_count); ASSERT_EQ (5, ledger.cache.block_count); } @@ -3602,16 +3602,16 @@ TEST (ledger, pruning_source_rollback_legacy) nano::work_pool pool (std::numeric_limits::max ()); nano::send_block send1 (genesis.hash (), nano::genesis_account, nano::genesis_amount - nano::Gxrb_ratio, nano::dev_genesis_key.prv, nano::dev_genesis_key.pub, *pool.generate (genesis.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code); - ASSERT_TRUE (store->pending_exists (transaction, nano::pending_key (nano::genesis_account, send1.hash ()))); + ASSERT_TRUE (store->pending.exists (transaction, nano::pending_key (nano::genesis_account, send1.hash ()))); nano::keypair key1; nano::send_block send2 (send1.hash (), key1.pub, nano::genesis_amount - 2 * nano::Gxrb_ratio, nano::dev_genesis_key.prv, nano::dev_genesis_key.pub, *pool.generate (send1.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send2).code); ASSERT_TRUE (store->block_exists (transaction, send2.hash ())); - ASSERT_TRUE (store->pending_exists (transaction, nano::pending_key (key1.pub, send2.hash ()))); + ASSERT_TRUE (store->pending.exists (transaction, nano::pending_key (key1.pub, send2.hash ()))); nano::send_block send3 (send2.hash (), nano::genesis_account, nano::genesis_amount - 3 * nano::Gxrb_ratio, nano::dev_genesis_key.prv, nano::dev_genesis_key.pub, *pool.generate (send2.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send3).code); ASSERT_TRUE (store->block_exists (transaction, send3.hash ())); - ASSERT_TRUE (store->pending_exists (transaction, nano::pending_key (nano::genesis_account, send3.hash ()))); + ASSERT_TRUE (store->pending.exists (transaction, nano::pending_key (nano::genesis_account, send3.hash ()))); // Pruning action ASSERT_EQ (2, ledger.pruning_action (transaction, send2.hash (), 1)); ASSERT_FALSE (store->block_exists (transaction, send2.hash ())); @@ -3620,49 +3620,49 @@ TEST (ledger, pruning_source_rollback_legacy) ASSERT_TRUE (store->pruned_exists (transaction, send1.hash ())); ASSERT_TRUE (store->block_exists (transaction, genesis.hash ())); nano::pending_info info1; - ASSERT_FALSE (store->pending_get (transaction, nano::pending_key (nano::genesis_account, send1.hash ()), info1)); + ASSERT_FALSE (store->pending.get (transaction, nano::pending_key (nano::genesis_account, send1.hash ()), info1)); ASSERT_EQ (nano::genesis_account, info1.source); ASSERT_EQ (nano::Gxrb_ratio, info1.amount.number ()); ASSERT_EQ (nano::epoch::epoch_0, info1.epoch); nano::pending_info info2; - ASSERT_FALSE (store->pending_get (transaction, nano::pending_key (key1.pub, send2.hash ()), info2)); + ASSERT_FALSE (store->pending.get (transaction, nano::pending_key (key1.pub, send2.hash ()), info2)); ASSERT_EQ (nano::genesis_account, info2.source); ASSERT_EQ (nano::Gxrb_ratio, info2.amount.number ()); ASSERT_EQ (nano::epoch::epoch_0, info2.epoch); // Receiving pruned block nano::receive_block receive1 (send3.hash (), send1.hash (), nano::dev_genesis_key.prv, nano::dev_genesis_key.pub, *pool.generate (send3.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, receive1).code); - ASSERT_FALSE (store->pending_exists (transaction, nano::pending_key (nano::genesis_account, send1.hash ()))); + ASSERT_FALSE (store->pending.exists (transaction, nano::pending_key (nano::genesis_account, send1.hash ()))); ASSERT_EQ (2, ledger.cache.pruned_count); ASSERT_EQ (5, ledger.cache.block_count); // Rollback receive block ASSERT_FALSE (ledger.rollback (transaction, receive1.hash ())); nano::pending_info info3; - ASSERT_FALSE (store->pending_get (transaction, nano::pending_key (nano::genesis_account, send1.hash ()), info3)); + ASSERT_FALSE (store->pending.get (transaction, nano::pending_key (nano::genesis_account, send1.hash ()), info3)); ASSERT_NE (nano::genesis_account, info3.source); // Tradeoff to not store pruned blocks accounts ASSERT_EQ (nano::Gxrb_ratio, info3.amount.number ()); ASSERT_EQ (nano::epoch::epoch_0, info3.epoch); // Process receive block again ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, receive1).code); - ASSERT_FALSE (store->pending_exists (transaction, nano::pending_key (nano::genesis_account, send1.hash ()))); + ASSERT_FALSE (store->pending.exists (transaction, nano::pending_key (nano::genesis_account, send1.hash ()))); ASSERT_EQ (2, ledger.cache.pruned_count); ASSERT_EQ (5, ledger.cache.block_count); // Receiving pruned block (open) nano::open_block open1 (send2.hash (), nano::genesis_account, key1.pub, key1.prv, key1.pub, *pool.generate (key1.pub)); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, open1).code); - ASSERT_FALSE (store->pending_exists (transaction, nano::pending_key (key1.pub, send2.hash ()))); + ASSERT_FALSE (store->pending.exists (transaction, nano::pending_key (key1.pub, send2.hash ()))); ASSERT_EQ (2, ledger.cache.pruned_count); ASSERT_EQ (6, ledger.cache.block_count); // Rollback open block ASSERT_FALSE (ledger.rollback (transaction, open1.hash ())); nano::pending_info info4; - ASSERT_FALSE (store->pending_get (transaction, nano::pending_key (key1.pub, send2.hash ()), info4)); + ASSERT_FALSE (store->pending.get (transaction, nano::pending_key (key1.pub, send2.hash ()), info4)); ASSERT_NE (nano::genesis_account, info4.source); // Tradeoff to not store pruned blocks accounts ASSERT_EQ (nano::Gxrb_ratio, info4.amount.number ()); ASSERT_EQ (nano::epoch::epoch_0, info4.epoch); // Process open block again ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, open1).code); - ASSERT_FALSE (store->pending_exists (transaction, nano::pending_key (key1.pub, send2.hash ()))); + ASSERT_FALSE (store->pending.exists (transaction, nano::pending_key (key1.pub, send2.hash ()))); ASSERT_EQ (2, ledger.cache.pruned_count); ASSERT_EQ (6, ledger.cache.block_count); } @@ -3711,7 +3711,7 @@ TEST (ledger, pruning_legacy_blocks) nano::work_pool pool (std::numeric_limits::max ()); nano::send_block send1 (genesis.hash (), nano::genesis_account, nano::genesis_amount - nano::Gxrb_ratio, nano::dev_genesis_key.prv, nano::dev_genesis_key.pub, *pool.generate (genesis.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code); - ASSERT_TRUE (store->pending_exists (transaction, nano::pending_key (nano::genesis_account, send1.hash ()))); + ASSERT_TRUE (store->pending.exists (transaction, nano::pending_key (nano::genesis_account, send1.hash ()))); nano::receive_block receive1 (send1.hash (), send1.hash (), nano::dev_genesis_key.prv, nano::dev_genesis_key.pub, *pool.generate (send1.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, receive1).code); nano::change_block change1 (receive1.hash (), key1.pub, nano::dev_genesis_key.prv, nano::dev_genesis_key.pub, *pool.generate (receive1.hash ())); @@ -3866,7 +3866,7 @@ TEST (ledger, migrate_lmdb_to_rocksdb) store.frontier.put (transaction, nano::block_hash (2), nano::account (5)); store.peer_put (transaction, endpoint_key); - store.pending_put (transaction, nano::pending_key (nano::genesis_account, send->hash ()), nano::pending_info (nano::genesis_account, 100, nano::epoch::epoch_0)); + store.pending.put (transaction, nano::pending_key (nano::genesis_account, send->hash ()), nano::pending_info (nano::genesis_account, 100, nano::epoch::epoch_0)); store.pruned_put (transaction, send->hash ()); store.unchecked_put (transaction, nano::genesis_hash, send); store.version_put (transaction, version); @@ -3882,7 +3882,7 @@ TEST (ledger, migrate_lmdb_to_rocksdb) auto rocksdb_transaction (rocksdb_store.tx_begin_read ()); nano::pending_info pending_info; - ASSERT_FALSE (rocksdb_store.pending_get (rocksdb_transaction, nano::pending_key (nano::genesis_account, send->hash ()), pending_info)); + ASSERT_FALSE (rocksdb_store.pending.get (rocksdb_transaction, nano::pending_key (nano::genesis_account, send->hash ()), pending_info)); for (auto i = rocksdb_store.online_weight_begin (rocksdb_transaction); i != rocksdb_store.online_weight_end (); ++i) { diff --git a/nano/nano_node/entry.cpp b/nano/nano_node/entry.cpp index 4f94209011..87c4820950 100644 --- a/nano/nano_node/entry.cpp +++ b/nano/nano_node/entry.cpp @@ -1742,7 +1742,7 @@ int main (int argc, char * const * argv) start_threads (check_pending, pending); size_t const pending_deque_overflow (64 * 1024); - for (auto i (node->store.pending_begin (transaction)), n (node->store.pending_end ()); i != n; ++i) + for (auto i (node->store.pending.begin (transaction)), n (node->store.pending.end ()); i != n; ++i) { { nano::unique_lock lock (mutex); @@ -1948,7 +1948,7 @@ int main (int argc, char * const * argv) // Iterate all pending blocks and collect the lowest version for each unopened account nano::locked>> unopened_highest_pending_shared; using unopened_highest_pending_t = decltype (unopened_highest_pending_shared)::value_type; - node->store.pending_for_each_par ( + node->store.pending.for_each_par ( [&unopened_highest_pending_shared, &opened_accounts] (nano::read_transaction const & /*unused*/, nano::store_iterator i, nano::store_iterator n) { // First cache locally unopened_highest_pending_t unopened_highest_pending_l; diff --git a/nano/node/bootstrap/bootstrap_bulk_pull.cpp b/nano/node/bootstrap/bootstrap_bulk_pull.cpp index 3894317782..f496ae3fce 100644 --- a/nano/node/bootstrap/bootstrap_bulk_pull.cpp +++ b/nano/node/bootstrap/bootstrap_bulk_pull.cpp @@ -786,7 +786,7 @@ std::pair, std::unique_ptrnode->store.tx_begin_read ()); - auto stream (connection->node->store.pending_begin (stream_transaction, current_key)); + auto stream (connection->node->store.pending.begin (stream_transaction, current_key)); if (stream == nano::store_iterator (nullptr)) { diff --git a/nano/node/json_handler.cpp b/nano/node/json_handler.cpp index 8acf1c8544..47703d6628 100644 --- a/nano/node/json_handler.cpp +++ b/nano/node/json_handler.cpp @@ -398,7 +398,7 @@ uint64_t nano::json_handler::difficulty_ledger (nano::block const & block_a) if (!link.is_zero () && !details.is_send) { auto block_link (node.store.block_get (transaction, link.as_block_hash ())); - if (block_link != nullptr && node.store.pending_exists (transaction, nano::pending_key (block_a.account (), link.as_block_hash ()))) + if (block_link != nullptr && node.store.pending.exists (transaction, nano::pending_key (block_a.account (), link.as_block_hash ()))) { details.epoch = std::max (details.epoch, block_link->sideband ().details.epoch); details.is_receive = true; @@ -956,7 +956,7 @@ void nano::json_handler::accounts_pending () if (!ec) { boost::property_tree::ptree peers_l; - for (auto i (node.store.pending_begin (transaction, nano::pending_key (account, 0))), n (node.store.pending_end ()); i != n && nano::pending_key (i->first).account == account && peers_l.size () < count; ++i) + for (auto i (node.store.pending.begin (transaction, nano::pending_key (account, 0))), n (node.store.pending.end ()); i != n && nano::pending_key (i->first).account == account && peers_l.size () < count; ++i) { nano::pending_key const & key (i->first); if (block_confirmed (node, transaction, key.hash, include_active, include_only_confirmed)) @@ -1243,7 +1243,7 @@ void nano::json_handler::blocks_info () auto destination (node.ledger.block_destination (transaction, *block)); if (!destination.is_zero ()) { - exists = node.store.pending_exists (transaction, nano::pending_key (destination, hash)); + exists = node.store.pending.exists (transaction, nano::pending_key (destination, hash)); } entry.put ("pending", exists ? "1" : "0"); } @@ -2871,7 +2871,7 @@ void nano::json_handler::pending () // The ptree container is used if there are any children nodes (e.g source/min_version) otherwise the amount container is used. std::vector> hash_ptree_pairs; std::vector> hash_amount_pairs; - for (auto i (node.store.pending_begin (transaction, nano::pending_key (account, 0))), n (node.store.pending_end ()); i != n && nano::pending_key (i->first).account == account && (should_sort || peers_l.size () < count); ++i) + for (auto i (node.store.pending.begin (transaction, nano::pending_key (account, 0))), n (node.store.pending.end ()); i != n && nano::pending_key (i->first).account == account && (should_sort || peers_l.size () < count); ++i) { nano::pending_key const & key (i->first); if (block_confirmed (node, transaction, key.hash, include_active, include_only_confirmed)) @@ -2970,7 +2970,7 @@ void nano::json_handler::pending_exists () auto destination (node.ledger.block_destination (transaction, *block)); if (!destination.is_zero ()) { - exists = node.store.pending_exists (transaction, nano::pending_key (destination, hash)); + exists = node.store.pending.exists (transaction, nano::pending_key (destination, hash)); } exists = exists && (block_confirmed (node, transaction, block->hash (), include_active, include_only_confirmed)); response_l.put ("exists", exists ? "1" : "0"); @@ -3200,7 +3200,7 @@ void nano::json_handler::receive () if (node.ledger.block_or_pruned_exists (block_transaction, hash)) { nano::pending_info pending_info; - if (!node.store.pending_get (block_transaction, nano::pending_key (account, hash), pending_info)) + if (!node.store.pending.get (block_transaction, nano::pending_key (account, hash), pending_info)) { auto work (work_optional_impl ()); if (!ec && work) @@ -3464,7 +3464,7 @@ void nano::json_handler::republish () auto destination (node.ledger.block_destination (transaction, *block_b)); if (!destination.is_zero ()) { - if (!node.store.pending_exists (transaction, nano::pending_key (destination, hash))) + if (!node.store.pending.exists (transaction, nano::pending_key (destination, hash))) { nano::block_hash previous (node.ledger.latest (transaction, destination)); auto block_d (node.store.block_get (transaction, previous)); @@ -4061,8 +4061,8 @@ void nano::json_handler::unopened () if (!ec) { auto transaction (node.store.tx_begin_read ()); - auto iterator (node.store.pending_begin (transaction, nano::pending_key (start, 0))); - auto end (node.store.pending_end ()); + auto iterator (node.store.pending.begin (transaction, nano::pending_key (start, 0))); + auto end (node.store.pending.end ()); nano::account current_account (start); nano::uint128_t current_account_sum{ 0 }; boost::property_tree::ptree accounts; @@ -4078,7 +4078,7 @@ void nano::json_handler::unopened () break; } // Skip existing accounts - iterator = node.store.pending_begin (transaction, nano::pending_key (account.number () + 1, 0)); + iterator = node.store.pending.begin (transaction, nano::pending_key (account.number () + 1, 0)); } else { @@ -4596,7 +4596,7 @@ void nano::json_handler::wallet_pending () { nano::account const & account (i->first); boost::property_tree::ptree peers_l; - for (auto ii (node.store.pending_begin (block_transaction, nano::pending_key (account, 0))), nn (node.store.pending_end ()); ii != nn && nano::pending_key (ii->first).account == account && peers_l.size () < count; ++ii) + for (auto ii (node.store.pending.begin (block_transaction, nano::pending_key (account, 0))), nn (node.store.pending.end ()); ii != nn && nano::pending_key (ii->first).account == account && peers_l.size () < count; ++ii) { nano::pending_key key (ii->first); if (block_confirmed (node, block_transaction, key.hash, include_active, include_only_confirmed)) diff --git a/nano/node/lmdb/lmdb.cpp b/nano/node/lmdb/lmdb.cpp index 1425c69cab..a4ca78956b 100644 --- a/nano/node/lmdb/lmdb.cpp +++ b/nano/node/lmdb/lmdb.cpp @@ -198,7 +198,7 @@ void nano::mdb_store::open_databases (bool & error_a, nano::transaction const & error_a |= mdb_dbi_open (env.tx (transaction_a), "accounts", flags, &accounts_v0) != 0; accounts = accounts_v0; error_a |= mdb_dbi_open (env.tx (transaction_a), "pending", flags, &pending_v0) != 0; - pending = pending_v0; + lmdb_pending = pending_v0; error_a |= mdb_dbi_open (env.tx (transaction_a), "final_votes", flags, &final_votes) != 0; auto version_l = version_get (transaction_a); @@ -404,7 +404,7 @@ void nano::mdb_store::upgrade_v14_to_v15 (nano::write_transaction & transaction_ for (auto const & pending_key_pending_info_pair : pending_infos) { - mdb_put (env.tx (transaction_a), pending, nano::mdb_val (pending_key_pending_info_pair.first), nano::mdb_val (pending_key_pending_info_pair.second), MDB_APPEND); + mdb_put (env.tx (transaction_a), lmdb_pending, nano::mdb_val (pending_key_pending_info_pair.first), nano::mdb_val (pending_key_pending_info_pair.second), MDB_APPEND); } version_put (transaction_a, 15); @@ -864,7 +864,7 @@ MDB_dbi nano::mdb_store::table_to_dbi (tables table_a) const case tables::blocks: return blocks; case tables::pending: - return pending; + return lmdb_pending; case tables::unchecked: return unchecked; case tables::online_weight: @@ -942,20 +942,20 @@ void nano::mdb_store::rebuild_db (nano::write_transaction const & transaction_a) MDB_dbi temp; mdb_dbi_open (env.tx (transaction_a), "temp_table", MDB_CREATE, &temp); // Copy all values to temporary table - for (auto i (nano::store_iterator (std::make_unique> (transaction_a, pending))), n (nano::store_iterator (nullptr)); i != n; ++i) + for (auto i (nano::store_iterator (std::make_unique> (transaction_a, lmdb_pending))), n (nano::store_iterator (nullptr)); i != n; ++i) { auto s = mdb_put (env.tx (transaction_a), temp, nano::mdb_val (i->first), nano::mdb_val (i->second), MDB_APPEND); release_assert_success (*this, s); } - release_assert (count (transaction_a, pending) == count (transaction_a, temp)); - mdb_drop (env.tx (transaction_a), pending, 0); + release_assert (count (transaction_a, lmdb_pending) == count (transaction_a, temp)); + mdb_drop (env.tx (transaction_a), lmdb_pending, 0); // Put values from copy for (auto i (nano::store_iterator (std::make_unique> (transaction_a, temp))), n (nano::store_iterator (nullptr)); i != n; ++i) { - auto s = mdb_put (env.tx (transaction_a), pending, nano::mdb_val (i->first), nano::mdb_val (i->second), MDB_APPEND); + auto s = mdb_put (env.tx (transaction_a), lmdb_pending, nano::mdb_val (i->first), nano::mdb_val (i->second), MDB_APPEND); release_assert_success (*this, s); } - release_assert (count (transaction_a, pending) == count (transaction_a, temp)); + release_assert (count (transaction_a, lmdb_pending) == count (transaction_a, temp)); mdb_drop (env.tx (transaction_a), temp, 1); } } diff --git a/nano/node/lmdb/lmdb.hpp b/nano/node/lmdb/lmdb.hpp index 70c9fff45d..d61b8ae196 100644 --- a/nano/node/lmdb/lmdb.hpp +++ b/nano/node/lmdb/lmdb.hpp @@ -142,7 +142,7 @@ class mdb_store : public block_store_partial * Maps (destination account, pending block) to (source account, amount, version). (Removed) * nano::account, nano::block_hash -> nano::account, nano::amount, nano::epoch */ - MDB_dbi pending{ 0 }; + MDB_dbi lmdb_pending{ 0 }; /** * Representative weights. (Removed) diff --git a/nano/node/node.cpp b/nano/node/node.cpp index 4662eb2abd..85443218f6 100644 --- a/nano/node/node.cpp +++ b/nano/node/node.cpp @@ -1283,7 +1283,7 @@ void nano::node::receive_confirmed (nano::transaction const & block_transaction_ nano::account representative; nano::pending_info pending; representative = wallet->store.representative (wallet_transaction); - auto error (store.pending_get (block_transaction_a, nano::pending_key (destination_a, hash_a), pending)); + auto error (store.pending.get (block_transaction_a, nano::pending_key (destination_a, hash_a), pending)); if (!error) { auto amount (pending.amount.number ()); @@ -1607,7 +1607,7 @@ void nano::node::epoch_upgrader_impl (nano::raw_key const & prv_a, nano::epoch e uint64_t workers (0); uint64_t attempts (0); auto transaction (store.tx_begin_read ()); - for (auto i (store.pending_begin (transaction, nano::pending_key (1, 0))), n (store.pending_end ()); i != n && attempts < upgrade_batch_size && attempts < count_limit && !stopped;) + for (auto i (store.pending.begin (transaction, nano::pending_key (1, 0))), n (store.pending.end ()); i != n && attempts < upgrade_batch_size && attempts < count_limit && !stopped;) { bool to_next_account (false); nano::pending_key const & key (i->first); @@ -1668,7 +1668,7 @@ void nano::node::epoch_upgrader_impl (nano::raw_key const & prv_a, nano::epoch e } else { - i = store.pending_begin (transaction, nano::pending_key (key.account.number () + 1, 0)); + i = store.pending.begin (transaction, nano::pending_key (key.account.number () + 1, 0)); } } else diff --git a/nano/node/testing.cpp b/nano/node/testing.cpp index c0e8341bf2..35de3246a0 100644 --- a/nano/node/testing.cpp +++ b/nano/node/testing.cpp @@ -353,8 +353,8 @@ void nano::system::generate_receive (nano::node & node_a) auto transaction (node_a.store.tx_begin_read ()); nano::account random_account; random_pool::generate_block (random_account.bytes.data (), sizeof (random_account.bytes)); - auto i (node_a.store.pending_begin (transaction, nano::pending_key (random_account, 0))); - if (i != node_a.store.pending_end ()) + auto i (node_a.store.pending.begin (transaction, nano::pending_key (random_account, 0))); + if (i != node_a.store.pending.end ()) { nano::pending_key const & send_hash (i->first); send_block = node_a.store.block_get (transaction, send_hash.hash); diff --git a/nano/node/wallet.cpp b/nano/node/wallet.cpp index 7a676654f6..08a7594b54 100644 --- a/nano/node/wallet.cpp +++ b/nano/node/wallet.cpp @@ -841,7 +841,7 @@ std::shared_ptr nano::wallet::receive_action (nano::block_hash cons nano::pending_info pending_info; if (wallets.node.ledger.block_or_pruned_exists (block_transaction, send_hash_a)) { - if (!wallets.node.ledger.store.pending_get (block_transaction, nano::pending_key (account_a, send_hash_a), pending_info)) + if (!wallets.node.ledger.store.pending.get (block_transaction, nano::pending_key (account_a, send_hash_a), pending_info)) { nano::raw_key prv; if (!store.fetch (transaction, account_a, prv)) @@ -1178,7 +1178,7 @@ bool nano::wallet::search_pending (nano::transaction const & wallet_transaction_ // Don't search pending for watch-only accounts if (!nano::wallet_value (i->second).key.is_zero ()) { - for (auto j (wallets.node.store.pending_begin (block_transaction, nano::pending_key (account, 0))), k (wallets.node.store.pending_end ()); j != k && nano::pending_key (j->first).account == account; ++j) + for (auto j (wallets.node.store.pending.begin (block_transaction, nano::pending_key (account, 0))), k (wallets.node.store.pending.end ()); j != k && nano::pending_key (j->first).account == account; ++j) { nano::pending_key key (j->first); auto hash (key.hash); @@ -1243,7 +1243,7 @@ uint32_t nano::wallet::deterministic_check (nano::transaction const & transactio else { // Check if there are pending blocks for account - for (auto ii (wallets.node.store.pending_begin (block_transaction, nano::pending_key (pair.pub, 0))), nn (wallets.node.store.pending_end ()); ii != nn && nano::pending_key (ii->first).account == pair.pub; ++ii) + for (auto ii (wallets.node.store.pending.begin (block_transaction, nano::pending_key (pair.pub, 0))), nn (wallets.node.store.pending.end ()); ii != nn && nano::pending_key (ii->first).account == pair.pub; ++ii) { index = i; n = i + 64 + (i / 64); diff --git a/nano/qt/qt.cpp b/nano/qt/qt.cpp index 067a63ea60..c7ff3a1e44 100644 --- a/nano/qt/qt.cpp +++ b/nano/qt/qt.cpp @@ -2336,7 +2336,7 @@ void nano_qt::block_creation::create_receive () { nano::pending_key pending_key (destination, source_l); nano::pending_info pending; - if (!wallet.node.store.pending_get (block_transaction, pending_key, pending)) + if (!wallet.node.store.pending.get (block_transaction, pending_key, pending)) { nano::account_info info; auto error (wallet.node.store.account_get (block_transaction, pending_key.account, info)); @@ -2501,7 +2501,7 @@ void nano_qt::block_creation::create_open () { nano::pending_key pending_key (destination, source_l); nano::pending_info pending; - if (!wallet.node.store.pending_get (block_transaction, pending_key, pending)) + if (!wallet.node.store.pending.get (block_transaction, pending_key, pending)) { nano::account_info info; auto error (wallet.node.store.account_get (block_transaction, pending_key.account, info)); diff --git a/nano/rpc_test/rpc.cpp b/nano/rpc_test/rpc.cpp index 34e184a924..8c5c20e3e9 100644 --- a/nano/rpc_test/rpc.cpp +++ b/nano/rpc_test/rpc.cpp @@ -4250,7 +4250,7 @@ TEST (rpc, pending_exists) request.put ("hash", hash0.to_string ()); pending_exists ("0"); - node->store.pending_exists (node->store.tx_begin_read (), nano::pending_key (nano::dev_genesis_key.pub, block1->hash ())); + node->store.pending.exists (node->store.tx_begin_read (), nano::pending_key (nano::dev_genesis_key.pub, block1->hash ())); request.put ("hash", block1->hash ().to_string ()); pending_exists ("1"); @@ -7232,7 +7232,7 @@ TEST (rpc, epoch_upgrade) // Check pending entry auto transaction (node->store.tx_begin_read ()); nano::pending_info info; - ASSERT_FALSE (node->store.pending_get (transaction, nano::pending_key (key3.pub, send7->hash ()), info)); + ASSERT_FALSE (node->store.pending.get (transaction, nano::pending_key (key3.pub, send7->hash ()), info)); ASSERT_EQ (nano::epoch::epoch_1, info.epoch); } @@ -7333,7 +7333,7 @@ TEST (rpc, epoch_upgrade_multithreaded) // Check pending entry auto transaction (node->store.tx_begin_read ()); nano::pending_info info; - ASSERT_FALSE (node->store.pending_get (transaction, nano::pending_key (key3.pub, send7->hash ()), info)); + ASSERT_FALSE (node->store.pending.get (transaction, nano::pending_key (key3.pub, send7->hash ()), info)); ASSERT_EQ (nano::epoch::epoch_1, info.epoch); } diff --git a/nano/secure/CMakeLists.txt b/nano/secure/CMakeLists.txt index a0c9f42188..b2d8ec5a2a 100644 --- a/nano/secure/CMakeLists.txt +++ b/nano/secure/CMakeLists.txt @@ -54,7 +54,8 @@ add_library( versioning.hpp versioning.cpp working.hpp - store/frontier_store_partial.hpp) + store/frontier_store_partial.hpp + store/pending_store_partial.hpp) target_link_libraries( secure diff --git a/nano/secure/blockstore.cpp b/nano/secure/blockstore.cpp index bbd894eb9e..44e517ead3 100644 --- a/nano/secure/blockstore.cpp +++ b/nano/secure/blockstore.cpp @@ -105,7 +105,8 @@ bool nano::write_transaction::contains (nano::tables table_a) const return impl->contains (table_a); } -nano::block_store::block_store (nano::frontier_store & frontier_store_a) : - frontier (frontier_store_a) +nano::block_store::block_store (nano::frontier_store & frontier_store_a, nano::pending_store & pending_store_a) : + frontier (frontier_store_a), + pending (pending_store_a) { } diff --git a/nano/secure/blockstore.hpp b/nano/secure/blockstore.hpp index 6ee175d506..18be9bec82 100644 --- a/nano/secure/blockstore.hpp +++ b/nano/secure/blockstore.hpp @@ -620,6 +620,9 @@ class write_transaction final : public transaction class ledger_cache; +/** + * Manages frontier storage and iteration + */ class frontier_store { public: @@ -632,13 +635,30 @@ class frontier_store virtual void for_each_par (std::function, nano::store_iterator)> const & action_a) const = 0; }; +/** + * Manages pending storage and iteration + */ +class pending_store +{ +public: + virtual void put (nano::write_transaction const &, nano::pending_key const &, nano::pending_info const &) = 0; + virtual void del (nano::write_transaction const &, nano::pending_key const &) = 0; + virtual bool get (nano::transaction const &, nano::pending_key const &, nano::pending_info &) = 0; + virtual bool exists (nano::transaction const &, nano::pending_key const &) = 0; + virtual bool any (nano::transaction const &, nano::account const &) = 0; + virtual nano::store_iterator begin (nano::transaction const &, nano::pending_key const &) const = 0; + virtual nano::store_iterator begin (nano::transaction const &) const = 0; + virtual nano::store_iterator end () const = 0; + virtual void for_each_par (std::function, nano::store_iterator)> const & action_a) const = 0; +}; + /** * Manages block storage and iteration */ class block_store { public: - explicit block_store (nano::frontier_store &); + explicit block_store (nano::frontier_store &, nano::pending_store &); virtual ~block_store () = default; virtual void initialize (nano::write_transaction const &, nano::genesis const &, nano::ledger_cache &) = 0; virtual void block_put (nano::write_transaction const &, nano::block_hash const &, nano::block const &) = 0; @@ -670,14 +690,7 @@ class block_store virtual nano::store_iterator accounts_rbegin (nano::transaction const &) const = 0; virtual nano::store_iterator accounts_end () const = 0; - virtual void pending_put (nano::write_transaction const &, nano::pending_key const &, nano::pending_info const &) = 0; - virtual void pending_del (nano::write_transaction const &, nano::pending_key const &) = 0; - virtual bool pending_get (nano::transaction const &, nano::pending_key const &, nano::pending_info &) = 0; - virtual bool pending_exists (nano::transaction const &, nano::pending_key const &) = 0; - virtual bool pending_any (nano::transaction const &, nano::account const &) = 0; - virtual nano::store_iterator pending_begin (nano::transaction const &, nano::pending_key const &) const = 0; - virtual nano::store_iterator pending_begin (nano::transaction const &) const = 0; - virtual nano::store_iterator pending_end () const = 0; + pending_store & pending; virtual nano::uint128_t block_balance (nano::transaction const &, nano::block_hash const &) = 0; virtual nano::uint128_t block_balance_calculated (std::shared_ptr const &) const = 0; @@ -736,7 +749,6 @@ class block_store virtual void accounts_for_each_par (std::function, nano::store_iterator)> const &) const = 0; virtual void confirmation_height_for_each_par (std::function, nano::store_iterator)> const &) const = 0; - virtual void pending_for_each_par (std::function, nano::store_iterator)> const & action_a) const = 0; virtual void unchecked_for_each_par (std::function, nano::store_iterator)> const & action_a) const = 0; virtual void pruned_for_each_par (std::function, nano::store_iterator)> const & action_a) const = 0; virtual void blocks_for_each_par (std::function, nano::store_iterator)> const & action_a) const = 0; diff --git a/nano/secure/blockstore_partial.hpp b/nano/secure/blockstore_partial.hpp index 7a36bcd2d5..c82ac0e172 100644 --- a/nano/secure/blockstore_partial.hpp +++ b/nano/secure/blockstore_partial.hpp @@ -7,6 +7,7 @@ #include #include #include +#include #include @@ -36,7 +37,9 @@ void release_assert_success (block_store_partial const & blo template class block_store_partial : public block_store { - nano::frontier_store_partial frontier_store; + nano::frontier_store_partial frontier_store_partial; + + nano::pending_store_partial pending_store_partial; friend void release_assert_success (block_store_partial const & block_store, const int status); @@ -47,9 +50,12 @@ class block_store_partial : public block_store friend class nano::block_predecessor_set; friend class nano::frontier_store_partial; + friend class nano::pending_store_partial; + block_store_partial () : - block_store{ frontier_store }, - frontier_store{ *this } + block_store{ frontier_store_partial, pending_store_partial }, + frontier_store_partial{ *this }, + pending_store_partial{ *this } { } @@ -230,11 +236,6 @@ class block_store_partial : public block_store return nano::store_iterator (nullptr); } - nano::store_iterator pending_end () const override - { - return nano::store_iterator (nullptr); - } - nano::store_iterator online_weight_end () const override { return nano::store_iterator (nullptr); @@ -304,46 +305,6 @@ class block_store_partial : public block_store release_assert_success (*this, status); } - void pending_put (nano::write_transaction const & transaction_a, nano::pending_key const & key_a, nano::pending_info const & pending_info_a) override - { - nano::db_val pending (pending_info_a); - auto status = put (transaction_a, tables::pending, key_a, pending); - release_assert_success (*this, status); - } - - void pending_del (nano::write_transaction const & transaction_a, nano::pending_key const & key_a) override - { - auto status = del (transaction_a, tables::pending, key_a); - release_assert_success (*this, status); - } - - bool pending_get (nano::transaction const & transaction_a, nano::pending_key const & key_a, nano::pending_info & pending_a) override - { - nano::db_val value; - nano::db_val key (key_a); - auto status1 = get (transaction_a, tables::pending, key, value); - release_assert (success (status1) || not_found (status1)); - bool result (true); - if (success (status1)) - { - nano::bufferstream stream (reinterpret_cast (value.data ()), value.size ()); - result = pending_a.deserialize (stream); - } - return result; - } - - bool pending_exists (nano::transaction const & transaction_a, nano::pending_key const & key_a) override - { - auto iterator (pending_begin (transaction_a, key_a)); - return iterator != pending_end () && nano::pending_key (iterator->first) == key_a; - } - - bool pending_any (nano::transaction const & transaction_a, nano::account const & account_a) override - { - auto iterator (pending_begin (transaction_a, nano::pending_key (account_a, 0))); - return iterator != pending_end () && nano::pending_key (iterator->first).account == account_a; - } - void unchecked_del (nano::write_transaction const & transaction_a, nano::unchecked_key const & key_a) override { auto status (del (transaction_a, tables::unchecked, key_a)); @@ -667,16 +628,6 @@ class block_store_partial : public block_store return make_iterator (transaction_a, tables::blocks, nano::db_val (hash_a)); } - nano::store_iterator pending_begin (nano::transaction const & transaction_a, nano::pending_key const & key_a) const override - { - return make_iterator (transaction_a, tables::pending, nano::db_val (key_a)); - } - - nano::store_iterator pending_begin (nano::transaction const & transaction_a) const override - { - return make_iterator (transaction_a, tables::pending); - } - nano::store_iterator unchecked_begin (nano::transaction const & transaction_a) const override { return make_iterator (transaction_a, tables::unchecked); @@ -760,19 +711,6 @@ class block_store_partial : public block_store }); } - void pending_for_each_par (std::function, nano::store_iterator)> const & action_a) const override - { - parallel_traversal ( - [&action_a, this] (nano::uint512_t const & start, nano::uint512_t const & end, bool const is_last) { - nano::uint512_union union_start (start); - nano::uint512_union union_end (end); - nano::pending_key key_start (union_start.uint256s[0].number (), union_start.uint256s[1].number ()); - nano::pending_key key_end (union_end.uint256s[0].number (), union_end.uint256s[1].number ()); - auto transaction (this->tx_begin_read ()); - action_a (transaction, this->pending_begin (transaction, key_start), !is_last ? this->pending_begin (transaction, key_end) : this->pending_end ()); - }); - } - void unchecked_for_each_par (std::function, nano::store_iterator)> const & action_a) const override { parallel_traversal ( diff --git a/nano/secure/ledger.cpp b/nano/secure/ledger.cpp index 4d571b288a..19e0a465b5 100644 --- a/nano/secure/ledger.cpp +++ b/nano/secure/ledger.cpp @@ -28,7 +28,7 @@ class rollback_visitor : public nano::block_visitor auto hash (block_a.hash ()); nano::pending_info pending; nano::pending_key key (block_a.hashables.destination, hash); - while (!error && ledger.store.pending_get (transaction, key, pending)) + while (!error && ledger.store.pending.get (transaction, key, pending)) { error = ledger.rollback (transaction, ledger.latest (transaction, block_a.hashables.destination), list); } @@ -37,7 +37,7 @@ class rollback_visitor : public nano::block_visitor nano::account_info info; [[maybe_unused]] auto error (ledger.store.account_get (transaction, pending.source, info)); debug_assert (!error); - ledger.store.pending_del (transaction, key); + ledger.store.pending.del (transaction, key); ledger.cache.rep_weights.representation_add (info.representative, pending.amount.number ()); nano::account_info new_info (block_a.hashables.previous, info.representative, info.open_block, ledger.balance (transaction, block_a.hashables.previous), nano::seconds_since_epoch (), info.block_count - 1, nano::epoch::epoch_0); ledger.update_account (transaction, pending.source, info, new_info); @@ -63,7 +63,7 @@ class rollback_visitor : public nano::block_visitor 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.update_account (transaction, destination_account, info, new_info); ledger.store.block_del (transaction, hash); - ledger.store.pending_put (transaction, nano::pending_key (destination_account, block_a.hashables.source), { source_account, amount, nano::epoch::epoch_0 }); + ledger.store.pending.put (transaction, nano::pending_key (destination_account, block_a.hashables.source), { source_account, amount, nano::epoch::epoch_0 }); ledger.store.frontier.del (transaction, hash); ledger.store.frontier.put (transaction, block_a.hashables.previous, destination_account); ledger.store.block_successor_clear (transaction, block_a.hashables.previous); @@ -81,7 +81,7 @@ class rollback_visitor : public nano::block_visitor nano::account_info new_info; ledger.update_account (transaction, destination_account, new_info, new_info); ledger.store.block_del (transaction, hash); - ledger.store.pending_put (transaction, nano::pending_key (destination_account, block_a.hashables.source), { source_account, amount, nano::epoch::epoch_0 }); + ledger.store.pending.put (transaction, nano::pending_key (destination_account, block_a.hashables.source), { source_account, amount, nano::epoch::epoch_0 }); ledger.store.frontier.del (transaction, hash); ledger.stats.inc (nano::stat::type::rollback, nano::stat::detail::open); } @@ -137,11 +137,11 @@ class rollback_visitor : public nano::block_visitor if (is_send) { nano::pending_key key (block_a.hashables.link.as_account (), hash); - while (!error && !ledger.store.pending_exists (transaction, key)) + while (!error && !ledger.store.pending.exists (transaction, key)) { error = ledger.rollback (transaction, ledger.latest (transaction, block_a.hashables.link.as_account ()), list); } - ledger.store.pending_del (transaction, key); + ledger.store.pending.del (transaction, key); ledger.stats.inc (nano::stat::type::rollback, nano::stat::detail::send); } else if (!block_a.hashables.link.is_zero () && !ledger.is_epoch_link (block_a.hashables.link)) @@ -150,7 +150,7 @@ class rollback_visitor : public nano::block_visitor [[maybe_unused]] bool is_pruned (false); auto source_account (ledger.account_safe (transaction, block_a.hashables.link.as_block_hash (), is_pruned)); nano::pending_info pending_info (source_account, block_a.hashables.balance.number () - balance, block_a.sideband ().source_epoch); - ledger.store.pending_put (transaction, nano::pending_key (block_a.hashables.account, block_a.hashables.link.as_block_hash ()), pending_info); + ledger.store.pending.put (transaction, nano::pending_key (block_a.hashables.account, block_a.hashables.link.as_block_hash ()), pending_info); ledger.stats.inc (nano::stat::type::rollback, nano::stat::detail::receive); } @@ -327,7 +327,7 @@ void ledger_processor::state_block_impl (nano::state_block & block_a) { nano::pending_key key (block_a.hashables.account, block_a.hashables.link.as_block_hash ()); nano::pending_info pending; - result.code = ledger.store.pending_get (transaction, key, pending) ? nano::process_result::unreceivable : nano::process_result::progress; // Has this source already been received (Malformed) + result.code = ledger.store.pending.get (transaction, key, pending) ? nano::process_result::unreceivable : nano::process_result::progress; // Has this source already been received (Malformed) if (result.code == nano::process_result::progress) { result.code = amount == pending.amount ? nano::process_result::progress : nano::process_result::balance_mismatch; @@ -368,11 +368,11 @@ void ledger_processor::state_block_impl (nano::state_block & block_a) { nano::pending_key key (block_a.hashables.link.as_account (), hash); nano::pending_info info (block_a.hashables.account, amount.number (), epoch); - ledger.store.pending_put (transaction, key, info); + ledger.store.pending.put (transaction, key, info); } else if (!block_a.hashables.link.is_zero ()) { - ledger.store.pending_del (transaction, nano::pending_key (block_a.hashables.account, block_a.hashables.link.as_block_hash ())); + ledger.store.pending.del (transaction, nano::pending_key (block_a.hashables.account, block_a.hashables.link.as_block_hash ())); } nano::account_info new_info (hash, block_a.representative (), info.open_block.is_zero () ? hash : info.open_block, block_a.hashables.balance, nano::seconds_since_epoch (), info.block_count + 1, epoch); @@ -430,7 +430,7 @@ void ledger_processor::epoch_block_impl (nano::state_block & block_a) // Non-exisitng account should have pending entries if (result.code == nano::process_result::progress) { - bool pending_exists = ledger.store.pending_any (transaction, block_a.hashables.account); + bool pending_exists = ledger.store.pending.any (transaction, block_a.hashables.account); result.code = pending_exists ? nano::process_result::progress : nano::process_result::gap_epoch_open_pending; } } @@ -566,7 +566,7 @@ void ledger_processor::send_block (nano::send_block & block_a) ledger.store.block_put (transaction, hash, block_a); nano::account_info new_info (hash, info.representative, info.open_block, block_a.hashables.balance, nano::seconds_since_epoch (), info.block_count + 1, nano::epoch::epoch_0); ledger.update_account (transaction, account, info, new_info); - ledger.store.pending_put (transaction, nano::pending_key (block_a.hashables.destination, hash), { account, amount, nano::epoch::epoch_0 }); + ledger.store.pending.put (transaction, nano::pending_key (block_a.hashables.destination, hash), { account, amount, nano::epoch::epoch_0 }); ledger.store.frontier.del (transaction, block_a.hashables.previous); ledger.store.frontier.put (transaction, hash, account); result.previous_balance = info.balance; @@ -617,7 +617,7 @@ void ledger_processor::receive_block (nano::receive_block & block_a) { nano::pending_key key (account, block_a.hashables.source); nano::pending_info pending; - result.code = ledger.store.pending_get (transaction, key, pending) ? nano::process_result::unreceivable : nano::process_result::progress; // Has this source already been received (Malformed) + result.code = ledger.store.pending.get (transaction, key, pending) ? nano::process_result::unreceivable : nano::process_result::progress; // Has this source already been received (Malformed) if (result.code == nano::process_result::progress) { result.code = pending.epoch == nano::epoch::epoch_0 ? nano::process_result::progress : nano::process_result::unreceivable; // Are we receiving a state-only send? (Malformed) @@ -636,7 +636,7 @@ void ledger_processor::receive_block (nano::receive_block & block_a) debug_assert (!error); } #endif - ledger.store.pending_del (transaction, key); + ledger.store.pending.del (transaction, key); block_a.sideband_set (nano::block_sideband (account, 0, new_balance, info.block_count + 1, nano::seconds_since_epoch (), block_details, nano::epoch::epoch_0 /* unused */)); ledger.store.block_put (transaction, hash, block_a); nano::account_info new_info (hash, info.representative, info.open_block, new_balance, nano::seconds_since_epoch (), info.block_count + 1, nano::epoch::epoch_0); @@ -687,7 +687,7 @@ void ledger_processor::open_block (nano::open_block & block_a) { nano::pending_key key (block_a.hashables.account, block_a.hashables.source); nano::pending_info pending; - result.code = ledger.store.pending_get (transaction, key, pending) ? nano::process_result::unreceivable : nano::process_result::progress; // Has this source already been received (Malformed) + result.code = ledger.store.pending.get (transaction, key, pending) ? nano::process_result::unreceivable : nano::process_result::progress; // Has this source already been received (Malformed) if (result.code == nano::process_result::progress) { result.code = block_a.hashables.account == ledger.network_params.ledger.burn_account ? nano::process_result::opened_burn_account : nano::process_result::progress; // Is it burning 0 account? (Malicious) @@ -708,7 +708,7 @@ void ledger_processor::open_block (nano::open_block & block_a) debug_assert (!error); } #endif - ledger.store.pending_del (transaction, key); + ledger.store.pending.del (transaction, key); block_a.sideband_set (nano::block_sideband (block_a.hashables.account, 0, pending.amount, 1, nano::seconds_since_epoch (), block_details, nano::epoch::epoch_0 /* unused */)); ledger.store.block_put (transaction, hash, block_a); nano::account_info new_info (hash, block_a.representative (), hash, pending.amount.number (), nano::seconds_since_epoch (), 1, nano::epoch::epoch_0); @@ -842,7 +842,7 @@ nano::uint128_t nano::ledger::account_pending (nano::transaction const & transac { nano::uint128_t result (0); nano::account end (account_a.number () + 1); - for (auto i (store.pending_begin (transaction_a, nano::pending_key (account_a, 0))), n (store.pending_begin (transaction_a, nano::pending_key (end, 0))); i != n; ++i) + for (auto i (store.pending.begin (transaction_a, nano::pending_key (account_a, 0))), n (store.pending.begin (transaction_a, nano::pending_key (end, 0))); i != n; ++i) { nano::pending_info const & info (i->second); if (only_confirmed_a) @@ -1445,12 +1445,12 @@ bool nano::ledger::migrate_lmdb_to_rocksdb (boost::filesystem::path const & data } }); - store.pending_for_each_par ( + store.pending.for_each_par ( [&rocksdb_store] (nano::read_transaction const & /*unused*/, auto i, auto n) { for (; i != n; ++i) { auto rocksdb_transaction (rocksdb_store->tx_begin_write ({}, { nano::tables::pending })); - rocksdb_store->pending_put (rocksdb_transaction, i->first, i->second); + rocksdb_store->pending.put (rocksdb_transaction, i->first, i->second); } }); diff --git a/nano/secure/store/pending_store_partial.hpp b/nano/secure/store/pending_store_partial.hpp new file mode 100644 index 0000000000..bfe1502cc1 --- /dev/null +++ b/nano/secure/store/pending_store_partial.hpp @@ -0,0 +1,100 @@ +#pragma once + +#include + +namespace +{ +template +void parallel_traversal (std::function const & action); +} + +namespace nano +{ +template +class block_store_partial; + +template +void release_assert_success (block_store_partial const & block_store, const int status); + +template +class pending_store_partial : public pending_store +{ +private: + nano::block_store_partial & block_store; + + friend void release_assert_success (block_store_partial const & block_store, const int status); + +public: + explicit pending_store_partial (nano::block_store_partial & block_store_a) : + block_store (block_store_a){}; + + void put (nano::write_transaction const & transaction_a, nano::pending_key const & key_a, nano::pending_info const & pending_info_a) override + { + nano::db_val pending (pending_info_a); + auto status = block_store.put (transaction_a, tables::pending, key_a, pending); + release_assert_success (block_store, status); + } + + void del (nano::write_transaction const & transaction_a, nano::pending_key const & key_a) override + { + auto status = block_store.del (transaction_a, tables::pending, key_a); + release_assert_success (block_store, status); + } + + bool get (nano::transaction const & transaction_a, nano::pending_key const & key_a, nano::pending_info & pending_a) override + { + nano::db_val value; + nano::db_val key (key_a); + auto status1 = block_store.get (transaction_a, tables::pending, key, value); + release_assert (block_store.success (status1) || block_store.not_found (status1)); + bool result (true); + if (block_store.success (status1)) + { + nano::bufferstream stream (reinterpret_cast (value.data ()), value.size ()); + result = pending_a.deserialize (stream); + } + return result; + } + + bool exists (nano::transaction const & transaction_a, nano::pending_key const & key_a) override + { + auto iterator (begin (transaction_a, key_a)); + return iterator != end () && nano::pending_key (iterator->first) == key_a; + } + + bool any (nano::transaction const & transaction_a, nano::account const & account_a) override + { + auto iterator (begin (transaction_a, nano::pending_key (account_a, 0))); + return iterator != end () && nano::pending_key (iterator->first).account == account_a; + } + + nano::store_iterator begin (nano::transaction const & transaction_a, nano::pending_key const & key_a) const override + { + return block_store.template make_iterator (transaction_a, tables::pending, nano::db_val (key_a)); + } + + nano::store_iterator begin (nano::transaction const & transaction_a) const override + { + return block_store.template make_iterator (transaction_a, tables::pending); + } + + nano::store_iterator end () const override + { + return nano::store_iterator (nullptr); + } + + void for_each_par (std::function, nano::store_iterator)> const & action_a) const override + { + parallel_traversal ( + [&action_a, this] (nano::uint512_t const & start, nano::uint512_t const & end, bool const is_last) { + nano::uint512_union union_start (start); + nano::uint512_union union_end (end); + nano::pending_key key_start (union_start.uint256s[0].number (), union_start.uint256s[1].number ()); + nano::pending_key key_end (union_end.uint256s[0].number (), union_end.uint256s[1].number ()); + auto transaction (this->block_store.tx_begin_read ()); + action_a (transaction, this->begin (transaction, key_start), !is_last ? this->begin (transaction, key_end) : this->end ()); + }); + } +}; + +}