Further removal of templates in db classes (#3785)
* Splitting release_assert_success in to lmdb/rocksdb variants and removing function from store_partial. This is one of the leaky abstractions resulting from the former templated code. lmdb exposes return statuses with int while rocksdb uses an enum class. Removing the leaky abstraction will allow this code to be specialized to the backend type and flow more logically. * Moving the parallel_traversal algorithm in to its own file. * Moving version number constants off of store_partial and on to store. Changing each to constexpr values. * Moving root_exists on to ledger since it's not a direct operation on store. * Removing unused functions from store_partial. * Remove put_key function as using a nullptr value has equivalent semantics and this is how it's actually implemented. * Removing unused functions and moving several functions from nano::store_partial to nano::store. * Renaming mdb_store and rocksdb_store to lmdb::store and rocksdb::store, respectively. * Moving ::initialize from store_partial to store. * Removing store_partial. * Formatting.
This commit is contained in:
parent
596e9a22df
commit
e4deda757a
64 changed files with 784 additions and 897 deletions
|
@ -26,11 +26,11 @@ using namespace std::chrono_literals;
|
|||
|
||||
namespace
|
||||
{
|
||||
void modify_account_info_to_v14 (nano::mdb_store & store, nano::transaction const & transaction_a, nano::account const & account_a, uint64_t confirmation_height, nano::block_hash const & rep_block);
|
||||
void modify_confirmation_height_to_v15 (nano::mdb_store & store, nano::transaction const & transaction, nano::account const & account, uint64_t confirmation_height);
|
||||
void write_sideband_v14 (nano::mdb_store & store_a, nano::transaction & transaction_a, nano::block const & block_a, MDB_dbi db_a);
|
||||
void write_sideband_v15 (nano::mdb_store & store_a, nano::transaction & transaction_a, nano::block const & block_a);
|
||||
void write_block_w_sideband_v18 (nano::mdb_store & store_a, MDB_dbi database, nano::write_transaction & transaction_a, nano::block const & block_a);
|
||||
void modify_account_info_to_v14 (nano::lmdb::store & store, nano::transaction const & transaction_a, nano::account const & account_a, uint64_t confirmation_height, nano::block_hash const & rep_block);
|
||||
void modify_confirmation_height_to_v15 (nano::lmdb::store & store, nano::transaction const & transaction, nano::account const & account, uint64_t confirmation_height);
|
||||
void write_sideband_v14 (nano::lmdb::store & store_a, nano::transaction & transaction_a, nano::block const & block_a, MDB_dbi db_a);
|
||||
void write_sideband_v15 (nano::lmdb::store & store_a, nano::transaction & transaction_a, nano::block const & block_a);
|
||||
void write_block_w_sideband_v18 (nano::lmdb::store & store_a, MDB_dbi database, nano::write_transaction & transaction_a, nano::block const & block_a);
|
||||
}
|
||||
|
||||
TEST (block_store, construction)
|
||||
|
@ -328,7 +328,7 @@ TEST (block_store, genesis)
|
|||
ASSERT_TRUE (!store->init_error ());
|
||||
nano::ledger_cache ledger_cache;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger_cache);
|
||||
store->initialize (transaction, ledger_cache, nano::dev::constants);
|
||||
nano::account_info info;
|
||||
ASSERT_FALSE (store->account.get (transaction, nano::dev::genesis->account (), info));
|
||||
ASSERT_EQ (nano::dev::genesis->hash (), info.head);
|
||||
|
@ -699,31 +699,31 @@ TEST (mdb_block_store, supported_version_upgrades)
|
|||
auto path (nano::unique_path ());
|
||||
nano::logger_mt logger;
|
||||
{
|
||||
nano::mdb_store store (logger, path, nano::dev::constants);
|
||||
nano::lmdb::store store (logger, path, nano::dev::constants);
|
||||
nano::stat stats;
|
||||
nano::ledger ledger (store, stats, nano::dev::constants);
|
||||
auto transaction (store.tx_begin_write ());
|
||||
store.initialize (transaction, ledger.cache);
|
||||
store.initialize (transaction, ledger.cache, nano::dev::constants);
|
||||
// Lower the database to the max version unsupported for upgrades
|
||||
store.version.put (transaction, store.minimum_version - 1);
|
||||
store.version.put (transaction, store.version_minimum - 1);
|
||||
}
|
||||
|
||||
// Upgrade should fail
|
||||
{
|
||||
nano::mdb_store store (logger, path, nano::dev::constants);
|
||||
nano::lmdb::store store (logger, path, nano::dev::constants);
|
||||
ASSERT_TRUE (store.init_error ());
|
||||
}
|
||||
|
||||
auto path1 (nano::unique_path ());
|
||||
// Now try with the minimum version
|
||||
{
|
||||
nano::mdb_store store (logger, path1, nano::dev::constants);
|
||||
nano::lmdb::store store (logger, path1, nano::dev::constants);
|
||||
nano::stat stats;
|
||||
nano::ledger ledger (store, stats, nano::dev::constants);
|
||||
auto transaction (store.tx_begin_write ());
|
||||
store.initialize (transaction, ledger.cache);
|
||||
store.initialize (transaction, ledger.cache, nano::dev::constants);
|
||||
// Lower the database version to the minimum version supported for upgrade.
|
||||
store.version.put (transaction, store.minimum_version);
|
||||
store.version.put (transaction, store.version_minimum);
|
||||
store.confirmation_height.del (transaction, nano::dev::genesis->account ());
|
||||
ASSERT_FALSE (mdb_dbi_open (store.env.tx (transaction), "accounts_v1", MDB_CREATE, &store.accounts_v1_handle));
|
||||
ASSERT_FALSE (mdb_dbi_open (store.env.tx (transaction), "open", MDB_CREATE, &store.open_blocks_handle));
|
||||
|
@ -733,7 +733,7 @@ TEST (mdb_block_store, supported_version_upgrades)
|
|||
|
||||
// Upgrade should work
|
||||
{
|
||||
nano::mdb_store store (logger, path1, nano::dev::constants);
|
||||
nano::lmdb::store store (logger, path1, nano::dev::constants);
|
||||
ASSERT_FALSE (store.init_error ());
|
||||
}
|
||||
}
|
||||
|
@ -746,7 +746,7 @@ TEST (mdb_block_store, bad_path)
|
|||
return;
|
||||
}
|
||||
nano::logger_mt logger;
|
||||
nano::mdb_store store (logger, boost::filesystem::path ("///"), nano::dev::constants);
|
||||
nano::lmdb::store store (logger, boost::filesystem::path ("///"), nano::dev::constants);
|
||||
ASSERT_TRUE (store.init_error ());
|
||||
}
|
||||
|
||||
|
@ -916,7 +916,7 @@ TEST (block_store, cemented_count_cache)
|
|||
ASSERT_TRUE (!store->init_error ());
|
||||
auto transaction (store->tx_begin_write ());
|
||||
nano::ledger_cache ledger_cache;
|
||||
store->initialize (transaction, ledger_cache);
|
||||
store->initialize (transaction, ledger_cache, nano::dev::constants);
|
||||
ASSERT_EQ (1, ledger_cache.cemented_count);
|
||||
}
|
||||
|
||||
|
@ -927,7 +927,7 @@ TEST (block_store, block_random)
|
|||
{
|
||||
nano::ledger_cache ledger_cache;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger_cache);
|
||||
store->initialize (transaction, ledger_cache, nano::dev::constants);
|
||||
}
|
||||
auto transaction (store->tx_begin_read ());
|
||||
auto block (store->block.random (transaction));
|
||||
|
@ -946,7 +946,7 @@ TEST (block_store, pruned_random)
|
|||
{
|
||||
nano::ledger_cache ledger_cache;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger_cache);
|
||||
store->initialize (transaction, ledger_cache, nano::dev::constants);
|
||||
store->pruned.put (transaction, hash1);
|
||||
}
|
||||
auto transaction (store->tx_begin_read ());
|
||||
|
@ -959,7 +959,7 @@ TEST (block_store, DISABLED_change_dupsort) // Unchecked is no longer dupsort ta
|
|||
{
|
||||
auto path (nano::unique_path ());
|
||||
nano::logger_mt logger{};
|
||||
nano::mdb_store store{ logger, path, nano::dev::constants };
|
||||
nano::lmdb::store store{ logger, path, nano::dev::constants };
|
||||
nano::unchecked_map unchecked{ store, false };
|
||||
auto transaction (store.tx_begin_write ());
|
||||
ASSERT_EQ (0, mdb_drop (store.env.tx (transaction), store.unchecked_handle, 1));
|
||||
|
@ -991,7 +991,7 @@ TEST (block_store, state_block)
|
|||
{
|
||||
nano::ledger_cache ledger_cache;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger_cache);
|
||||
store->initialize (transaction, ledger_cache, nano::dev::constants);
|
||||
ASSERT_EQ (nano::block_type::state, block1.type ());
|
||||
store->block.put (transaction, block1.hash (), block1);
|
||||
ASSERT_TRUE (store->block.exists (transaction, block1.hash ()));
|
||||
|
@ -1022,12 +1022,12 @@ TEST (mdb_block_store, sideband_height)
|
|||
nano::keypair key1;
|
||||
nano::keypair key2;
|
||||
nano::keypair key3;
|
||||
nano::mdb_store store (logger, nano::unique_path (), nano::dev::constants);
|
||||
nano::lmdb::store store (logger, nano::unique_path (), nano::dev::constants);
|
||||
ASSERT_FALSE (store.init_error ());
|
||||
nano::stat stat;
|
||||
nano::ledger ledger (store, stat, nano::dev::constants);
|
||||
auto transaction (store.tx_begin_write ());
|
||||
store.initialize (transaction, ledger.cache);
|
||||
store.initialize (transaction, ledger.cache, nano::dev::constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::send_block send (nano::dev::genesis->hash (), nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send).code);
|
||||
|
@ -1290,11 +1290,11 @@ TEST (mdb_block_store, upgrade_v14_v15)
|
|||
nano::state_block state_send (nano::dev::genesis_key.pub, epoch.hash (), nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio * 2, nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (epoch.hash ()));
|
||||
{
|
||||
nano::logger_mt logger;
|
||||
nano::mdb_store store (logger, path, nano::dev::constants);
|
||||
nano::lmdb::store store (logger, path, nano::dev::constants);
|
||||
nano::stat stats;
|
||||
nano::ledger ledger (store, stats, nano::dev::constants);
|
||||
auto transaction (store.tx_begin_write ());
|
||||
store.initialize (transaction, ledger.cache);
|
||||
store.initialize (transaction, ledger.cache, nano::dev::constants);
|
||||
nano::account_info account_info;
|
||||
ASSERT_FALSE (store.account.get (transaction, nano::dev::genesis->account (), account_info));
|
||||
nano::confirmation_height_info confirmation_height_info;
|
||||
|
@ -1344,7 +1344,7 @@ TEST (mdb_block_store, upgrade_v14_v15)
|
|||
|
||||
// Now do the upgrade
|
||||
nano::logger_mt logger;
|
||||
nano::mdb_store store (logger, path, nano::dev::constants);
|
||||
nano::lmdb::store store (logger, path, nano::dev::constants);
|
||||
ASSERT_FALSE (store.init_error ());
|
||||
auto transaction (store.tx_begin_read ());
|
||||
|
||||
|
@ -1397,11 +1397,11 @@ TEST (mdb_block_store, upgrade_v15_v16)
|
|||
nano::mdb_val value;
|
||||
{
|
||||
nano::logger_mt logger;
|
||||
nano::mdb_store store (logger, path, nano::dev::constants);
|
||||
nano::lmdb::store store (logger, path, nano::dev::constants);
|
||||
nano::stat stats;
|
||||
nano::ledger ledger (store, stats, nano::dev::constants);
|
||||
auto transaction (store.tx_begin_write ());
|
||||
store.initialize (transaction, ledger.cache);
|
||||
store.initialize (transaction, ledger.cache, nano::dev::constants);
|
||||
// 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_handle));
|
||||
|
@ -1418,7 +1418,7 @@ TEST (mdb_block_store, upgrade_v15_v16)
|
|||
|
||||
// Now do the upgrade
|
||||
nano::logger_mt logger;
|
||||
nano::mdb_store store (logger, path, nano::dev::constants);
|
||||
nano::lmdb::store store (logger, path, nano::dev::constants);
|
||||
ASSERT_FALSE (store.init_error ());
|
||||
auto transaction (store.tx_begin_read ());
|
||||
|
||||
|
@ -1448,11 +1448,11 @@ TEST (mdb_block_store, upgrade_v16_v17)
|
|||
nano::mdb_val value;
|
||||
{
|
||||
nano::logger_mt logger;
|
||||
nano::mdb_store store (logger, path, nano::dev::constants);
|
||||
nano::lmdb::store store (logger, path, nano::dev::constants);
|
||||
nano::stat stats;
|
||||
nano::ledger ledger (store, stats, nano::dev::constants);
|
||||
auto transaction (store.tx_begin_write ());
|
||||
store.initialize (transaction, ledger.cache);
|
||||
store.initialize (transaction, ledger.cache, nano::dev::constants);
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, block1).code);
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, block2).code);
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, block3).code);
|
||||
|
@ -1471,7 +1471,7 @@ TEST (mdb_block_store, upgrade_v16_v17)
|
|||
|
||||
// Now do the upgrade
|
||||
nano::logger_mt logger;
|
||||
nano::mdb_store store (logger, path, nano::dev::constants);
|
||||
nano::lmdb::store store (logger, path, nano::dev::constants);
|
||||
ASSERT_FALSE (store.init_error ());
|
||||
auto transaction (store.tx_begin_read ());
|
||||
|
||||
|
@ -1519,11 +1519,11 @@ TEST (mdb_block_store, upgrade_v17_v18)
|
|||
nano::state_block state_send_epoch_link (key2.pub, state_open.hash (), key2.pub, 0, nano::dev::network_params.ledger.epochs.link (nano::epoch::epoch_2), key2.prv, key2.pub, *pool.generate (state_open.hash ()));
|
||||
{
|
||||
nano::logger_mt logger;
|
||||
nano::mdb_store store (logger, path, nano::dev::constants);
|
||||
nano::lmdb::store store (logger, path, nano::dev::constants);
|
||||
auto transaction (store.tx_begin_write ());
|
||||
nano::stat stats;
|
||||
nano::ledger ledger (store, stats, nano::dev::constants);
|
||||
store.initialize (transaction, ledger.cache);
|
||||
store.initialize (transaction, ledger.cache, nano::dev::constants);
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send_zero).code);
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, state_receive_zero).code);
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, epoch).code);
|
||||
|
@ -1572,7 +1572,7 @@ TEST (mdb_block_store, upgrade_v17_v18)
|
|||
|
||||
// Now do the upgrade
|
||||
nano::logger_mt logger;
|
||||
nano::mdb_store store (logger, path, nano::dev::constants);
|
||||
nano::lmdb::store store (logger, path, nano::dev::constants);
|
||||
ASSERT_FALSE (store.init_error ());
|
||||
auto transaction (store.tx_begin_read ());
|
||||
|
||||
|
@ -1714,11 +1714,11 @@ TEST (mdb_block_store, upgrade_v18_v19)
|
|||
|
||||
{
|
||||
nano::logger_mt logger;
|
||||
nano::mdb_store store (logger, path, nano::dev::constants);
|
||||
nano::lmdb::store store (logger, path, nano::dev::constants);
|
||||
nano::stat stats;
|
||||
nano::ledger ledger (store, stats, nano::dev::constants);
|
||||
auto transaction (store.tx_begin_write ());
|
||||
store.initialize (transaction, ledger.cache);
|
||||
store.initialize (transaction, ledger.cache, nano::dev::constants);
|
||||
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send).code);
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, receive).code);
|
||||
|
@ -1749,7 +1749,7 @@ TEST (mdb_block_store, upgrade_v18_v19)
|
|||
|
||||
// Now do the upgrade
|
||||
nano::logger_mt logger;
|
||||
nano::mdb_store store (logger, path, nano::dev::constants);
|
||||
nano::lmdb::store store (logger, path, nano::dev::constants);
|
||||
ASSERT_FALSE (store.init_error ());
|
||||
auto transaction (store.tx_begin_read ());
|
||||
|
||||
|
@ -1797,16 +1797,16 @@ TEST (mdb_block_store, upgrade_v19_v20)
|
|||
nano::logger_mt logger;
|
||||
nano::stat stats;
|
||||
{
|
||||
nano::mdb_store store (logger, path, nano::dev::constants);
|
||||
nano::lmdb::store store (logger, path, nano::dev::constants);
|
||||
nano::ledger ledger (store, stats, nano::dev::constants);
|
||||
auto transaction (store.tx_begin_write ());
|
||||
store.initialize (transaction, ledger.cache);
|
||||
store.initialize (transaction, ledger.cache, nano::dev::constants);
|
||||
// Delete pruned table
|
||||
ASSERT_FALSE (mdb_drop (store.env.tx (transaction), store.pruned_handle, 1));
|
||||
store.version.put (transaction, 19);
|
||||
}
|
||||
// Upgrading should create the table
|
||||
nano::mdb_store store (logger, path, nano::dev::constants);
|
||||
nano::lmdb::store store (logger, path, nano::dev::constants);
|
||||
ASSERT_FALSE (store.init_error ());
|
||||
ASSERT_NE (store.pruned_handle, 0);
|
||||
|
||||
|
@ -1826,16 +1826,16 @@ TEST (mdb_block_store, upgrade_v20_v21)
|
|||
nano::logger_mt logger;
|
||||
nano::stat stats;
|
||||
{
|
||||
nano::mdb_store store (logger, path, nano::dev::constants);
|
||||
nano::lmdb::store store (logger, path, nano::dev::constants);
|
||||
nano::ledger ledger (store, stats, nano::dev::constants);
|
||||
auto transaction (store.tx_begin_write ());
|
||||
store.initialize (transaction, ledger.cache);
|
||||
store.initialize (transaction, ledger.cache, ledger.constants);
|
||||
// Delete pruned table
|
||||
ASSERT_FALSE (mdb_drop (store.env.tx (transaction), store.final_votes_handle, 1));
|
||||
store.version.put (transaction, 20);
|
||||
}
|
||||
// Upgrading should create the table
|
||||
nano::mdb_store store (logger, path, nano::dev::constants);
|
||||
nano::lmdb::store store (logger, path, nano::dev::constants);
|
||||
ASSERT_FALSE (store.init_error ());
|
||||
ASSERT_NE (store.final_votes_handle, 0);
|
||||
|
||||
|
@ -1869,7 +1869,7 @@ TEST (mdb_block_store, upgrade_backup)
|
|||
|
||||
{
|
||||
nano::logger_mt logger;
|
||||
nano::mdb_store store (logger, path, nano::dev::constants);
|
||||
nano::lmdb::store store (logger, path, nano::dev::constants);
|
||||
auto transaction (store.tx_begin_write ());
|
||||
store.version.put (transaction, 14);
|
||||
}
|
||||
|
@ -1877,7 +1877,7 @@ TEST (mdb_block_store, upgrade_backup)
|
|||
|
||||
// Now do the upgrade and confirm that backup is saved
|
||||
nano::logger_mt logger;
|
||||
nano::mdb_store store (logger, path, nano::dev::constants, nano::txn_tracking_config{}, std::chrono::seconds (5), nano::lmdb_config{}, true);
|
||||
nano::lmdb::store store (logger, path, nano::dev::constants, nano::txn_tracking_config{}, std::chrono::seconds (5), nano::lmdb_config{}, true);
|
||||
ASSERT_FALSE (store.init_error ());
|
||||
auto transaction (store.tx_begin_read ());
|
||||
ASSERT_LT (14, store.version.get (transaction));
|
||||
|
@ -2027,10 +2027,10 @@ TEST (block_store, rocksdb_force_test_env_variable)
|
|||
|
||||
auto store = nano::make_store (logger, nano::unique_path (), nano::dev::constants);
|
||||
|
||||
auto mdb_cast = dynamic_cast<nano::mdb_store *> (store.get ());
|
||||
auto mdb_cast = dynamic_cast<nano::lmdb::store *> (store.get ());
|
||||
if (value && boost::lexical_cast<int> (value) == 1)
|
||||
{
|
||||
ASSERT_NE (boost::polymorphic_downcast<nano::rocksdb_store *> (store.get ()), nullptr);
|
||||
ASSERT_NE (boost::polymorphic_downcast<nano::rocksdb::store *> (store.get ()), nullptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2048,7 +2048,7 @@ TEST (rocksdb_block_store, tombstone_count)
|
|||
{
|
||||
nano::system system{};
|
||||
nano::logger_mt logger{};
|
||||
auto store = std::make_unique<nano::rocksdb_store> (logger, nano::unique_path (), nano::dev::constants);
|
||||
auto store = std::make_unique<nano::rocksdb::store> (logger, nano::unique_path (), nano::dev::constants);
|
||||
nano::unchecked_map unchecked{ *store, false };
|
||||
ASSERT_TRUE (!store->init_error ());
|
||||
std::shared_ptr<nano::block> block = std::make_shared<nano::send_block> (0, 1, 2, nano::keypair ().prv, 4, 5);
|
||||
|
@ -2069,7 +2069,7 @@ TEST (rocksdb_block_store, tombstone_count)
|
|||
|
||||
namespace
|
||||
{
|
||||
void write_sideband_v14 (nano::mdb_store & store_a, nano::transaction & transaction_a, nano::block const & block_a, MDB_dbi db_a)
|
||||
void write_sideband_v14 (nano::lmdb::store & store_a, nano::transaction & transaction_a, nano::block const & block_a, MDB_dbi db_a)
|
||||
{
|
||||
auto block = store_a.block.get (transaction_a, block_a.hash ());
|
||||
ASSERT_NE (block, nullptr);
|
||||
|
@ -2086,7 +2086,7 @@ void write_sideband_v14 (nano::mdb_store & store_a, nano::transaction & transact
|
|||
ASSERT_FALSE (mdb_put (store_a.env.tx (transaction_a), block->sideband ().details.epoch == nano::epoch::epoch_0 ? store_a.state_blocks_v0_handle : store_a.state_blocks_v1_handle, nano::mdb_val (block_a.hash ()), &val, 0));
|
||||
}
|
||||
|
||||
void write_sideband_v15 (nano::mdb_store & store_a, nano::transaction & transaction_a, nano::block const & block_a)
|
||||
void write_sideband_v15 (nano::lmdb::store & store_a, nano::transaction & transaction_a, nano::block const & block_a)
|
||||
{
|
||||
auto block = store_a.block.get (transaction_a, block_a.hash ());
|
||||
ASSERT_NE (block, nullptr);
|
||||
|
@ -2105,7 +2105,7 @@ void write_sideband_v15 (nano::mdb_store & store_a, nano::transaction & transact
|
|||
ASSERT_FALSE (mdb_put (store_a.env.tx (transaction_a), store_a.state_blocks_handle, nano::mdb_val (block_a.hash ()), &val, 0));
|
||||
}
|
||||
|
||||
void write_block_w_sideband_v18 (nano::mdb_store & store_a, MDB_dbi database, nano::write_transaction & transaction_a, nano::block const & block_a)
|
||||
void write_block_w_sideband_v18 (nano::lmdb::store & store_a, MDB_dbi database, nano::write_transaction & transaction_a, nano::block const & block_a)
|
||||
{
|
||||
auto block = store_a.block.get (transaction_a, block_a.hash ());
|
||||
ASSERT_NE (block, nullptr);
|
||||
|
@ -2124,7 +2124,7 @@ void write_block_w_sideband_v18 (nano::mdb_store & store_a, MDB_dbi database, na
|
|||
store_a.del (transaction_a, nano::tables::blocks, nano::mdb_val (block_a.hash ()));
|
||||
}
|
||||
|
||||
void modify_account_info_to_v14 (nano::mdb_store & store, nano::transaction const & transaction, nano::account const & account, uint64_t confirmation_height, nano::block_hash const & rep_block)
|
||||
void modify_account_info_to_v14 (nano::lmdb::store & store, nano::transaction const & transaction, nano::account const & account, uint64_t confirmation_height, nano::block_hash const & rep_block)
|
||||
{
|
||||
nano::account_info info;
|
||||
ASSERT_FALSE (store.account.get (transaction, account, info));
|
||||
|
@ -2133,7 +2133,7 @@ void modify_account_info_to_v14 (nano::mdb_store & store, nano::transaction cons
|
|||
ASSERT_EQ (status, 0);
|
||||
}
|
||||
|
||||
void modify_confirmation_height_to_v15 (nano::mdb_store & store, nano::transaction const & transaction, nano::account const & account, uint64_t confirmation_height)
|
||||
void modify_confirmation_height_to_v15 (nano::lmdb::store & store, nano::transaction const & transaction, nano::account const & account, uint64_t confirmation_height)
|
||||
{
|
||||
auto status (mdb_put (store.env.tx (transaction), store.confirmation_height_handle, nano::mdb_val (account), nano::mdb_val (confirmation_height), 0));
|
||||
ASSERT_EQ (status, 0);
|
||||
|
|
|
@ -764,7 +764,7 @@ TEST (confirmation_heightDeathTest, rollback_added_block)
|
|||
auto send = std::make_shared<nano::send_block> (nano::dev::genesis->hash (), key1.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
{
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
}
|
||||
|
||||
uint64_t batch_write_size = 2048;
|
||||
|
@ -840,7 +840,7 @@ TEST (confirmation_heightDeathTest, modified_chain)
|
|||
auto send = std::make_shared<nano::send_block> (nano::dev::genesis->hash (), key1.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
{
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, *send).code);
|
||||
}
|
||||
|
||||
|
@ -911,7 +911,7 @@ TEST (confirmation_heightDeathTest, modified_chain_account_removed)
|
|||
auto open = std::make_shared<nano::state_block> (key1.pub, 0, 0, nano::Gxrb_ratio, send->hash (), key1.prv, key1.pub, *pool.generate (key1.pub));
|
||||
{
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, *send).code);
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, *open).code);
|
||||
}
|
||||
|
@ -1402,7 +1402,7 @@ TEST (confirmation_height, unbounded_block_cache_iteration)
|
|||
auto send1 = std::make_shared<nano::send_block> (send->hash (), key1.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio * 2, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send->hash ()));
|
||||
{
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, nano::dev::constants);
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, *send).code);
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, *send1).code);
|
||||
}
|
||||
|
@ -1454,7 +1454,7 @@ TEST (confirmation_height, pruned_source)
|
|||
auto open2 = std::make_shared<nano::state_block> (key2.pub, 0, key1.pub, 50, send2->hash (), key2.prv, key2.pub, *pool.generate (key2.pub));
|
||||
{
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, nano::dev::constants);
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, *send1).code);
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, *open1).code);
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, *send2).code);
|
||||
|
|
|
@ -18,7 +18,7 @@ TEST (ledger, store_error)
|
|||
return;
|
||||
}
|
||||
nano::logger_mt logger;
|
||||
nano::mdb_store store (logger, boost::filesystem::path ("///"), nano::dev::constants);
|
||||
nano::lmdb::store store (logger, boost::filesystem::path ("///"), nano::dev::constants);
|
||||
ASSERT_TRUE (store.init_error ());
|
||||
nano::stat stats;
|
||||
nano::ledger ledger (store, stats, nano::dev::constants);
|
||||
|
@ -47,7 +47,7 @@ TEST (ledger, genesis_balance)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
auto balance (ledger.account_balance (transaction, nano::dev::genesis->account ()));
|
||||
ASSERT_EQ (nano::dev::constants.genesis_amount, balance);
|
||||
auto amount (ledger.amount (transaction, nano::dev::genesis->account ()));
|
||||
|
@ -72,7 +72,7 @@ TEST (ledger, process_modifies_sideband)
|
|||
ASSERT_TRUE (!store->init_error ());
|
||||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
store->initialize (store->tx_begin_write (), ledger.cache);
|
||||
store->initialize (store->tx_begin_write (), ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (store->tx_begin_write (), send1).code);
|
||||
|
@ -88,7 +88,7 @@ TEST (ledger, process_send)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::account_info info1;
|
||||
ASSERT_FALSE (store->account.get (transaction, nano::dev::genesis_key.pub, info1));
|
||||
|
@ -187,7 +187,7 @@ TEST (ledger, process_receive)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::account_info info1;
|
||||
ASSERT_FALSE (store->account.get (transaction, nano::dev::genesis_key.pub, info1));
|
||||
|
@ -250,7 +250,7 @@ TEST (ledger, rollback_receiver)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::account_info info1;
|
||||
ASSERT_FALSE (store->account.get (transaction, nano::dev::genesis_key.pub, info1));
|
||||
|
@ -289,7 +289,7 @@ TEST (ledger, rollback_representation)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::keypair key5;
|
||||
nano::change_block change1 (nano::dev::genesis->hash (), key5.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
|
@ -342,7 +342,7 @@ TEST (ledger, receive_rollback)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::send_block send (nano::dev::genesis->hash (), nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send).code);
|
||||
|
@ -359,7 +359,7 @@ TEST (ledger, process_duplicate)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::account_info info1;
|
||||
ASSERT_FALSE (store->account.get (transaction, nano::dev::genesis_key.pub, info1));
|
||||
|
@ -381,7 +381,7 @@ TEST (ledger, representative_genesis)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
auto latest (ledger.latest (transaction, nano::dev::genesis_key.pub));
|
||||
ASSERT_FALSE (latest.is_zero ());
|
||||
ASSERT_EQ (nano::dev::genesis->hash (), ledger.representative (transaction, latest));
|
||||
|
@ -395,7 +395,7 @@ TEST (ledger, weight)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
ASSERT_EQ (nano::dev::constants.genesis_amount, ledger.weight (nano::dev::genesis->account ()));
|
||||
}
|
||||
|
||||
|
@ -408,7 +408,7 @@ TEST (ledger, representative_change)
|
|||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
nano::keypair key2;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
ASSERT_EQ (nano::dev::constants.genesis_amount, ledger.weight (nano::dev::genesis_key.pub));
|
||||
ASSERT_EQ (0, ledger.weight (key2.pub));
|
||||
|
@ -447,7 +447,7 @@ TEST (ledger, send_fork)
|
|||
nano::keypair key2;
|
||||
nano::keypair key3;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::account_info info1;
|
||||
ASSERT_FALSE (store->account.get (transaction, nano::dev::genesis_key.pub, info1));
|
||||
|
@ -467,7 +467,7 @@ TEST (ledger, receive_fork)
|
|||
nano::keypair key2;
|
||||
nano::keypair key3;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::account_info info1;
|
||||
ASSERT_FALSE (store->account.get (transaction, nano::dev::genesis_key.pub, info1));
|
||||
|
@ -493,7 +493,7 @@ TEST (ledger, open_fork)
|
|||
nano::keypair key2;
|
||||
nano::keypair key3;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::account_info info1;
|
||||
ASSERT_FALSE (store->account.get (transaction, nano::dev::genesis_key.pub, info1));
|
||||
|
@ -525,7 +525,7 @@ TEST (ledger, representation)
|
|||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto & rep_weights = ledger.cache.rep_weights;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
ASSERT_EQ (nano::dev::constants.genesis_amount, rep_weights.representation_get (nano::dev::genesis_key.pub));
|
||||
nano::keypair key2;
|
||||
|
@ -598,7 +598,7 @@ TEST (ledger, double_open)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::keypair key2;
|
||||
nano::send_block send1 (nano::dev::genesis->hash (), key2.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
|
@ -617,7 +617,7 @@ TEST (ledger, double_receive)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::keypair key2;
|
||||
nano::send_block send1 (nano::dev::genesis->hash (), key2.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
|
@ -898,7 +898,7 @@ TEST (ledger, fail_change_old)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::keypair key1;
|
||||
nano::change_block block (nano::dev::genesis->hash (), key1.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
|
@ -916,7 +916,7 @@ TEST (ledger, fail_change_gap_previous)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::keypair key1;
|
||||
nano::change_block block (1, key1.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::root (1)));
|
||||
|
@ -932,7 +932,7 @@ TEST (ledger, fail_change_bad_signature)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::keypair key1;
|
||||
nano::change_block block (nano::dev::genesis->hash (), key1.pub, nano::keypair ().prv, 0, *pool.generate (nano::dev::genesis->hash ()));
|
||||
|
@ -948,7 +948,7 @@ TEST (ledger, fail_change_fork)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::keypair key1;
|
||||
nano::change_block block1 (nano::dev::genesis->hash (), key1.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
|
@ -968,7 +968,7 @@ TEST (ledger, fail_send_old)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::keypair key1;
|
||||
nano::send_block block (nano::dev::genesis->hash (), key1.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
|
@ -986,7 +986,7 @@ TEST (ledger, fail_send_gap_previous)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::keypair key1;
|
||||
nano::send_block block (1, key1.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::root (1)));
|
||||
|
@ -1002,7 +1002,7 @@ TEST (ledger, fail_send_bad_signature)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::keypair key1;
|
||||
nano::send_block block (nano::dev::genesis->hash (), key1.pub, 1, nano::keypair ().prv, 0, *pool.generate (nano::dev::genesis->hash ()));
|
||||
|
@ -1018,7 +1018,7 @@ TEST (ledger, fail_send_negative_spend)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::keypair key1;
|
||||
nano::send_block block1 (nano::dev::genesis->hash (), key1.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
|
@ -1036,7 +1036,7 @@ TEST (ledger, fail_send_fork)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::keypair key1;
|
||||
nano::send_block block1 (nano::dev::genesis->hash (), key1.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
|
@ -1054,7 +1054,7 @@ TEST (ledger, fail_open_old)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::keypair key1;
|
||||
nano::send_block block1 (nano::dev::genesis->hash (), key1.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
|
@ -1072,7 +1072,7 @@ TEST (ledger, fail_open_gap_source)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::keypair key1;
|
||||
nano::open_block block2 (1, 1, key1.pub, key1.prv, key1.pub, *pool.generate (key1.pub));
|
||||
|
@ -1088,7 +1088,7 @@ TEST (ledger, fail_open_bad_signature)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::keypair key1;
|
||||
nano::send_block block1 (nano::dev::genesis->hash (), key1.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
|
@ -1106,7 +1106,7 @@ TEST (ledger, fail_open_fork_previous)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::keypair key1;
|
||||
nano::send_block block1 (nano::dev::genesis->hash (), key1.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
|
@ -1128,7 +1128,7 @@ TEST (ledger, fail_open_account_mismatch)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::keypair key1;
|
||||
nano::send_block block1 (nano::dev::genesis->hash (), key1.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
|
@ -1147,7 +1147,7 @@ TEST (ledger, fail_receive_old)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::keypair key1;
|
||||
nano::send_block block1 (nano::dev::genesis->hash (), key1.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
|
@ -1169,7 +1169,7 @@ TEST (ledger, fail_receive_gap_source)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::keypair key1;
|
||||
nano::send_block block1 (nano::dev::genesis->hash (), key1.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
|
@ -1194,7 +1194,7 @@ TEST (ledger, fail_receive_overreceive)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::keypair key1;
|
||||
nano::send_block block1 (nano::dev::genesis->hash (), key1.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
|
@ -1216,7 +1216,7 @@ TEST (ledger, fail_receive_bad_signature)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::keypair key1;
|
||||
nano::send_block block1 (nano::dev::genesis->hash (), key1.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
|
@ -1241,7 +1241,7 @@ TEST (ledger, fail_receive_gap_previous_opened)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::keypair key1;
|
||||
nano::send_block block1 (nano::dev::genesis->hash (), key1.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
|
@ -1266,7 +1266,7 @@ TEST (ledger, fail_receive_gap_previous_unopened)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::keypair key1;
|
||||
nano::send_block block1 (nano::dev::genesis->hash (), key1.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
|
@ -1288,7 +1288,7 @@ TEST (ledger, fail_receive_fork_previous)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::keypair key1;
|
||||
nano::send_block block1 (nano::dev::genesis->hash (), key1.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
|
@ -1317,7 +1317,7 @@ TEST (ledger, fail_receive_received_source)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::keypair key1;
|
||||
nano::send_block block1 (nano::dev::genesis->hash (), key1.pub, 2, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
|
@ -1365,7 +1365,7 @@ TEST (ledger, latest_root)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::keypair key;
|
||||
ASSERT_EQ (key.pub, ledger.latest_root (transaction, key.pub));
|
||||
|
@ -1384,7 +1384,7 @@ TEST (ledger, change_representative_move_representation)
|
|||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
nano::keypair key1;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
ASSERT_EQ (nano::dev::constants.genesis_amount, ledger.weight (nano::dev::genesis_key.pub));
|
||||
nano::send_block send (nano::dev::genesis->hash (), key1.pub, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
|
@ -1407,7 +1407,7 @@ TEST (ledger, send_open_receive_rollback)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::account_info info1;
|
||||
ASSERT_FALSE (store->account.get (transaction, nano::dev::genesis_key.pub, info1));
|
||||
|
@ -1469,7 +1469,7 @@ TEST (ledger, bootstrap_rep_weight)
|
|||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
{
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
ASSERT_FALSE (store->account.get (transaction, nano::dev::genesis_key.pub, info1));
|
||||
nano::send_block send (info1.head, key2.pub, std::numeric_limits<nano::uint128_t>::max () - 50, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (info1.head));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send).code);
|
||||
|
@ -1501,7 +1501,7 @@ TEST (ledger, block_destination_source)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::keypair dest;
|
||||
nano::uint128_t balance (nano::dev::constants.genesis_amount);
|
||||
|
@ -1546,7 +1546,7 @@ TEST (ledger, state_account)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code);
|
||||
|
@ -1561,7 +1561,7 @@ TEST (ledger, state_send_receive)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code);
|
||||
|
@ -1602,7 +1602,7 @@ TEST (ledger, state_receive)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::send_block send1 (nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code);
|
||||
|
@ -1636,7 +1636,7 @@ TEST (ledger, state_rep_change)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::keypair rep;
|
||||
nano::state_block change1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), rep.pub, nano::dev::constants.genesis_amount, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
|
@ -1663,7 +1663,7 @@ TEST (ledger, state_open)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::keypair destination;
|
||||
nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
|
@ -1702,7 +1702,7 @@ TEST (ledger, send_after_state_fail)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code);
|
||||
|
@ -1719,7 +1719,7 @@ TEST (ledger, receive_after_state_fail)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code);
|
||||
|
@ -1736,7 +1736,7 @@ TEST (ledger, change_after_state_fail)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code);
|
||||
|
@ -1753,7 +1753,7 @@ TEST (ledger, state_unreceivable_fail)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::send_block send1 (nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code);
|
||||
|
@ -1776,7 +1776,7 @@ TEST (ledger, state_receive_bad_amount_fail)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::send_block send1 (nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code);
|
||||
|
@ -1799,7 +1799,7 @@ TEST (ledger, state_no_link_amount_fail)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code);
|
||||
|
@ -1816,7 +1816,7 @@ TEST (ledger, state_receive_wrong_account_fail)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code);
|
||||
|
@ -1840,7 +1840,7 @@ TEST (ledger, state_open_state_fork)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::keypair destination;
|
||||
nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
|
@ -1860,7 +1860,7 @@ TEST (ledger, state_state_open_fork)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::keypair destination;
|
||||
nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
|
@ -1881,7 +1881,7 @@ TEST (ledger, state_open_previous_fail)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::keypair destination;
|
||||
nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
|
@ -1898,7 +1898,7 @@ TEST (ledger, state_open_source_fail)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::keypair destination;
|
||||
nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
|
@ -1915,7 +1915,7 @@ TEST (ledger, state_send_change)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::keypair rep;
|
||||
nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), rep.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
|
@ -1942,7 +1942,7 @@ TEST (ledger, state_receive_change)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code);
|
||||
|
@ -1978,7 +1978,7 @@ TEST (ledger, state_open_old)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::keypair destination;
|
||||
nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
|
@ -1998,7 +1998,7 @@ TEST (ledger, state_receive_old)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::keypair destination;
|
||||
nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
|
@ -2022,7 +2022,7 @@ TEST (ledger, state_rollback_send)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code);
|
||||
|
@ -2053,7 +2053,7 @@ TEST (ledger, state_rollback_receive)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code);
|
||||
|
@ -2079,7 +2079,7 @@ TEST (ledger, state_rollback_received_send)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::keypair key;
|
||||
nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
|
@ -2106,7 +2106,7 @@ TEST (ledger, state_rep_change_rollback)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::keypair rep;
|
||||
nano::state_block change1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), rep.pub, nano::dev::constants.genesis_amount, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
|
@ -2126,7 +2126,7 @@ TEST (ledger, state_open_rollback)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::keypair destination;
|
||||
nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
|
@ -2152,7 +2152,7 @@ TEST (ledger, state_send_change_rollback)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::keypair rep;
|
||||
nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), rep.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
|
@ -2173,7 +2173,7 @@ TEST (ledger, state_receive_change_rollback)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code);
|
||||
|
@ -2196,7 +2196,7 @@ TEST (ledger, epoch_blocks_v1_general)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::keypair destination;
|
||||
nano::state_block epoch1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount, ledger.epoch_link (nano::epoch::epoch_1), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
|
@ -2266,7 +2266,7 @@ TEST (ledger, epoch_blocks_v2_general)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::keypair destination;
|
||||
nano::state_block epoch1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount, ledger.epoch_link (nano::epoch::epoch_2), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
|
@ -2331,7 +2331,7 @@ TEST (ledger, epoch_blocks_receive_upgrade)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::keypair destination;
|
||||
nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
|
@ -2411,7 +2411,7 @@ TEST (ledger, epoch_blocks_fork)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::keypair destination;
|
||||
nano::send_block send1 (nano::dev::genesis->hash (), nano::account{}, nano::dev::constants.genesis_amount, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
|
@ -2592,7 +2592,7 @@ TEST (ledger, could_fit)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::keypair destination;
|
||||
// Test legacy and state change blocks could_fit
|
||||
|
@ -2803,7 +2803,7 @@ TEST (ledger, confirmation_height_not_updated)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::account_info account_info;
|
||||
ASSERT_FALSE (store->account.get (transaction, nano::dev::genesis_key.pub, account_info));
|
||||
|
@ -2863,7 +2863,7 @@ TEST (ledger, work_validation)
|
|||
ASSERT_TRUE (!store->init_error ());
|
||||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
store->initialize (store->tx_begin_write (), ledger.cache);
|
||||
store->initialize (store->tx_begin_write (), ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::block_builder builder;
|
||||
auto gen = nano::dev::genesis_key;
|
||||
|
@ -2957,7 +2957,7 @@ TEST (ledger, dependents_confirmed)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
ASSERT_TRUE (ledger.dependents_confirmed (transaction, *nano::dev::genesis));
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::keypair key1;
|
||||
|
@ -3030,7 +3030,7 @@ TEST (ledger, dependents_confirmed_pruning)
|
|||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
ledger.pruning = true;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::keypair key1;
|
||||
auto send1 = builder.state ()
|
||||
|
@ -3080,7 +3080,7 @@ TEST (ledger, block_confirmed)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
ASSERT_TRUE (ledger.block_confirmed (transaction, nano::dev::genesis->hash ()));
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::keypair key1;
|
||||
|
@ -3111,7 +3111,7 @@ TEST (ledger, cache)
|
|||
ASSERT_TRUE (!store->init_error ());
|
||||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
store->initialize (store->tx_begin_write (), ledger.cache);
|
||||
store->initialize (store->tx_begin_write (), ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::block_builder builder;
|
||||
|
||||
|
@ -3224,7 +3224,7 @@ TEST (ledger, pruning_action)
|
|||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
ledger.pruning = true;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code);
|
||||
|
@ -3280,7 +3280,7 @@ TEST (ledger, pruning_large_chain)
|
|||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
ledger.pruning = true;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
size_t send_receive_pairs (20);
|
||||
auto last_hash (nano::dev::genesis->hash ());
|
||||
|
@ -3316,7 +3316,7 @@ TEST (ledger, pruning_source_rollback)
|
|||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
ledger.pruning = true;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::state_block epoch1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount, ledger.epoch_link (nano::epoch::epoch_1), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, epoch1).code);
|
||||
|
@ -3367,7 +3367,7 @@ TEST (ledger, pruning_source_rollback_legacy)
|
|||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
ledger.pruning = true;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::send_block send1 (nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code);
|
||||
|
@ -3445,7 +3445,7 @@ TEST (ledger, pruning_process_error)
|
|||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
ledger.pruning = true;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code);
|
||||
|
@ -3474,7 +3474,7 @@ TEST (ledger, pruning_legacy_blocks)
|
|||
ledger.pruning = true;
|
||||
nano::keypair key1;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::send_block send1 (nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code);
|
||||
|
@ -3518,7 +3518,7 @@ TEST (ledger, pruning_safe_functions)
|
|||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
ledger.pruning = true;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code);
|
||||
|
@ -3560,7 +3560,7 @@ TEST (ledger, hash_root_random)
|
|||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
ledger.pruning = true;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code);
|
||||
|
@ -3600,7 +3600,7 @@ TEST (ledger, migrate_lmdb_to_rocksdb)
|
|||
nano::logger_mt logger{};
|
||||
boost::asio::ip::address_v6 address (boost::asio::ip::make_address_v6 ("::ffff:127.0.0.1"));
|
||||
uint16_t port = 100;
|
||||
nano::mdb_store store{ logger, path / "data.ldb", nano::dev::constants };
|
||||
nano::lmdb::store store{ logger, path / "data.ldb", nano::dev::constants };
|
||||
nano::unchecked_map unchecked{ store, false };
|
||||
nano::stat stats{};
|
||||
nano::ledger ledger{ store, stats, nano::dev::constants };
|
||||
|
@ -3621,7 +3621,7 @@ TEST (ledger, migrate_lmdb_to_rocksdb)
|
|||
|
||||
{
|
||||
auto transaction = store.tx_begin_write ();
|
||||
store.initialize (transaction, ledger.cache);
|
||||
store.initialize (transaction, ledger.cache, ledger.constants);
|
||||
ASSERT_FALSE (store.init_error ());
|
||||
|
||||
// Lower the database to the max version unsupported for upgrades
|
||||
|
@ -3642,7 +3642,7 @@ TEST (ledger, migrate_lmdb_to_rocksdb)
|
|||
auto error = ledger.migrate_lmdb_to_rocksdb (path);
|
||||
ASSERT_FALSE (error);
|
||||
|
||||
nano::rocksdb_store rocksdb_store{ logger, path / "rocksdb", nano::dev::constants };
|
||||
nano::rocksdb::store rocksdb_store{ logger, path / "rocksdb", nano::dev::constants };
|
||||
nano::unchecked_map rocksdb_unchecked{ rocksdb_store, false };
|
||||
auto rocksdb_transaction (rocksdb_store.tx_begin_read ());
|
||||
|
||||
|
@ -3678,7 +3678,7 @@ TEST (ledger, unconfirmed_frontiers)
|
|||
ASSERT_TRUE (!store->init_error ());
|
||||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
store->initialize (store->tx_begin_write (), ledger.cache);
|
||||
store->initialize (store->tx_begin_write (), ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
|
||||
auto unconfirmed_frontiers = ledger.unconfirmed_frontiers ();
|
||||
|
|
|
@ -3345,7 +3345,7 @@ TEST (node, dont_write_lock_node)
|
|||
{
|
||||
nano::ledger_cache ledger_cache;
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger_cache);
|
||||
store->initialize (transaction, ledger_cache, nano::dev::constants);
|
||||
}
|
||||
|
||||
// Hold write lock open until main thread is done needing it
|
||||
|
|
|
@ -15,7 +15,7 @@ TEST (processor_service, bad_send_signature)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::account_info info1;
|
||||
ASSERT_FALSE (store->account.get (transaction, nano::dev::genesis_key.pub, info1));
|
||||
|
@ -33,7 +33,7 @@ TEST (processor_service, bad_receive_signature)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::account_info info1;
|
||||
ASSERT_FALSE (store->account.get (transaction, nano::dev::genesis_key.pub, info1));
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include <nano/node/lmdb/account_store.hpp>
|
||||
#include <nano/node/lmdb/lmdb.hpp>
|
||||
#include <nano/secure/parallel_traversal.hpp>
|
||||
|
||||
nano::lmdb::account_store::account_store (nano::mdb_store & store_a) :
|
||||
nano::lmdb::account_store::account_store (nano::lmdb::store & store_a) :
|
||||
store (store_a){};
|
||||
|
||||
void nano::lmdb::account_store::put (nano::write_transaction const & transaction, nano::account const & account, nano::account_info const & info)
|
||||
|
@ -27,7 +28,7 @@ bool nano::lmdb::account_store::get (nano::transaction const & transaction, nano
|
|||
void nano::lmdb::account_store::del (nano::write_transaction const & transaction_a, nano::account const & account_a)
|
||||
{
|
||||
auto status = store.del (transaction_a, tables::accounts, account_a);
|
||||
release_assert_success (store, status);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
||||
bool nano::lmdb::account_store::exists (nano::transaction const & transaction_a, nano::account const & account_a)
|
||||
|
|
|
@ -4,16 +4,16 @@
|
|||
|
||||
namespace nano
|
||||
{
|
||||
class mdb_store;
|
||||
namespace lmdb
|
||||
{
|
||||
class store;
|
||||
class account_store : public nano::account_store
|
||||
{
|
||||
private:
|
||||
nano::mdb_store & store;
|
||||
nano::lmdb::store & store;
|
||||
|
||||
public:
|
||||
explicit account_store (nano::mdb_store & store_a);
|
||||
explicit account_store (nano::lmdb::store & store_a);
|
||||
void put (nano::write_transaction const & transaction, nano::account const & account, nano::account_info const & info) override;
|
||||
bool get (nano::transaction const & transaction_a, nano::account const & account_a, nano::account_info & info_a) override;
|
||||
void del (nano::write_transaction const & transaction_a, nano::account const & account_a) override;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <nano/node/lmdb/block_store.hpp>
|
||||
#include <nano/node/lmdb/lmdb.hpp>
|
||||
#include <nano/secure/parallel_traversal.hpp>
|
||||
|
||||
namespace nano
|
||||
{
|
||||
|
@ -22,7 +23,7 @@ public:
|
|||
};
|
||||
}
|
||||
|
||||
nano::lmdb::block_store::block_store (nano::mdb_store & store_a) :
|
||||
nano::lmdb::block_store::block_store (nano::lmdb::store & store_a) :
|
||||
store{ store_a } {};
|
||||
|
||||
void nano::lmdb::block_store::put (nano::write_transaction const & transaction, nano::block_hash const & hash, nano::block const & block)
|
||||
|
@ -44,7 +45,7 @@ void nano::lmdb::block_store::raw_put (nano::write_transaction const & transacti
|
|||
{
|
||||
nano::mdb_val value{ data.size (), (void *)data.data () };
|
||||
auto status = store.put (transaction_a, tables::blocks, hash_a, value);
|
||||
release_assert_success (store, status);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
||||
nano::block_hash nano::lmdb::block_store::successor (nano::transaction const & transaction_a, nano::block_hash const & hash_a) const
|
||||
|
@ -130,7 +131,7 @@ std::shared_ptr<nano::block> nano::lmdb::block_store::random (nano::transaction
|
|||
void nano::lmdb::block_store::del (nano::write_transaction const & transaction_a, nano::block_hash const & hash_a)
|
||||
{
|
||||
auto status = store.del (transaction_a, tables::blocks, hash_a);
|
||||
release_assert_success (store, status);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
||||
bool nano::lmdb::block_store::exists (nano::transaction const & transaction, nano::block_hash const & hash)
|
||||
|
|
|
@ -4,18 +4,18 @@
|
|||
|
||||
namespace nano
|
||||
{
|
||||
class mdb_store;
|
||||
using mdb_val = db_val<MDB_val>;
|
||||
class block_predecessor_mdb_set;
|
||||
namespace lmdb
|
||||
{
|
||||
class store;
|
||||
class block_store : public nano::block_store
|
||||
{
|
||||
friend class nano::block_predecessor_mdb_set;
|
||||
nano::mdb_store & store;
|
||||
nano::lmdb::store & store;
|
||||
|
||||
public:
|
||||
explicit block_store (nano::mdb_store & store_a);
|
||||
explicit block_store (nano::lmdb::store & store_a);
|
||||
void put (nano::write_transaction const & transaction_a, nano::block_hash const & hash_a, nano::block const & block_a) override;
|
||||
void raw_put (nano::write_transaction const & transaction_a, std::vector<uint8_t> const & data, nano::block_hash const & hash_a) override;
|
||||
nano::block_hash successor (nano::transaction const & transaction_a, nano::block_hash const & hash_a) const override;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include <nano/node/lmdb/confirmation_height_store.hpp>
|
||||
#include <nano/node/lmdb/lmdb.hpp>
|
||||
#include <nano/secure/parallel_traversal.hpp>
|
||||
|
||||
nano::lmdb::confirmation_height_store::confirmation_height_store (nano::mdb_store & store) :
|
||||
nano::lmdb::confirmation_height_store::confirmation_height_store (nano::lmdb::store & store) :
|
||||
store{ store }
|
||||
{
|
||||
}
|
||||
|
@ -9,7 +10,7 @@ nano::lmdb::confirmation_height_store::confirmation_height_store (nano::mdb_stor
|
|||
void nano::lmdb::confirmation_height_store::put (nano::write_transaction const & transaction, nano::account const & account, nano::confirmation_height_info const & confirmation_height_info)
|
||||
{
|
||||
auto status = store.put (transaction, tables::confirmation_height, account, confirmation_height_info);
|
||||
release_assert_success (store, status);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
||||
bool nano::lmdb::confirmation_height_store::get (nano::transaction const & transaction, nano::account const & account, nano::confirmation_height_info & confirmation_height_info)
|
||||
|
@ -40,7 +41,7 @@ bool nano::lmdb::confirmation_height_store::exists (nano::transaction const & tr
|
|||
void nano::lmdb::confirmation_height_store::del (nano::write_transaction const & transaction, nano::account const & account)
|
||||
{
|
||||
auto status = store.del (transaction, tables::confirmation_height, account);
|
||||
release_assert_success (store, status);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
||||
uint64_t nano::lmdb::confirmation_height_store::count (nano::transaction const & transaction_a)
|
||||
|
|
|
@ -4,15 +4,15 @@
|
|||
|
||||
namespace nano
|
||||
{
|
||||
class mdb_store;
|
||||
namespace lmdb
|
||||
{
|
||||
class store;
|
||||
class confirmation_height_store : public nano::confirmation_height_store
|
||||
{
|
||||
nano::mdb_store & store;
|
||||
nano::lmdb::store & store;
|
||||
|
||||
public:
|
||||
explicit confirmation_height_store (nano::mdb_store & store_a);
|
||||
explicit confirmation_height_store (nano::lmdb::store & store_a);
|
||||
void put (nano::write_transaction const & transaction_a, nano::account const & account_a, nano::confirmation_height_info const & confirmation_height_info_a) override;
|
||||
bool get (nano::transaction const & transaction_a, nano::account const & account_a, nano::confirmation_height_info & confirmation_height_info_a) override;
|
||||
bool exists (nano::transaction const & transaction_a, nano::account const & account_a) const override;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include <nano/node/lmdb/final_vote_store.hpp>
|
||||
#include <nano/node/lmdb/lmdb.hpp>
|
||||
#include <nano/secure/parallel_traversal.hpp>
|
||||
|
||||
nano::lmdb::final_vote_store::final_vote_store (nano::mdb_store & store) :
|
||||
nano::lmdb::final_vote_store::final_vote_store (nano::lmdb::store & store) :
|
||||
store{ store } {};
|
||||
|
||||
bool nano::lmdb::final_vote_store::put (nano::write_transaction const & transaction, nano::qualified_root const & root, nano::block_hash const & hash)
|
||||
|
@ -17,7 +18,7 @@ bool nano::lmdb::final_vote_store::put (nano::write_transaction const & transact
|
|||
else
|
||||
{
|
||||
status = store.put (transaction, tables::final_votes, root, hash);
|
||||
release_assert_success (store, status);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -44,7 +45,7 @@ void nano::lmdb::final_vote_store::del (nano::write_transaction const & transact
|
|||
for (auto & final_vote_qualified_root : final_vote_qualified_roots)
|
||||
{
|
||||
auto status = store.del (transaction, tables::final_votes, final_vote_qualified_root);
|
||||
release_assert_success (store, status);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,16 +4,16 @@
|
|||
|
||||
namespace nano
|
||||
{
|
||||
class mdb_store;
|
||||
namespace lmdb
|
||||
{
|
||||
class store;
|
||||
class final_vote_store : public nano::final_vote_store
|
||||
{
|
||||
private:
|
||||
nano::mdb_store & store;
|
||||
nano::lmdb::store & store;
|
||||
|
||||
public:
|
||||
explicit final_vote_store (nano::mdb_store & store);
|
||||
explicit final_vote_store (nano::lmdb::store & store);
|
||||
bool put (nano::write_transaction const & transaction_a, nano::qualified_root const & root_a, nano::block_hash const & hash_a) override;
|
||||
std::vector<nano::block_hash> get (nano::transaction const & transaction_a, nano::root const & root_a) override;
|
||||
void del (nano::write_transaction const & transaction_a, nano::root const & root_a) override;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include <nano/node/lmdb/frontier_store.hpp>
|
||||
#include <nano/node/lmdb/lmdb.hpp>
|
||||
#include <nano/secure/parallel_traversal.hpp>
|
||||
|
||||
nano::lmdb::frontier_store::frontier_store (nano::mdb_store & store) :
|
||||
nano::lmdb::frontier_store::frontier_store (nano::lmdb::store & store) :
|
||||
store{ store }
|
||||
{
|
||||
}
|
||||
|
@ -9,7 +10,7 @@ nano::lmdb::frontier_store::frontier_store (nano::mdb_store & store) :
|
|||
void nano::lmdb::frontier_store::put (nano::write_transaction const & transaction, nano::block_hash const & hash, nano::account const & account)
|
||||
{
|
||||
auto status = store.put (transaction, tables::frontiers, hash, account);
|
||||
release_assert_success (store, status);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
||||
nano::account nano::lmdb::frontier_store::get (nano::transaction const & transaction, nano::block_hash const & hash) const
|
||||
|
@ -28,7 +29,7 @@ nano::account nano::lmdb::frontier_store::get (nano::transaction const & transac
|
|||
void nano::lmdb::frontier_store::del (nano::write_transaction const & transaction, nano::block_hash const & hash)
|
||||
{
|
||||
auto status = store.del (transaction, tables::frontiers, hash);
|
||||
release_assert_success (store, status);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
||||
nano::store_iterator<nano::block_hash, nano::account> nano::lmdb::frontier_store::begin (nano::transaction const & transaction) const
|
||||
|
|
|
@ -4,13 +4,13 @@
|
|||
|
||||
namespace nano
|
||||
{
|
||||
class mdb_store;
|
||||
namespace lmdb
|
||||
{
|
||||
class store;
|
||||
class frontier_store : public nano::frontier_store
|
||||
{
|
||||
public:
|
||||
frontier_store (nano::mdb_store & store);
|
||||
frontier_store (nano::lmdb::store & store);
|
||||
void put (nano::write_transaction const &, nano::block_hash const &, nano::account const &) override;
|
||||
nano::account get (nano::transaction const &, nano::block_hash const &) const override;
|
||||
void del (nano::write_transaction const &, nano::block_hash const &) override;
|
||||
|
@ -20,7 +20,7 @@ namespace lmdb
|
|||
void for_each_par (std::function<void (nano::read_transaction const &, nano::store_iterator<nano::block_hash, nano::account>, nano::store_iterator<nano::block_hash, nano::account>)> const & action_a) const override;
|
||||
|
||||
private:
|
||||
nano::mdb_store & store;
|
||||
nano::lmdb::store & store;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,10 +40,9 @@ void mdb_val::convert_buffer_to_value ()
|
|||
}
|
||||
}
|
||||
|
||||
nano::mdb_store::mdb_store (nano::logger_mt & logger_a, boost::filesystem::path const & path_a, nano::ledger_constants & constants, nano::txn_tracking_config const & txn_tracking_config_a, std::chrono::milliseconds block_processor_batch_max_time_a, nano::lmdb_config const & lmdb_config_a, bool backup_before_upgrade_a) :
|
||||
nano::lmdb::store::store (nano::logger_mt & logger_a, boost::filesystem::path const & path_a, nano::ledger_constants & constants, nano::txn_tracking_config const & txn_tracking_config_a, std::chrono::milliseconds block_processor_batch_max_time_a, nano::lmdb_config const & lmdb_config_a, bool backup_before_upgrade_a) :
|
||||
// clang-format off
|
||||
store_partial{
|
||||
constants,
|
||||
nano::store{
|
||||
block_store,
|
||||
frontier_store,
|
||||
account_store,
|
||||
|
@ -83,7 +82,7 @@ nano::mdb_store::mdb_store (nano::logger_mt & logger_a, boost::filesystem::path
|
|||
is_fresh_db = err != MDB_SUCCESS;
|
||||
if (err == MDB_SUCCESS)
|
||||
{
|
||||
is_fully_upgraded = (version.get (transaction) == version_number);
|
||||
is_fully_upgraded = (version.get (transaction) == version_current);
|
||||
mdb_dbi_close (env, meta_handle);
|
||||
}
|
||||
}
|
||||
|
@ -107,7 +106,7 @@ nano::mdb_store::mdb_store (nano::logger_mt & logger_a, boost::filesystem::path
|
|||
open_databases (error, transaction, MDB_CREATE);
|
||||
if (!error)
|
||||
{
|
||||
error |= do_upgrades (transaction, needs_vacuuming);
|
||||
error |= do_upgrades (transaction, constants, needs_vacuuming);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -126,7 +125,7 @@ nano::mdb_store::mdb_store (nano::logger_mt & logger_a, boost::filesystem::path
|
|||
}
|
||||
}
|
||||
|
||||
bool nano::mdb_store::vacuum_after_upgrade (boost::filesystem::path const & path_a, nano::lmdb_config const & lmdb_config_a)
|
||||
bool nano::lmdb::store::vacuum_after_upgrade (boost::filesystem::path const & path_a, nano::lmdb_config const & lmdb_config_a)
|
||||
{
|
||||
// Vacuum the database. This is not a required step and may actually fail if there isn't enough storage space.
|
||||
auto vacuum_path = path_a.parent_path () / "vacuumed.ldb";
|
||||
|
@ -161,12 +160,12 @@ bool nano::mdb_store::vacuum_after_upgrade (boost::filesystem::path const & path
|
|||
return vacuum_success;
|
||||
}
|
||||
|
||||
void nano::mdb_store::serialize_mdb_tracker (boost::property_tree::ptree & json, std::chrono::milliseconds min_read_time, std::chrono::milliseconds min_write_time)
|
||||
void nano::lmdb::store::serialize_mdb_tracker (boost::property_tree::ptree & json, std::chrono::milliseconds min_read_time, std::chrono::milliseconds min_write_time)
|
||||
{
|
||||
mdb_txn_tracker.serialize_json (json, min_read_time, min_write_time);
|
||||
}
|
||||
|
||||
void nano::mdb_store::serialize_memory_stats (boost::property_tree::ptree & json)
|
||||
void nano::lmdb::store::serialize_memory_stats (boost::property_tree::ptree & json)
|
||||
{
|
||||
MDB_stat stats;
|
||||
auto status (mdb_env_stat (env.environment, &stats));
|
||||
|
@ -179,22 +178,22 @@ void nano::mdb_store::serialize_memory_stats (boost::property_tree::ptree & json
|
|||
json.put ("page_size", stats.ms_psize);
|
||||
}
|
||||
|
||||
nano::write_transaction nano::mdb_store::tx_begin_write (std::vector<nano::tables> const &, std::vector<nano::tables> const &)
|
||||
nano::write_transaction nano::lmdb::store::tx_begin_write (std::vector<nano::tables> const &, std::vector<nano::tables> const &)
|
||||
{
|
||||
return env.tx_begin_write (create_txn_callbacks ());
|
||||
}
|
||||
|
||||
nano::read_transaction nano::mdb_store::tx_begin_read () const
|
||||
nano::read_transaction nano::lmdb::store::tx_begin_read () const
|
||||
{
|
||||
return env.tx_begin_read (create_txn_callbacks ());
|
||||
}
|
||||
|
||||
std::string nano::mdb_store::vendor_get () const
|
||||
std::string nano::lmdb::store::vendor_get () const
|
||||
{
|
||||
return boost::str (boost::format ("LMDB %1%.%2%.%3%") % MDB_VERSION_MAJOR % MDB_VERSION_MINOR % MDB_VERSION_PATCH);
|
||||
}
|
||||
|
||||
nano::mdb_txn_callbacks nano::mdb_store::create_txn_callbacks () const
|
||||
nano::mdb_txn_callbacks nano::lmdb::store::create_txn_callbacks () const
|
||||
{
|
||||
nano::mdb_txn_callbacks mdb_txn_callbacks;
|
||||
if (txn_tracking_enabled)
|
||||
|
@ -209,7 +208,7 @@ nano::mdb_txn_callbacks nano::mdb_store::create_txn_callbacks () const
|
|||
return mdb_txn_callbacks;
|
||||
}
|
||||
|
||||
void nano::mdb_store::open_databases (bool & error_a, nano::transaction const & transaction_a, unsigned flags)
|
||||
void nano::lmdb::store::open_databases (bool & error_a, nano::transaction const & transaction_a, unsigned flags)
|
||||
{
|
||||
error_a |= mdb_dbi_open (env.tx (transaction_a), "frontiers", flags, &frontiers_handle) != 0;
|
||||
error_a |= mdb_dbi_open (env.tx (transaction_a), "unchecked", flags, &unchecked_handle) != 0;
|
||||
|
@ -260,7 +259,7 @@ void nano::mdb_store::open_databases (bool & error_a, nano::transaction const &
|
|||
}
|
||||
}
|
||||
|
||||
bool nano::mdb_store::do_upgrades (nano::write_transaction & transaction_a, bool & needs_vacuuming)
|
||||
bool nano::lmdb::store::do_upgrades (nano::write_transaction & transaction_a, nano::ledger_constants & constants, bool & needs_vacuuming)
|
||||
{
|
||||
auto error (false);
|
||||
auto version_l = version.get (transaction_a);
|
||||
|
@ -279,7 +278,7 @@ bool nano::mdb_store::do_upgrades (nano::write_transaction & transaction_a, bool
|
|||
case 11:
|
||||
case 12:
|
||||
case 13:
|
||||
logger.always_log (boost::str (boost::format ("The version of the ledger (%1%) is lower than the minimum (%2%) which is supported for upgrades. Either upgrade to a v19, v20 or v21 node first or delete the ledger.") % version_l % minimum_version));
|
||||
logger.always_log (boost::str (boost::format ("The version of the ledger (%1%) is lower than the minimum (%2%) which is supported for upgrades. Either upgrade to a v19, v20 or v21 node first or delete the ledger.") % version_l % version_minimum));
|
||||
error = true;
|
||||
break;
|
||||
case 14:
|
||||
|
@ -293,7 +292,7 @@ bool nano::mdb_store::do_upgrades (nano::write_transaction & transaction_a, bool
|
|||
upgrade_v16_to_v17 (transaction_a);
|
||||
[[fallthrough]];
|
||||
case 17:
|
||||
upgrade_v17_to_v18 (transaction_a);
|
||||
upgrade_v17_to_v18 (transaction_a, constants);
|
||||
[[fallthrough]];
|
||||
// Upgrades to version 19 & 20 are both part of the v22 node release
|
||||
case 18:
|
||||
|
@ -316,7 +315,7 @@ bool nano::mdb_store::do_upgrades (nano::write_transaction & transaction_a, bool
|
|||
return error;
|
||||
}
|
||||
|
||||
void nano::mdb_store::upgrade_v14_to_v15 (nano::write_transaction & transaction_a)
|
||||
void nano::lmdb::store::upgrade_v14_to_v15 (nano::write_transaction & transaction_a)
|
||||
{
|
||||
logger.always_log ("Preparing v14 to v15 database upgrade...");
|
||||
|
||||
|
@ -434,7 +433,7 @@ void nano::mdb_store::upgrade_v14_to_v15 (nano::write_transaction & transaction_
|
|||
logger.always_log ("Finished epoch merge upgrade");
|
||||
}
|
||||
|
||||
void nano::mdb_store::upgrade_v15_to_v16 (nano::write_transaction const & transaction_a)
|
||||
void nano::lmdb::store::upgrade_v15_to_v16 (nano::write_transaction const & transaction_a)
|
||||
{
|
||||
// Representation table is no longer used
|
||||
debug_assert (representation_handle != 0);
|
||||
|
@ -447,7 +446,7 @@ void nano::mdb_store::upgrade_v15_to_v16 (nano::write_transaction const & transa
|
|||
version.put (transaction_a, 16);
|
||||
}
|
||||
|
||||
void nano::mdb_store::upgrade_v16_to_v17 (nano::write_transaction const & transaction_a)
|
||||
void nano::lmdb::store::upgrade_v16_to_v17 (nano::write_transaction const & transaction_a)
|
||||
{
|
||||
logger.always_log ("Preparing v16 to v17 database upgrade...");
|
||||
|
||||
|
@ -526,7 +525,7 @@ void nano::mdb_store::upgrade_v16_to_v17 (nano::write_transaction const & transa
|
|||
logger.always_log ("Finished upgrading confirmation height frontiers");
|
||||
}
|
||||
|
||||
void nano::mdb_store::upgrade_v17_to_v18 (nano::write_transaction const & transaction_a)
|
||||
void nano::lmdb::store::upgrade_v17_to_v18 (nano::write_transaction const & transaction_a, nano::ledger_constants & constants)
|
||||
{
|
||||
logger.always_log ("Preparing v17 to v18 database upgrade...");
|
||||
|
||||
|
@ -588,7 +587,7 @@ void nano::mdb_store::upgrade_v17_to_v18 (nano::write_transaction const & transa
|
|||
logger.always_log ("Finished upgrading the sideband");
|
||||
}
|
||||
|
||||
void nano::mdb_store::upgrade_v18_to_v19 (nano::write_transaction const & transaction_a)
|
||||
void nano::lmdb::store::upgrade_v18_to_v19 (nano::write_transaction const & transaction_a)
|
||||
{
|
||||
logger.always_log ("Preparing v18 to v19 database upgrade...");
|
||||
auto count_pre (count (transaction_a, state_blocks_handle) + count (transaction_a, send_blocks_handle) + count (transaction_a, receive_blocks_handle) + count (transaction_a, change_blocks_handle) + count (transaction_a, open_blocks_handle));
|
||||
|
@ -764,7 +763,7 @@ void nano::mdb_store::upgrade_v18_to_v19 (nano::write_transaction const & transa
|
|||
logger.always_log ("Finished upgrading all blocks to new blocks database");
|
||||
}
|
||||
|
||||
void nano::mdb_store::upgrade_v19_to_v20 (nano::write_transaction const & transaction_a)
|
||||
void nano::lmdb::store::upgrade_v19_to_v20 (nano::write_transaction const & transaction_a)
|
||||
{
|
||||
logger.always_log ("Preparing v19 to v20 database upgrade...");
|
||||
mdb_dbi_open (env.tx (transaction_a), "pruned", MDB_CREATE, &pruned_handle);
|
||||
|
@ -772,7 +771,7 @@ void nano::mdb_store::upgrade_v19_to_v20 (nano::write_transaction const & transa
|
|||
logger.always_log ("Finished creating new pruned table");
|
||||
}
|
||||
|
||||
void nano::mdb_store::upgrade_v20_to_v21 (nano::write_transaction const & transaction_a)
|
||||
void nano::lmdb::store::upgrade_v20_to_v21 (nano::write_transaction const & transaction_a)
|
||||
{
|
||||
logger.always_log ("Preparing v20 to v21 database upgrade...");
|
||||
mdb_dbi_open (env.tx (transaction_a), "final_votes", MDB_CREATE, &final_votes_handle);
|
||||
|
@ -781,7 +780,7 @@ void nano::mdb_store::upgrade_v20_to_v21 (nano::write_transaction const & transa
|
|||
}
|
||||
|
||||
/** Takes a filepath, appends '_backup_<timestamp>' to the end (but before any extension) and saves that file in the same directory */
|
||||
void nano::mdb_store::create_backup_file (nano::mdb_env & env_a, boost::filesystem::path const & filepath_a, nano::logger_mt & logger_a)
|
||||
void nano::lmdb::store::create_backup_file (nano::mdb_env & env_a, boost::filesystem::path const & filepath_a, nano::logger_mt & logger_a)
|
||||
{
|
||||
auto extension = filepath_a.extension ();
|
||||
auto filename_without_extension = filepath_a.filename ().replace_extension ("");
|
||||
|
@ -811,7 +810,7 @@ void nano::mdb_store::create_backup_file (nano::mdb_env & env_a, boost::filesyst
|
|||
}
|
||||
}
|
||||
|
||||
bool nano::mdb_store::exists (nano::transaction const & transaction_a, tables table_a, nano::mdb_val const & key_a) const
|
||||
bool nano::lmdb::store::exists (nano::transaction const & transaction_a, tables table_a, nano::mdb_val const & key_a) const
|
||||
{
|
||||
nano::mdb_val junk;
|
||||
auto status = get (transaction_a, table_a, key_a, junk);
|
||||
|
@ -819,37 +818,37 @@ bool nano::mdb_store::exists (nano::transaction const & transaction_a, tables ta
|
|||
return (status == MDB_SUCCESS);
|
||||
}
|
||||
|
||||
int nano::mdb_store::get (nano::transaction const & transaction_a, tables table_a, nano::mdb_val const & key_a, nano::mdb_val & value_a) const
|
||||
int nano::lmdb::store::get (nano::transaction const & transaction_a, tables table_a, nano::mdb_val const & key_a, nano::mdb_val & value_a) const
|
||||
{
|
||||
return mdb_get (env.tx (transaction_a), table_to_dbi (table_a), key_a, value_a);
|
||||
}
|
||||
|
||||
int nano::mdb_store::put (nano::write_transaction const & transaction_a, tables table_a, nano::mdb_val const & key_a, nano::mdb_val const & value_a) const
|
||||
int nano::lmdb::store::put (nano::write_transaction const & transaction_a, tables table_a, nano::mdb_val const & key_a, nano::mdb_val const & value_a) const
|
||||
{
|
||||
return (mdb_put (env.tx (transaction_a), table_to_dbi (table_a), key_a, value_a, 0));
|
||||
}
|
||||
|
||||
int nano::mdb_store::del (nano::write_transaction const & transaction_a, tables table_a, nano::mdb_val const & key_a) const
|
||||
int nano::lmdb::store::del (nano::write_transaction const & transaction_a, tables table_a, nano::mdb_val const & key_a) const
|
||||
{
|
||||
return (mdb_del (env.tx (transaction_a), table_to_dbi (table_a), key_a, nullptr));
|
||||
}
|
||||
|
||||
int nano::mdb_store::drop (nano::write_transaction const & transaction_a, tables table_a)
|
||||
int nano::lmdb::store::drop (nano::write_transaction const & transaction_a, tables table_a)
|
||||
{
|
||||
return clear (transaction_a, table_to_dbi (table_a));
|
||||
}
|
||||
|
||||
int nano::mdb_store::clear (nano::write_transaction const & transaction_a, MDB_dbi handle_a)
|
||||
int nano::lmdb::store::clear (nano::write_transaction const & transaction_a, MDB_dbi handle_a)
|
||||
{
|
||||
return mdb_drop (env.tx (transaction_a), handle_a, 0);
|
||||
}
|
||||
|
||||
uint64_t nano::mdb_store::count (nano::transaction const & transaction_a, tables table_a) const
|
||||
uint64_t nano::lmdb::store::count (nano::transaction const & transaction_a, tables table_a) const
|
||||
{
|
||||
return count (transaction_a, table_to_dbi (table_a));
|
||||
}
|
||||
|
||||
uint64_t nano::mdb_store::count (nano::transaction const & transaction_a, MDB_dbi db_a) const
|
||||
uint64_t nano::lmdb::store::count (nano::transaction const & transaction_a, MDB_dbi db_a) const
|
||||
{
|
||||
MDB_stat stats;
|
||||
auto status (mdb_stat (env.tx (transaction_a), db_a, &stats));
|
||||
|
@ -857,7 +856,7 @@ uint64_t nano::mdb_store::count (nano::transaction const & transaction_a, MDB_db
|
|||
return (stats.ms_entries);
|
||||
}
|
||||
|
||||
MDB_dbi nano::mdb_store::table_to_dbi (tables table_a) const
|
||||
MDB_dbi nano::lmdb::store::table_to_dbi (tables table_a) const
|
||||
{
|
||||
switch (table_a)
|
||||
{
|
||||
|
@ -889,32 +888,32 @@ MDB_dbi nano::mdb_store::table_to_dbi (tables table_a) const
|
|||
}
|
||||
}
|
||||
|
||||
bool nano::mdb_store::not_found (int status) const
|
||||
bool nano::lmdb::store::not_found (int status) const
|
||||
{
|
||||
return (status_code_not_found () == status);
|
||||
}
|
||||
|
||||
bool nano::mdb_store::success (int status) const
|
||||
bool nano::lmdb::store::success (int status) const
|
||||
{
|
||||
return (MDB_SUCCESS == status);
|
||||
}
|
||||
|
||||
int nano::mdb_store::status_code_not_found () const
|
||||
int nano::lmdb::store::status_code_not_found () const
|
||||
{
|
||||
return MDB_NOTFOUND;
|
||||
}
|
||||
|
||||
std::string nano::mdb_store::error_string (int status) const
|
||||
std::string nano::lmdb::store::error_string (int status) const
|
||||
{
|
||||
return mdb_strerror (status);
|
||||
}
|
||||
|
||||
bool nano::mdb_store::copy_db (boost::filesystem::path const & destination_file)
|
||||
bool nano::lmdb::store::copy_db (boost::filesystem::path const & destination_file)
|
||||
{
|
||||
return !mdb_env_copy2 (env.environment, destination_file.string ().c_str (), MDB_CP_COMPACT);
|
||||
}
|
||||
|
||||
void nano::mdb_store::rebuild_db (nano::write_transaction const & transaction_a)
|
||||
void nano::lmdb::store::rebuild_db (nano::write_transaction const & transaction_a)
|
||||
{
|
||||
// Tables with uint256_union key
|
||||
std::vector<MDB_dbi> tables = { accounts_handle, blocks_handle, pruned_handle, confirmation_height_handle };
|
||||
|
@ -964,12 +963,12 @@ void nano::mdb_store::rebuild_db (nano::write_transaction const & transaction_a)
|
|||
}
|
||||
}
|
||||
|
||||
bool nano::mdb_store::init_error () const
|
||||
bool nano::lmdb::store::init_error () const
|
||||
{
|
||||
return error;
|
||||
}
|
||||
|
||||
std::shared_ptr<nano::block> nano::mdb_store::block_get_v18 (nano::transaction const & transaction_a, nano::block_hash const & hash_a) const
|
||||
std::shared_ptr<nano::block> nano::lmdb::store::block_get_v18 (nano::transaction const & transaction_a, nano::block_hash const & hash_a) const
|
||||
{
|
||||
nano::block_type type;
|
||||
auto value (block_raw_get_v18 (transaction_a, hash_a, type));
|
||||
|
@ -987,7 +986,7 @@ std::shared_ptr<nano::block> nano::mdb_store::block_get_v18 (nano::transaction c
|
|||
return result;
|
||||
}
|
||||
|
||||
nano::mdb_val nano::mdb_store::block_raw_get_v18 (nano::transaction const & transaction_a, nano::block_hash const & hash_a, nano::block_type & type_a) const
|
||||
nano::mdb_val nano::lmdb::store::block_raw_get_v18 (nano::transaction const & transaction_a, nano::block_hash const & hash_a, nano::block_type & type_a) const
|
||||
{
|
||||
nano::mdb_val result;
|
||||
// Table lookups are ordered by match probability
|
||||
|
@ -1006,7 +1005,7 @@ nano::mdb_val nano::mdb_store::block_raw_get_v18 (nano::transaction const & tran
|
|||
return result;
|
||||
}
|
||||
|
||||
boost::optional<nano::mdb_val> nano::mdb_store::block_raw_get_by_type_v18 (nano::transaction const & transaction_a, nano::block_hash const & hash_a, nano::block_type & type_a) const
|
||||
boost::optional<nano::mdb_val> nano::lmdb::store::block_raw_get_by_type_v18 (nano::transaction const & transaction_a, nano::block_hash const & hash_a, nano::block_type & type_a) const
|
||||
{
|
||||
nano::mdb_val value;
|
||||
nano::mdb_val hash (hash_a);
|
||||
|
@ -1054,7 +1053,7 @@ boost::optional<nano::mdb_val> nano::mdb_store::block_raw_get_by_type_v18 (nano:
|
|||
return result;
|
||||
}
|
||||
|
||||
nano::uint128_t nano::mdb_store::block_balance_v18 (nano::transaction const & transaction_a, nano::block_hash const & hash_a) const
|
||||
nano::uint128_t nano::lmdb::store::block_balance_v18 (nano::transaction const & transaction_a, nano::block_hash const & hash_a) const
|
||||
{
|
||||
auto block (block_get_v18 (transaction_a, hash_a));
|
||||
release_assert (block);
|
||||
|
@ -1063,12 +1062,12 @@ nano::uint128_t nano::mdb_store::block_balance_v18 (nano::transaction const & tr
|
|||
}
|
||||
|
||||
// All the v14 functions below are only needed during upgrades
|
||||
std::size_t nano::mdb_store::block_successor_offset_v14 (nano::transaction const & transaction_a, std::size_t entry_size_a, nano::block_type type_a) const
|
||||
std::size_t nano::lmdb::store::block_successor_offset_v14 (nano::transaction const & transaction_a, std::size_t entry_size_a, nano::block_type type_a) const
|
||||
{
|
||||
return entry_size_a - nano::block_sideband_v14::size (type_a);
|
||||
}
|
||||
|
||||
nano::block_hash nano::mdb_store::block_successor_v14 (nano::transaction const & transaction_a, nano::block_hash const & hash_a) const
|
||||
nano::block_hash nano::lmdb::store::block_successor_v14 (nano::transaction const & transaction_a, nano::block_hash const & hash_a) const
|
||||
{
|
||||
nano::block_type type;
|
||||
auto value (block_raw_get_v14 (transaction_a, hash_a, type));
|
||||
|
@ -1088,7 +1087,7 @@ nano::block_hash nano::mdb_store::block_successor_v14 (nano::transaction const &
|
|||
return result;
|
||||
}
|
||||
|
||||
nano::mdb_val nano::mdb_store::block_raw_get_v14 (nano::transaction const & transaction_a, nano::block_hash const & hash_a, nano::block_type & type_a, bool * is_state_v1) const
|
||||
nano::mdb_val nano::lmdb::store::block_raw_get_v14 (nano::transaction const & transaction_a, nano::block_hash const & hash_a, nano::block_type & type_a, bool * is_state_v1) const
|
||||
{
|
||||
nano::mdb_val result;
|
||||
// Table lookups are ordered by match probability
|
||||
|
@ -1107,7 +1106,7 @@ nano::mdb_val nano::mdb_store::block_raw_get_v14 (nano::transaction const & tran
|
|||
return result;
|
||||
}
|
||||
|
||||
boost::optional<nano::mdb_val> nano::mdb_store::block_raw_get_by_type_v14 (nano::transaction const & transaction_a, nano::block_hash const & hash_a, nano::block_type & type_a, bool * is_state_v1) const
|
||||
boost::optional<nano::mdb_val> nano::lmdb::store::block_raw_get_by_type_v14 (nano::transaction const & transaction_a, nano::block_hash const & hash_a, nano::block_type & type_a, bool * is_state_v1) const
|
||||
{
|
||||
nano::mdb_val value;
|
||||
nano::mdb_val hash (hash_a);
|
||||
|
@ -1163,7 +1162,7 @@ boost::optional<nano::mdb_val> nano::mdb_store::block_raw_get_by_type_v14 (nano:
|
|||
return result;
|
||||
}
|
||||
|
||||
std::shared_ptr<nano::block> nano::mdb_store::block_get_v14 (nano::transaction const & transaction_a, nano::block_hash const & hash_a, nano::block_sideband_v14 * sideband_a, bool * is_state_v1) const
|
||||
std::shared_ptr<nano::block> nano::lmdb::store::block_get_v14 (nano::transaction const & transaction_a, nano::block_hash const & hash_a, nano::block_sideband_v14 * sideband_a, bool * is_state_v1) const
|
||||
{
|
||||
nano::block_type type;
|
||||
auto value (block_raw_get_v14 (transaction_a, hash_a, type, is_state_v1));
|
||||
|
@ -1184,21 +1183,18 @@ std::shared_ptr<nano::block> nano::mdb_store::block_get_v14 (nano::transaction c
|
|||
return result;
|
||||
}
|
||||
|
||||
nano::mdb_store::upgrade_counters::upgrade_counters (uint64_t count_before_v0, uint64_t count_before_v1) :
|
||||
nano::lmdb::store::upgrade_counters::upgrade_counters (uint64_t count_before_v0, uint64_t count_before_v1) :
|
||||
before_v0 (count_before_v0),
|
||||
before_v1 (count_before_v1)
|
||||
{
|
||||
}
|
||||
|
||||
bool nano::mdb_store::upgrade_counters::are_equal () const
|
||||
bool nano::lmdb::store::upgrade_counters::are_equal () const
|
||||
{
|
||||
return (before_v0 == after_v0) && (before_v1 == after_v1);
|
||||
}
|
||||
|
||||
unsigned nano::mdb_store::max_block_write_batch_num () const
|
||||
unsigned nano::lmdb::store::max_block_write_batch_num () const
|
||||
{
|
||||
return std::numeric_limits<unsigned>::max ();
|
||||
}
|
||||
|
||||
// Explicitly instantiate
|
||||
template class nano::store_partial<MDB_val, nano::mdb_store>;
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include <nano/node/lmdb/unchecked_store.hpp>
|
||||
#include <nano/node/lmdb/version_store.hpp>
|
||||
#include <nano/secure/common.hpp>
|
||||
#include <nano/secure/store_partial.hpp>
|
||||
#include <nano/secure/versioning.hpp>
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
|
@ -39,285 +38,287 @@ namespace nano
|
|||
using mdb_val = db_val<MDB_val>;
|
||||
|
||||
class logging_mt;
|
||||
class mdb_store;
|
||||
class transaction;
|
||||
|
||||
/**
|
||||
namespace lmdb
|
||||
{
|
||||
/**
|
||||
* mdb implementation of the block store
|
||||
*/
|
||||
class mdb_store : public store_partial<MDB_val, mdb_store>
|
||||
{
|
||||
private:
|
||||
nano::lmdb::account_store account_store;
|
||||
nano::lmdb::block_store block_store;
|
||||
nano::lmdb::confirmation_height_store confirmation_height_store;
|
||||
nano::lmdb::final_vote_store final_vote_store;
|
||||
nano::lmdb::frontier_store frontier_store;
|
||||
nano::lmdb::online_weight_store online_weight_store;
|
||||
nano::lmdb::peer_store peer_store;
|
||||
nano::lmdb::pending_store pending_store;
|
||||
nano::lmdb::pruned_store pruned_store;
|
||||
nano::lmdb::unchecked_store unchecked_store;
|
||||
nano::lmdb::version_store version_store;
|
||||
class store : public nano::store
|
||||
{
|
||||
private:
|
||||
nano::lmdb::account_store account_store;
|
||||
nano::lmdb::block_store block_store;
|
||||
nano::lmdb::confirmation_height_store confirmation_height_store;
|
||||
nano::lmdb::final_vote_store final_vote_store;
|
||||
nano::lmdb::frontier_store frontier_store;
|
||||
nano::lmdb::online_weight_store online_weight_store;
|
||||
nano::lmdb::peer_store peer_store;
|
||||
nano::lmdb::pending_store pending_store;
|
||||
nano::lmdb::pruned_store pruned_store;
|
||||
nano::lmdb::unchecked_store unchecked_store;
|
||||
nano::lmdb::version_store version_store;
|
||||
|
||||
friend class nano::lmdb::account_store;
|
||||
friend class nano::lmdb::block_store;
|
||||
friend class nano::lmdb::confirmation_height_store;
|
||||
friend class nano::lmdb::final_vote_store;
|
||||
friend class nano::lmdb::frontier_store;
|
||||
friend class nano::lmdb::online_weight_store;
|
||||
friend class nano::lmdb::peer_store;
|
||||
friend class nano::lmdb::pending_store;
|
||||
friend class nano::lmdb::pruned_store;
|
||||
friend class nano::lmdb::unchecked_store;
|
||||
friend class nano::lmdb::version_store;
|
||||
friend class nano::lmdb::account_store;
|
||||
friend class nano::lmdb::block_store;
|
||||
friend class nano::lmdb::confirmation_height_store;
|
||||
friend class nano::lmdb::final_vote_store;
|
||||
friend class nano::lmdb::frontier_store;
|
||||
friend class nano::lmdb::online_weight_store;
|
||||
friend class nano::lmdb::peer_store;
|
||||
friend class nano::lmdb::pending_store;
|
||||
friend class nano::lmdb::pruned_store;
|
||||
friend class nano::lmdb::unchecked_store;
|
||||
friend class nano::lmdb::version_store;
|
||||
|
||||
public:
|
||||
mdb_store (nano::logger_mt &, boost::filesystem::path const &, nano::ledger_constants & constants, nano::txn_tracking_config const & txn_tracking_config_a = nano::txn_tracking_config{}, std::chrono::milliseconds block_processor_batch_max_time_a = std::chrono::milliseconds (5000), nano::lmdb_config const & lmdb_config_a = nano::lmdb_config{}, bool backup_before_upgrade = false);
|
||||
nano::write_transaction tx_begin_write (std::vector<nano::tables> const & tables_requiring_lock = {}, std::vector<nano::tables> const & tables_no_lock = {}) override;
|
||||
nano::read_transaction tx_begin_read () const override;
|
||||
public:
|
||||
store (nano::logger_mt &, boost::filesystem::path const &, nano::ledger_constants & constants, nano::txn_tracking_config const & txn_tracking_config_a = nano::txn_tracking_config{}, std::chrono::milliseconds block_processor_batch_max_time_a = std::chrono::milliseconds (5000), nano::lmdb_config const & lmdb_config_a = nano::lmdb_config{}, bool backup_before_upgrade = false);
|
||||
nano::write_transaction tx_begin_write (std::vector<nano::tables> const & tables_requiring_lock = {}, std::vector<nano::tables> const & tables_no_lock = {}) override;
|
||||
nano::read_transaction tx_begin_read () const override;
|
||||
|
||||
std::string vendor_get () const override;
|
||||
std::string vendor_get () const override;
|
||||
|
||||
void serialize_mdb_tracker (boost::property_tree::ptree &, std::chrono::milliseconds, std::chrono::milliseconds) override;
|
||||
void serialize_mdb_tracker (boost::property_tree::ptree &, std::chrono::milliseconds, std::chrono::milliseconds) override;
|
||||
|
||||
static void create_backup_file (nano::mdb_env &, boost::filesystem::path const &, nano::logger_mt &);
|
||||
static void create_backup_file (nano::mdb_env &, boost::filesystem::path const &, nano::logger_mt &);
|
||||
|
||||
void serialize_memory_stats (boost::property_tree::ptree &) override;
|
||||
void serialize_memory_stats (boost::property_tree::ptree &) override;
|
||||
|
||||
unsigned max_block_write_batch_num () const override;
|
||||
unsigned max_block_write_batch_num () const override;
|
||||
|
||||
private:
|
||||
nano::logger_mt & logger;
|
||||
bool error{ false };
|
||||
private:
|
||||
nano::logger_mt & logger;
|
||||
bool error{ false };
|
||||
|
||||
public:
|
||||
nano::mdb_env env;
|
||||
public:
|
||||
nano::mdb_env env;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Maps head block to owning account
|
||||
* nano::block_hash -> nano::account
|
||||
*/
|
||||
MDB_dbi frontiers_handle{ 0 };
|
||||
MDB_dbi frontiers_handle{ 0 };
|
||||
|
||||
/**
|
||||
/**
|
||||
* Maps account v1 to account information, head, rep, open, balance, timestamp and block count. (Removed)
|
||||
* nano::account -> nano::block_hash, nano::block_hash, nano::block_hash, nano::amount, uint64_t, uint64_t
|
||||
*/
|
||||
MDB_dbi accounts_v0_handle{ 0 };
|
||||
MDB_dbi accounts_v0_handle{ 0 };
|
||||
|
||||
/**
|
||||
/**
|
||||
* Maps account v0 to account information, head, rep, open, balance, timestamp and block count. (Removed)
|
||||
* nano::account -> nano::block_hash, nano::block_hash, nano::block_hash, nano::amount, uint64_t, uint64_t
|
||||
*/
|
||||
MDB_dbi accounts_v1_handle{ 0 };
|
||||
MDB_dbi accounts_v1_handle{ 0 };
|
||||
|
||||
/**
|
||||
/**
|
||||
* Maps account v0 to account information, head, rep, open, balance, timestamp, block count and epoch
|
||||
* nano::account -> nano::block_hash, nano::block_hash, nano::block_hash, nano::amount, uint64_t, uint64_t, nano::epoch
|
||||
*/
|
||||
MDB_dbi accounts_handle{ 0 };
|
||||
MDB_dbi accounts_handle{ 0 };
|
||||
|
||||
/**
|
||||
/**
|
||||
* Maps block hash to send block. (Removed)
|
||||
* nano::block_hash -> nano::send_block
|
||||
*/
|
||||
MDB_dbi send_blocks_handle{ 0 };
|
||||
MDB_dbi send_blocks_handle{ 0 };
|
||||
|
||||
/**
|
||||
/**
|
||||
* Maps block hash to receive block. (Removed)
|
||||
* nano::block_hash -> nano::receive_block
|
||||
*/
|
||||
MDB_dbi receive_blocks_handle{ 0 };
|
||||
MDB_dbi receive_blocks_handle{ 0 };
|
||||
|
||||
/**
|
||||
/**
|
||||
* Maps block hash to open block. (Removed)
|
||||
* nano::block_hash -> nano::open_block
|
||||
*/
|
||||
MDB_dbi open_blocks_handle{ 0 };
|
||||
MDB_dbi open_blocks_handle{ 0 };
|
||||
|
||||
/**
|
||||
/**
|
||||
* Maps block hash to change block. (Removed)
|
||||
* nano::block_hash -> nano::change_block
|
||||
*/
|
||||
MDB_dbi change_blocks_handle{ 0 };
|
||||
MDB_dbi change_blocks_handle{ 0 };
|
||||
|
||||
/**
|
||||
/**
|
||||
* Maps block hash to v0 state block. (Removed)
|
||||
* nano::block_hash -> nano::state_block
|
||||
*/
|
||||
MDB_dbi state_blocks_v0_handle{ 0 };
|
||||
MDB_dbi state_blocks_v0_handle{ 0 };
|
||||
|
||||
/**
|
||||
/**
|
||||
* Maps block hash to v1 state block. (Removed)
|
||||
* nano::block_hash -> nano::state_block
|
||||
*/
|
||||
MDB_dbi state_blocks_v1_handle{ 0 };
|
||||
MDB_dbi state_blocks_v1_handle{ 0 };
|
||||
|
||||
/**
|
||||
/**
|
||||
* Maps block hash to state block. (Removed)
|
||||
* nano::block_hash -> nano::state_block
|
||||
*/
|
||||
MDB_dbi state_blocks_handle{ 0 };
|
||||
MDB_dbi state_blocks_handle{ 0 };
|
||||
|
||||
/**
|
||||
/**
|
||||
* Maps min_version 0 (destination account, pending block) to (source account, amount). (Removed)
|
||||
* nano::account, nano::block_hash -> nano::account, nano::amount
|
||||
*/
|
||||
MDB_dbi pending_v0_handle{ 0 };
|
||||
MDB_dbi pending_v0_handle{ 0 };
|
||||
|
||||
/**
|
||||
/**
|
||||
* Maps min_version 1 (destination account, pending block) to (source account, amount). (Removed)
|
||||
* nano::account, nano::block_hash -> nano::account, nano::amount
|
||||
*/
|
||||
MDB_dbi pending_v1_handle{ 0 };
|
||||
MDB_dbi pending_v1_handle{ 0 };
|
||||
|
||||
/**
|
||||
/**
|
||||
* 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_handle{ 0 };
|
||||
MDB_dbi pending_handle{ 0 };
|
||||
|
||||
/**
|
||||
/**
|
||||
* Representative weights. (Removed)
|
||||
* nano::account -> nano::uint128_t
|
||||
*/
|
||||
MDB_dbi representation_handle{ 0 };
|
||||
MDB_dbi representation_handle{ 0 };
|
||||
|
||||
/**
|
||||
/**
|
||||
* Unchecked bootstrap blocks info.
|
||||
* nano::block_hash -> nano::unchecked_info
|
||||
*/
|
||||
MDB_dbi unchecked_handle{ 0 };
|
||||
MDB_dbi unchecked_handle{ 0 };
|
||||
|
||||
/**
|
||||
/**
|
||||
* Samples of online vote weight
|
||||
* uint64_t -> nano::amount
|
||||
*/
|
||||
MDB_dbi online_weight_handle{ 0 };
|
||||
MDB_dbi online_weight_handle{ 0 };
|
||||
|
||||
/**
|
||||
/**
|
||||
* Meta information about block store, such as versions.
|
||||
* nano::uint256_union (arbitrary key) -> blob
|
||||
*/
|
||||
MDB_dbi meta_handle{ 0 };
|
||||
MDB_dbi meta_handle{ 0 };
|
||||
|
||||
/**
|
||||
/**
|
||||
* Pruned blocks hashes
|
||||
* nano::block_hash -> none
|
||||
*/
|
||||
MDB_dbi pruned_handle{ 0 };
|
||||
MDB_dbi pruned_handle{ 0 };
|
||||
|
||||
/*
|
||||
/*
|
||||
* Endpoints for peers
|
||||
* nano::endpoint_key -> no_value
|
||||
*/
|
||||
MDB_dbi peers_handle{ 0 };
|
||||
MDB_dbi peers_handle{ 0 };
|
||||
|
||||
/*
|
||||
/*
|
||||
* Confirmation height of an account, and the hash for the block at that height
|
||||
* nano::account -> uint64_t, nano::block_hash
|
||||
*/
|
||||
MDB_dbi confirmation_height_handle{ 0 };
|
||||
MDB_dbi confirmation_height_handle{ 0 };
|
||||
|
||||
/*
|
||||
/*
|
||||
* Contains block_sideband and block for all block types (legacy send/change/open/receive & state blocks)
|
||||
* nano::block_hash -> nano::block_sideband, nano::block
|
||||
*/
|
||||
MDB_dbi blocks_handle{ 0 };
|
||||
MDB_dbi blocks_handle{ 0 };
|
||||
|
||||
/**
|
||||
/**
|
||||
* Maps root to block hash for generated final votes.
|
||||
* nano::qualified_root -> nano::block_hash
|
||||
*/
|
||||
MDB_dbi final_votes_handle{ 0 };
|
||||
MDB_dbi final_votes_handle{ 0 };
|
||||
|
||||
bool exists (nano::transaction const & transaction_a, tables table_a, nano::mdb_val const & key_a) const;
|
||||
bool exists (nano::transaction const & transaction_a, tables table_a, nano::mdb_val const & key_a) const;
|
||||
|
||||
int get (nano::transaction const & transaction_a, tables table_a, nano::mdb_val const & key_a, nano::mdb_val & value_a) const;
|
||||
int put (nano::write_transaction const & transaction_a, tables table_a, nano::mdb_val const & key_a, nano::mdb_val const & value_a) const;
|
||||
int del (nano::write_transaction const & transaction_a, tables table_a, nano::mdb_val const & key_a) const;
|
||||
int get (nano::transaction const & transaction_a, tables table_a, nano::mdb_val const & key_a, nano::mdb_val & value_a) const;
|
||||
int put (nano::write_transaction const & transaction_a, tables table_a, nano::mdb_val const & key_a, nano::mdb_val const & value_a) const;
|
||||
int del (nano::write_transaction const & transaction_a, tables table_a, nano::mdb_val const & key_a) const;
|
||||
|
||||
bool copy_db (boost::filesystem::path const & destination_file) override;
|
||||
void rebuild_db (nano::write_transaction const & transaction_a) override;
|
||||
bool copy_db (boost::filesystem::path const & destination_file) override;
|
||||
void rebuild_db (nano::write_transaction const & transaction_a) override;
|
||||
|
||||
template <typename Key, typename Value>
|
||||
nano::store_iterator<Key, Value> make_iterator (nano::transaction const & transaction_a, tables table_a, bool const direction_asc = true) const
|
||||
{
|
||||
return nano::store_iterator<Key, Value> (std::make_unique<nano::mdb_iterator<Key, Value>> (transaction_a, table_to_dbi (table_a), nano::mdb_val{}, direction_asc));
|
||||
}
|
||||
|
||||
template <typename Key, typename Value>
|
||||
nano::store_iterator<Key, Value> make_iterator (nano::transaction const & transaction_a, tables table_a, nano::mdb_val const & key) const
|
||||
{
|
||||
return nano::store_iterator<Key, Value> (std::make_unique<nano::mdb_iterator<Key, Value>> (transaction_a, table_to_dbi (table_a), key));
|
||||
}
|
||||
|
||||
bool init_error () const override;
|
||||
|
||||
uint64_t count (nano::transaction const &, MDB_dbi) const;
|
||||
std::string error_string (int status) const override;
|
||||
|
||||
// These are only use in the upgrade process.
|
||||
std::shared_ptr<nano::block> block_get_v14 (nano::transaction const & transaction_a, nano::block_hash const & hash_a, nano::block_sideband_v14 * sideband_a = nullptr, bool * is_state_v1 = nullptr) const;
|
||||
std::size_t block_successor_offset_v14 (nano::transaction const & transaction_a, std::size_t entry_size_a, nano::block_type type_a) const;
|
||||
nano::block_hash block_successor_v14 (nano::transaction const & transaction_a, nano::block_hash const & hash_a) const;
|
||||
nano::mdb_val block_raw_get_v14 (nano::transaction const & transaction_a, nano::block_hash const & hash_a, nano::block_type & type_a, bool * is_state_v1 = nullptr) const;
|
||||
boost::optional<nano::mdb_val> block_raw_get_by_type_v14 (nano::transaction const & transaction_a, nano::block_hash const & hash_a, nano::block_type & type_a, bool * is_state_v1) const;
|
||||
|
||||
private:
|
||||
bool do_upgrades (nano::write_transaction &, bool &);
|
||||
void upgrade_v14_to_v15 (nano::write_transaction &);
|
||||
void upgrade_v15_to_v16 (nano::write_transaction const &);
|
||||
void upgrade_v16_to_v17 (nano::write_transaction const &);
|
||||
void upgrade_v17_to_v18 (nano::write_transaction const &);
|
||||
void upgrade_v18_to_v19 (nano::write_transaction const &);
|
||||
void upgrade_v19_to_v20 (nano::write_transaction const &);
|
||||
void upgrade_v20_to_v21 (nano::write_transaction const &);
|
||||
|
||||
std::shared_ptr<nano::block> block_get_v18 (nano::transaction const & transaction_a, nano::block_hash const & hash_a) const;
|
||||
nano::mdb_val block_raw_get_v18 (nano::transaction const & transaction_a, nano::block_hash const & hash_a, nano::block_type & type_a) const;
|
||||
boost::optional<nano::mdb_val> block_raw_get_by_type_v18 (nano::transaction const & transaction_a, nano::block_hash const & hash_a, nano::block_type & type_a) const;
|
||||
nano::uint128_t block_balance_v18 (nano::transaction const & transaction_a, nano::block_hash const & hash_a) const;
|
||||
|
||||
void open_databases (bool &, nano::transaction const &, unsigned);
|
||||
|
||||
int drop (nano::write_transaction const & transaction_a, tables table_a) override;
|
||||
int clear (nano::write_transaction const & transaction_a, MDB_dbi handle_a);
|
||||
|
||||
bool not_found (int status) const override;
|
||||
bool success (int status) const override;
|
||||
void release_assert_success (int const status) const
|
||||
{
|
||||
if (!success (status))
|
||||
template <typename Key, typename Value>
|
||||
nano::store_iterator<Key, Value> make_iterator (nano::transaction const & transaction_a, tables table_a, bool const direction_asc = true) const
|
||||
{
|
||||
release_assert (false, error_string (status));
|
||||
return nano::store_iterator<Key, Value> (std::make_unique<nano::mdb_iterator<Key, Value>> (transaction_a, table_to_dbi (table_a), nano::mdb_val{}, direction_asc));
|
||||
}
|
||||
}
|
||||
int status_code_not_found () const override;
|
||||
|
||||
MDB_dbi table_to_dbi (tables table_a) const;
|
||||
template <typename Key, typename Value>
|
||||
nano::store_iterator<Key, Value> make_iterator (nano::transaction const & transaction_a, tables table_a, nano::mdb_val const & key) const
|
||||
{
|
||||
return nano::store_iterator<Key, Value> (std::make_unique<nano::mdb_iterator<Key, Value>> (transaction_a, table_to_dbi (table_a), key));
|
||||
}
|
||||
|
||||
mutable nano::mdb_txn_tracker mdb_txn_tracker;
|
||||
nano::mdb_txn_callbacks create_txn_callbacks () const;
|
||||
bool txn_tracking_enabled;
|
||||
bool init_error () const override;
|
||||
|
||||
uint64_t count (nano::transaction const & transaction_a, tables table_a) const override;
|
||||
uint64_t count (nano::transaction const &, MDB_dbi) const;
|
||||
std::string error_string (int status) const override;
|
||||
|
||||
bool vacuum_after_upgrade (boost::filesystem::path const & path_a, nano::lmdb_config const & lmdb_config_a);
|
||||
// These are only use in the upgrade process.
|
||||
std::shared_ptr<nano::block> block_get_v14 (nano::transaction const & transaction_a, nano::block_hash const & hash_a, nano::block_sideband_v14 * sideband_a = nullptr, bool * is_state_v1 = nullptr) const;
|
||||
std::size_t block_successor_offset_v14 (nano::transaction const & transaction_a, std::size_t entry_size_a, nano::block_type type_a) const;
|
||||
nano::block_hash block_successor_v14 (nano::transaction const & transaction_a, nano::block_hash const & hash_a) const;
|
||||
nano::mdb_val block_raw_get_v14 (nano::transaction const & transaction_a, nano::block_hash const & hash_a, nano::block_type & type_a, bool * is_state_v1 = nullptr) const;
|
||||
boost::optional<nano::mdb_val> block_raw_get_by_type_v14 (nano::transaction const & transaction_a, nano::block_hash const & hash_a, nano::block_type & type_a, bool * is_state_v1) const;
|
||||
|
||||
class upgrade_counters
|
||||
{
|
||||
public:
|
||||
upgrade_counters (uint64_t count_before_v0, uint64_t count_before_v1);
|
||||
bool are_equal () const;
|
||||
private:
|
||||
bool do_upgrades (nano::write_transaction &, nano::ledger_constants & constants, bool &);
|
||||
void upgrade_v14_to_v15 (nano::write_transaction &);
|
||||
void upgrade_v15_to_v16 (nano::write_transaction const &);
|
||||
void upgrade_v16_to_v17 (nano::write_transaction const &);
|
||||
void upgrade_v17_to_v18 (nano::write_transaction const &, nano::ledger_constants & constants);
|
||||
void upgrade_v18_to_v19 (nano::write_transaction const &);
|
||||
void upgrade_v19_to_v20 (nano::write_transaction const &);
|
||||
void upgrade_v20_to_v21 (nano::write_transaction const &);
|
||||
|
||||
uint64_t before_v0;
|
||||
uint64_t before_v1;
|
||||
uint64_t after_v0{ 0 };
|
||||
uint64_t after_v1{ 0 };
|
||||
std::shared_ptr<nano::block> block_get_v18 (nano::transaction const & transaction_a, nano::block_hash const & hash_a) const;
|
||||
nano::mdb_val block_raw_get_v18 (nano::transaction const & transaction_a, nano::block_hash const & hash_a, nano::block_type & type_a) const;
|
||||
boost::optional<nano::mdb_val> block_raw_get_by_type_v18 (nano::transaction const & transaction_a, nano::block_hash const & hash_a, nano::block_type & type_a) const;
|
||||
nano::uint128_t block_balance_v18 (nano::transaction const & transaction_a, nano::block_hash const & hash_a) const;
|
||||
|
||||
void open_databases (bool &, nano::transaction const &, unsigned);
|
||||
|
||||
int drop (nano::write_transaction const & transaction_a, tables table_a) override;
|
||||
int clear (nano::write_transaction const & transaction_a, MDB_dbi handle_a);
|
||||
|
||||
bool not_found (int status) const override;
|
||||
bool success (int status) const override;
|
||||
void release_assert_success (int const status) const
|
||||
{
|
||||
if (!success (status))
|
||||
{
|
||||
release_assert (false, error_string (status));
|
||||
}
|
||||
}
|
||||
int status_code_not_found () const override;
|
||||
|
||||
MDB_dbi table_to_dbi (tables table_a) const;
|
||||
|
||||
mutable nano::mdb_txn_tracker mdb_txn_tracker;
|
||||
nano::mdb_txn_callbacks create_txn_callbacks () const;
|
||||
bool txn_tracking_enabled;
|
||||
|
||||
uint64_t count (nano::transaction const & transaction_a, tables table_a) const override;
|
||||
|
||||
bool vacuum_after_upgrade (boost::filesystem::path const & path_a, nano::lmdb_config const & lmdb_config_a);
|
||||
|
||||
class upgrade_counters
|
||||
{
|
||||
public:
|
||||
upgrade_counters (uint64_t count_before_v0, uint64_t count_before_v1);
|
||||
bool are_equal () const;
|
||||
|
||||
uint64_t before_v0;
|
||||
uint64_t before_v1;
|
||||
uint64_t after_v0{ 0 };
|
||||
uint64_t after_v1{ 0 };
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
template <>
|
||||
void * mdb_val::data () const;
|
||||
|
@ -327,6 +328,4 @@ template <>
|
|||
mdb_val::db_val (std::size_t size_a, void * data_a);
|
||||
template <>
|
||||
void mdb_val::convert_buffer_to_value ();
|
||||
|
||||
extern template class store_partial<MDB_val, mdb_store>;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include <nano/node/lmdb/lmdb.hpp>
|
||||
#include <nano/node/lmdb/online_weight_store.hpp>
|
||||
|
||||
nano::lmdb::online_weight_store::online_weight_store (nano::mdb_store & store_a) :
|
||||
nano::lmdb::online_weight_store::online_weight_store (nano::lmdb::store & store_a) :
|
||||
store{ store_a }
|
||||
{
|
||||
}
|
||||
|
@ -9,13 +9,13 @@ nano::lmdb::online_weight_store::online_weight_store (nano::mdb_store & store_a)
|
|||
void nano::lmdb::online_weight_store::put (nano::write_transaction const & transaction, uint64_t time, nano::amount const & amount)
|
||||
{
|
||||
auto status = store.put (transaction, tables::online_weight, time, amount);
|
||||
release_assert_success (store, status);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
||||
void nano::lmdb::online_weight_store::del (nano::write_transaction const & transaction, uint64_t time)
|
||||
{
|
||||
auto status = store.del (transaction, tables::online_weight, time);
|
||||
release_assert_success (store, status);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
||||
nano::store_iterator<uint64_t, nano::amount> nano::lmdb::online_weight_store::begin (nano::transaction const & transaction) const
|
||||
|
@ -41,5 +41,5 @@ size_t nano::lmdb::online_weight_store::count (nano::transaction const & transac
|
|||
void nano::lmdb::online_weight_store::clear (nano::write_transaction const & transaction)
|
||||
{
|
||||
auto status = store.drop (transaction, tables::online_weight);
|
||||
release_assert_success (store, status);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
|
|
@ -4,16 +4,15 @@
|
|||
|
||||
namespace nano
|
||||
{
|
||||
class mdb_store;
|
||||
namespace lmdb
|
||||
{
|
||||
class online_weight_store : public nano::online_weight_store
|
||||
{
|
||||
private:
|
||||
nano::mdb_store & store;
|
||||
nano::lmdb::store & store;
|
||||
|
||||
public:
|
||||
explicit online_weight_store (nano::mdb_store & store_a);
|
||||
explicit online_weight_store (nano::lmdb::store & store_a);
|
||||
void put (nano::write_transaction const & transaction_a, uint64_t time_a, nano::amount const & amount_a) override;
|
||||
void del (nano::write_transaction const & transaction_a, uint64_t time_a) override;
|
||||
nano::store_iterator<uint64_t, nano::amount> begin (nano::transaction const & transaction_a) const override;
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
#include <nano/node/lmdb/lmdb.hpp>
|
||||
#include <nano/node/lmdb/peer_store.hpp>
|
||||
|
||||
nano::lmdb::peer_store::peer_store (nano::mdb_store & store) :
|
||||
nano::lmdb::peer_store::peer_store (nano::lmdb::store & store) :
|
||||
store{ store } {};
|
||||
|
||||
void nano::lmdb::peer_store::put (nano::write_transaction const & transaction, nano::endpoint_key const & endpoint)
|
||||
{
|
||||
auto status = store.put_key (transaction, tables::peers, endpoint);
|
||||
release_assert_success (store, status);
|
||||
auto status = store.put (transaction, tables::peers, endpoint, nullptr);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
||||
void nano::lmdb::peer_store::del (nano::write_transaction const & transaction, nano::endpoint_key const & endpoint)
|
||||
{
|
||||
auto status = store.del (transaction, tables::peers, endpoint);
|
||||
release_assert_success (store, status);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
||||
bool nano::lmdb::peer_store::exists (nano::transaction const & transaction, nano::endpoint_key const & endpoint) const
|
||||
|
@ -29,7 +29,7 @@ size_t nano::lmdb::peer_store::count (nano::transaction const & transaction) con
|
|||
void nano::lmdb::peer_store::clear (nano::write_transaction const & transaction)
|
||||
{
|
||||
auto status = store.drop (transaction, tables::peers);
|
||||
release_assert_success (store, status);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
||||
nano::store_iterator<nano::endpoint_key, nano::no_value> nano::lmdb::peer_store::begin (nano::transaction const & transaction) const
|
||||
|
|
|
@ -4,16 +4,16 @@
|
|||
|
||||
namespace nano
|
||||
{
|
||||
class mdb_store;
|
||||
namespace lmdb
|
||||
{
|
||||
class store;
|
||||
class peer_store : public nano::peer_store
|
||||
{
|
||||
private:
|
||||
nano::mdb_store & store;
|
||||
nano::lmdb::store & store;
|
||||
|
||||
public:
|
||||
explicit peer_store (nano::mdb_store & store_a);
|
||||
explicit peer_store (nano::lmdb::store & store_a);
|
||||
void put (nano::write_transaction const & transaction_a, nano::endpoint_key const & endpoint_a) override;
|
||||
void del (nano::write_transaction const & transaction_a, nano::endpoint_key const & endpoint_a) override;
|
||||
bool exists (nano::transaction const & transaction_a, nano::endpoint_key const & endpoint_a) const override;
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
#include <nano/node/lmdb/lmdb.hpp>
|
||||
#include <nano/node/lmdb/pending_store.hpp>
|
||||
#include <nano/secure/parallel_traversal.hpp>
|
||||
|
||||
nano::lmdb::pending_store::pending_store (nano::mdb_store & store) :
|
||||
nano::lmdb::pending_store::pending_store (nano::lmdb::store & store) :
|
||||
store{ store } {};
|
||||
|
||||
void nano::lmdb::pending_store::put (nano::write_transaction const & transaction, nano::pending_key const & key, nano::pending_info const & pending)
|
||||
{
|
||||
auto status = store.put (transaction, tables::pending, key, pending);
|
||||
release_assert_success (store, status);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
||||
void nano::lmdb::pending_store::del (nano::write_transaction const & transaction, nano::pending_key const & key)
|
||||
{
|
||||
auto status = store.del (transaction, tables::pending, key);
|
||||
release_assert_success (store, status);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
||||
bool nano::lmdb::pending_store::get (nano::transaction const & transaction, nano::pending_key const & key, nano::pending_info & pending_a)
|
||||
|
|
|
@ -4,16 +4,16 @@
|
|||
|
||||
namespace nano
|
||||
{
|
||||
class mdb_store;
|
||||
namespace lmdb
|
||||
{
|
||||
class store;
|
||||
class pending_store : public nano::pending_store
|
||||
{
|
||||
private:
|
||||
nano::mdb_store & store;
|
||||
nano::lmdb::store & store;
|
||||
|
||||
public:
|
||||
explicit pending_store (nano::mdb_store & store_a);
|
||||
explicit pending_store (nano::lmdb::store & store_a);
|
||||
void put (nano::write_transaction const & transaction_a, nano::pending_key const & key_a, nano::pending_info const & pending_info_a) override;
|
||||
void del (nano::write_transaction const & transaction_a, nano::pending_key const & key_a) override;
|
||||
bool get (nano::transaction const & transaction_a, nano::pending_key const & key_a, nano::pending_info & pending_a) override;
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
#include <nano/node/lmdb/lmdb.hpp>
|
||||
#include <nano/node/lmdb/pruned_store.hpp>
|
||||
#include <nano/secure/parallel_traversal.hpp>
|
||||
|
||||
nano::lmdb::pruned_store::pruned_store (nano::mdb_store & store_a) :
|
||||
nano::lmdb::pruned_store::pruned_store (nano::lmdb::store & store_a) :
|
||||
store{ store_a } {};
|
||||
|
||||
void nano::lmdb::pruned_store::put (nano::write_transaction const & transaction_a, nano::block_hash const & hash_a)
|
||||
{
|
||||
auto status = store.put_key (transaction_a, tables::pruned, hash_a);
|
||||
release_assert_success (store, status);
|
||||
auto status = store.put (transaction_a, tables::pruned, hash_a, nullptr);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
||||
void nano::lmdb::pruned_store::del (nano::write_transaction const & transaction_a, nano::block_hash const & hash_a)
|
||||
{
|
||||
auto status = store.del (transaction_a, tables::pruned, hash_a);
|
||||
release_assert_success (store, status);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
||||
bool nano::lmdb::pruned_store::exists (nano::transaction const & transaction_a, nano::block_hash const & hash_a) const
|
||||
|
@ -41,7 +42,7 @@ size_t nano::lmdb::pruned_store::count (nano::transaction const & transaction_a)
|
|||
void nano::lmdb::pruned_store::clear (nano::write_transaction const & transaction_a)
|
||||
{
|
||||
auto status = store.drop (transaction_a, tables::pruned);
|
||||
release_assert_success (store, status);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
||||
nano::store_iterator<nano::block_hash, std::nullptr_t> nano::lmdb::pruned_store::begin (nano::transaction const & transaction, nano::block_hash const & hash) const
|
||||
|
|
|
@ -4,16 +4,16 @@
|
|||
|
||||
namespace nano
|
||||
{
|
||||
class mdb_store;
|
||||
namespace lmdb
|
||||
{
|
||||
class store;
|
||||
class pruned_store : public nano::pruned_store
|
||||
{
|
||||
private:
|
||||
nano::mdb_store & store;
|
||||
nano::lmdb::store & store;
|
||||
|
||||
public:
|
||||
explicit pruned_store (nano::mdb_store & store_a);
|
||||
explicit pruned_store (nano::lmdb::store & store_a);
|
||||
void put (nano::write_transaction const & transaction_a, nano::block_hash const & hash_a) override;
|
||||
void del (nano::write_transaction const & transaction_a, nano::block_hash const & hash_a) override;
|
||||
bool exists (nano::transaction const & transaction_a, nano::block_hash const & hash_a) const override;
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
#include <nano/node/lmdb/lmdb.hpp>
|
||||
#include <nano/node/lmdb/unchecked_store.hpp>
|
||||
#include <nano/secure/parallel_traversal.hpp>
|
||||
|
||||
nano::lmdb::unchecked_store::unchecked_store (nano::mdb_store & store_a) :
|
||||
nano::lmdb::unchecked_store::unchecked_store (nano::lmdb::store & store_a) :
|
||||
store (store_a){};
|
||||
|
||||
void nano::lmdb::unchecked_store::clear (nano::write_transaction const & transaction_a)
|
||||
{
|
||||
auto status = store.drop (transaction_a, tables::unchecked);
|
||||
release_assert_success (store, status);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
||||
void nano::lmdb::unchecked_store::put (nano::write_transaction const & transaction_a, nano::hash_or_account const & dependency, nano::unchecked_info const & info)
|
||||
{
|
||||
auto status = store.put (transaction_a, tables::unchecked, nano::unchecked_key{ dependency, info.block->hash () }, info);
|
||||
release_assert_success (store, status);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
||||
bool nano::lmdb::unchecked_store::exists (nano::transaction const & transaction_a, nano::unchecked_key const & key)
|
||||
|
@ -27,7 +28,7 @@ bool nano::lmdb::unchecked_store::exists (nano::transaction const & transaction_
|
|||
void nano::lmdb::unchecked_store::del (nano::write_transaction const & transaction_a, nano::unchecked_key const & key_a)
|
||||
{
|
||||
auto status (store.del (transaction_a, tables::unchecked, key_a));
|
||||
release_assert_success (store, status);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
||||
nano::store_iterator<nano::unchecked_key, nano::unchecked_info> nano::lmdb::unchecked_store::end () const
|
||||
|
|
|
@ -4,16 +4,16 @@
|
|||
|
||||
namespace nano
|
||||
{
|
||||
class mdb_store;
|
||||
namespace lmdb
|
||||
{
|
||||
class store;
|
||||
class unchecked_store : public nano::unchecked_store
|
||||
{
|
||||
private:
|
||||
nano::mdb_store & store;
|
||||
nano::lmdb::store & store;
|
||||
|
||||
public:
|
||||
unchecked_store (nano::mdb_store & store_a);
|
||||
unchecked_store (nano::lmdb::store & store_a);
|
||||
|
||||
void clear (nano::write_transaction const & transaction_a) override;
|
||||
void put (nano::write_transaction const & transaction_a, nano::hash_or_account const & dependency, nano::unchecked_info const & info_a) override;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include <nano/node/lmdb/lmdb.hpp>
|
||||
#include <nano/node/lmdb/version_store.hpp>
|
||||
|
||||
nano::lmdb::version_store::version_store (nano::mdb_store & store_a) :
|
||||
nano::lmdb::version_store::version_store (nano::lmdb::store & store_a) :
|
||||
store{ store_a } {};
|
||||
|
||||
void nano::lmdb::version_store::put (nano::write_transaction const & transaction_a, int version)
|
||||
|
@ -9,7 +9,7 @@ void nano::lmdb::version_store::put (nano::write_transaction const & transaction
|
|||
nano::uint256_union version_key{ 1 };
|
||||
nano::uint256_union version_value (version);
|
||||
auto status = store.put (transaction_a, tables::meta, version_key, version_value);
|
||||
release_assert_success (store, status);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
||||
int nano::lmdb::version_store::get (nano::transaction const & transaction_a) const
|
||||
|
@ -17,7 +17,7 @@ int nano::lmdb::version_store::get (nano::transaction const & transaction_a) con
|
|||
nano::uint256_union version_key{ 1 };
|
||||
nano::mdb_val data;
|
||||
auto status = store.get (transaction_a, tables::meta, version_key, data);
|
||||
int result = store.minimum_version;
|
||||
int result = store.version_minimum;
|
||||
if (store.success (status))
|
||||
{
|
||||
nano::uint256_union version_value{ data };
|
||||
|
|
|
@ -4,16 +4,16 @@
|
|||
|
||||
namespace nano
|
||||
{
|
||||
class mdb_store;
|
||||
namespace lmdb
|
||||
{
|
||||
class store;
|
||||
class version_store : public nano::version_store
|
||||
{
|
||||
protected:
|
||||
nano::mdb_store & store;
|
||||
nano::lmdb::store & store;
|
||||
|
||||
public:
|
||||
explicit version_store (nano::mdb_store & store_a);
|
||||
explicit version_store (nano::lmdb::store & store_a);
|
||||
void put (nano::write_transaction const & transaction_a, int version_a) override;
|
||||
int get (nano::transaction const & transaction_a) const override;
|
||||
};
|
||||
|
|
|
@ -360,7 +360,7 @@ nano::node::node (boost::asio::io_context & io_ctx_a, boost::filesystem::path co
|
|||
{
|
||||
auto const transaction (store.tx_begin_write ({ tables::accounts, tables::blocks, tables::confirmation_height, tables::frontiers }));
|
||||
// Store was empty meaning we just created it, add the genesis block
|
||||
store.initialize (transaction, ledger.cache);
|
||||
store.initialize (transaction, ledger.cache, ledger.constants);
|
||||
}
|
||||
|
||||
if (!ledger.block_or_pruned_exists (config.network_params.ledger.genesis->hash ()))
|
||||
|
@ -1857,8 +1857,8 @@ std::unique_ptr<nano::store> nano::make_store (nano::logger_mt & logger, boost::
|
|||
{
|
||||
if (rocksdb_config.enable)
|
||||
{
|
||||
return std::make_unique<nano::rocksdb_store> (logger, add_db_postfix ? path / "rocksdb" : path, constants, rocksdb_config, read_only);
|
||||
return std::make_unique<nano::rocksdb::store> (logger, add_db_postfix ? path / "rocksdb" : path, constants, rocksdb_config, read_only);
|
||||
}
|
||||
|
||||
return std::make_unique<nano::mdb_store> (logger, add_db_postfix ? path / "data.ldb" : path, constants, txn_tracking_config_a, block_processor_batch_max_time_a, lmdb_config_a, backup_before_upgrade);
|
||||
return std::make_unique<nano::lmdb::store> (logger, add_db_postfix ? path / "data.ldb" : path, constants, txn_tracking_config_a, block_processor_batch_max_time_a, lmdb_config_a, backup_before_upgrade);
|
||||
}
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
#include <nano/node/rocksdb/account_store.hpp>
|
||||
#include <nano/node/rocksdb/rocksdb.hpp>
|
||||
#include <nano/secure/parallel_traversal.hpp>
|
||||
|
||||
nano::rocksdb::account_store::account_store (nano::rocksdb_store & store_a) :
|
||||
nano::rocksdb::account_store::account_store (nano::rocksdb::store & store_a) :
|
||||
store (store_a){};
|
||||
|
||||
void nano::rocksdb::account_store::put (nano::write_transaction const & transaction, nano::account const & account, nano::account_info const & info)
|
||||
{
|
||||
auto status = store.put (transaction, tables::accounts, account, info);
|
||||
release_assert_success (store, status);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
||||
bool nano::rocksdb::account_store::get (nano::transaction const & transaction, nano::account const & account, nano::account_info & info)
|
||||
|
@ -27,7 +28,7 @@ bool nano::rocksdb::account_store::get (nano::transaction const & transaction, n
|
|||
void nano::rocksdb::account_store::del (nano::write_transaction const & transaction_a, nano::account const & account_a)
|
||||
{
|
||||
auto status = store.del (transaction_a, tables::accounts, account_a);
|
||||
release_assert_success (store, status);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
||||
bool nano::rocksdb::account_store::exists (nano::transaction const & transaction_a, nano::account const & account_a)
|
||||
|
|
|
@ -4,16 +4,16 @@
|
|||
|
||||
namespace nano
|
||||
{
|
||||
class rocksdb_store;
|
||||
namespace rocksdb
|
||||
{
|
||||
class store;
|
||||
class account_store : public nano::account_store
|
||||
{
|
||||
private:
|
||||
nano::rocksdb_store & store;
|
||||
nano::rocksdb::store & store;
|
||||
|
||||
public:
|
||||
explicit account_store (nano::rocksdb_store & store_a);
|
||||
explicit account_store (nano::rocksdb::store & store_a);
|
||||
void put (nano::write_transaction const & transaction, nano::account const & account, nano::account_info const & info) override;
|
||||
bool get (nano::transaction const & transaction_a, nano::account const & account_a, nano::account_info & info_a) override;
|
||||
void del (nano::write_transaction const & transaction_a, nano::account const & account_a) override;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <nano/node/rocksdb/block_store.hpp>
|
||||
#include <nano/node/rocksdb/rocksdb.hpp>
|
||||
#include <nano/secure/parallel_traversal.hpp>
|
||||
|
||||
namespace nano
|
||||
{
|
||||
|
@ -22,7 +23,7 @@ public:
|
|||
};
|
||||
}
|
||||
|
||||
nano::rocksdb::block_store::block_store (nano::rocksdb_store & store_a) :
|
||||
nano::rocksdb::block_store::block_store (nano::rocksdb::store & store_a) :
|
||||
store{ store_a } {};
|
||||
|
||||
void nano::rocksdb::block_store::put (nano::write_transaction const & transaction, nano::block_hash const & hash, nano::block const & block)
|
||||
|
@ -44,7 +45,7 @@ void nano::rocksdb::block_store::raw_put (nano::write_transaction const & transa
|
|||
{
|
||||
nano::rocksdb_val value{ data.size (), (void *)data.data () };
|
||||
auto status = store.put (transaction_a, tables::blocks, hash_a, value);
|
||||
release_assert_success (store, status);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
||||
nano::block_hash nano::rocksdb::block_store::successor (nano::transaction const & transaction_a, nano::block_hash const & hash_a) const
|
||||
|
@ -130,7 +131,7 @@ std::shared_ptr<nano::block> nano::rocksdb::block_store::random (nano::transacti
|
|||
void nano::rocksdb::block_store::del (nano::write_transaction const & transaction_a, nano::block_hash const & hash_a)
|
||||
{
|
||||
auto status = store.del (transaction_a, tables::blocks, hash_a);
|
||||
release_assert_success (store, status);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
||||
bool nano::rocksdb::block_store::exists (nano::transaction const & transaction, nano::block_hash const & hash)
|
||||
|
|
|
@ -6,18 +6,18 @@
|
|||
|
||||
namespace nano
|
||||
{
|
||||
class rocksdb_store;
|
||||
using rocksdb_val = db_val<::rocksdb::Slice>;
|
||||
class block_predecessor_rocksdb_set;
|
||||
namespace rocksdb
|
||||
{
|
||||
class store;
|
||||
class block_store : public nano::block_store
|
||||
{
|
||||
friend class nano::block_predecessor_rocksdb_set;
|
||||
nano::rocksdb_store & store;
|
||||
nano::rocksdb::store & store;
|
||||
|
||||
public:
|
||||
explicit block_store (nano::rocksdb_store & store_a);
|
||||
explicit block_store (nano::rocksdb::store & store_a);
|
||||
void put (nano::write_transaction const & transaction_a, nano::block_hash const & hash_a, nano::block const & block_a) override;
|
||||
void raw_put (nano::write_transaction const & transaction_a, std::vector<uint8_t> const & data, nano::block_hash const & hash_a) override;
|
||||
nano::block_hash successor (nano::transaction const & transaction_a, nano::block_hash const & hash_a) const override;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include <nano/node/rocksdb/confirmation_height_store.hpp>
|
||||
#include <nano/node/rocksdb/rocksdb.hpp>
|
||||
#include <nano/secure/parallel_traversal.hpp>
|
||||
|
||||
nano::rocksdb::confirmation_height_store::confirmation_height_store (nano::rocksdb_store & store) :
|
||||
nano::rocksdb::confirmation_height_store::confirmation_height_store (nano::rocksdb::store & store) :
|
||||
store{ store }
|
||||
{
|
||||
}
|
||||
|
@ -9,7 +10,7 @@ nano::rocksdb::confirmation_height_store::confirmation_height_store (nano::rocks
|
|||
void nano::rocksdb::confirmation_height_store::put (nano::write_transaction const & transaction, nano::account const & account, nano::confirmation_height_info const & confirmation_height_info)
|
||||
{
|
||||
auto status = store.put (transaction, tables::confirmation_height, account, confirmation_height_info);
|
||||
release_assert_success (store, status);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
||||
bool nano::rocksdb::confirmation_height_store::get (nano::transaction const & transaction, nano::account const & account, nano::confirmation_height_info & confirmation_height_info)
|
||||
|
@ -40,7 +41,7 @@ bool nano::rocksdb::confirmation_height_store::exists (nano::transaction const &
|
|||
void nano::rocksdb::confirmation_height_store::del (nano::write_transaction const & transaction, nano::account const & account)
|
||||
{
|
||||
auto status = store.del (transaction, tables::confirmation_height, account);
|
||||
release_assert_success (store, status);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
||||
uint64_t nano::rocksdb::confirmation_height_store::count (nano::transaction const & transaction)
|
||||
|
|
|
@ -4,15 +4,15 @@
|
|||
|
||||
namespace nano
|
||||
{
|
||||
class rocksdb_store;
|
||||
namespace rocksdb
|
||||
{
|
||||
class store;
|
||||
class confirmation_height_store : public nano::confirmation_height_store
|
||||
{
|
||||
nano::rocksdb_store & store;
|
||||
nano::rocksdb::store & store;
|
||||
|
||||
public:
|
||||
explicit confirmation_height_store (nano::rocksdb_store & store_a);
|
||||
explicit confirmation_height_store (nano::rocksdb::store & store_a);
|
||||
void put (nano::write_transaction const & transaction_a, nano::account const & account_a, nano::confirmation_height_info const & confirmation_height_info_a) override;
|
||||
bool get (nano::transaction const & transaction_a, nano::account const & account_a, nano::confirmation_height_info & confirmation_height_info_a) override;
|
||||
bool exists (nano::transaction const & transaction_a, nano::account const & account_a) const override;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include <nano/node/rocksdb/final_vote_store.hpp>
|
||||
#include <nano/node/rocksdb/rocksdb.hpp>
|
||||
#include <nano/secure/parallel_traversal.hpp>
|
||||
|
||||
nano::rocksdb::final_vote_store::final_vote_store (nano::rocksdb_store & store) :
|
||||
nano::rocksdb::final_vote_store::final_vote_store (nano::rocksdb::store & store) :
|
||||
store{ store } {};
|
||||
|
||||
bool nano::rocksdb::final_vote_store::put (nano::write_transaction const & transaction, nano::qualified_root const & root, nano::block_hash const & hash)
|
||||
|
@ -17,7 +18,7 @@ bool nano::rocksdb::final_vote_store::put (nano::write_transaction const & trans
|
|||
else
|
||||
{
|
||||
status = store.put (transaction, tables::final_votes, root, hash);
|
||||
release_assert_success (store, status);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -44,7 +45,7 @@ void nano::rocksdb::final_vote_store::del (nano::write_transaction const & trans
|
|||
for (auto & final_vote_qualified_root : final_vote_qualified_roots)
|
||||
{
|
||||
auto status = store.del (transaction, tables::final_votes, final_vote_qualified_root);
|
||||
release_assert_success (store, status);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,16 +4,16 @@
|
|||
|
||||
namespace nano
|
||||
{
|
||||
class rocksdb_store;
|
||||
namespace rocksdb
|
||||
{
|
||||
class store;
|
||||
class final_vote_store : public nano::final_vote_store
|
||||
{
|
||||
private:
|
||||
nano::rocksdb_store & store;
|
||||
nano::rocksdb::store & store;
|
||||
|
||||
public:
|
||||
explicit final_vote_store (nano::rocksdb_store & store);
|
||||
explicit final_vote_store (nano::rocksdb::store & store);
|
||||
bool put (nano::write_transaction const & transaction_a, nano::qualified_root const & root_a, nano::block_hash const & hash_a) override;
|
||||
std::vector<nano::block_hash> get (nano::transaction const & transaction_a, nano::root const & root_a) override;
|
||||
void del (nano::write_transaction const & transaction_a, nano::root const & root_a) override;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include <nano/node/rocksdb/frontier_store.hpp>
|
||||
#include <nano/node/rocksdb/rocksdb.hpp>
|
||||
#include <nano/secure/parallel_traversal.hpp>
|
||||
|
||||
nano::rocksdb::frontier_store::frontier_store (nano::rocksdb_store & store) :
|
||||
nano::rocksdb::frontier_store::frontier_store (nano::rocksdb::store & store) :
|
||||
store{ store }
|
||||
{
|
||||
}
|
||||
|
@ -9,7 +10,7 @@ nano::rocksdb::frontier_store::frontier_store (nano::rocksdb_store & store) :
|
|||
void nano::rocksdb::frontier_store::put (nano::write_transaction const & transaction, nano::block_hash const & block, nano::account const & account)
|
||||
{
|
||||
auto status = store.put (transaction, tables::frontiers, block, account);
|
||||
release_assert_success (store, status);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
||||
nano::account nano::rocksdb::frontier_store::get (nano::transaction const & transaction, nano::block_hash const & hash) const
|
||||
|
@ -28,7 +29,7 @@ nano::account nano::rocksdb::frontier_store::get (nano::transaction const & tran
|
|||
void nano::rocksdb::frontier_store::del (nano::write_transaction const & transaction, nano::block_hash const & hash)
|
||||
{
|
||||
auto status = store.del (transaction, tables::frontiers, hash);
|
||||
release_assert_success (store, status);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
||||
nano::store_iterator<nano::block_hash, nano::account> nano::rocksdb::frontier_store::begin (nano::transaction const & transaction) const
|
||||
|
|
|
@ -4,13 +4,13 @@
|
|||
|
||||
namespace nano
|
||||
{
|
||||
class rocksdb_store;
|
||||
namespace rocksdb
|
||||
{
|
||||
class store;
|
||||
class frontier_store : public nano::frontier_store
|
||||
{
|
||||
public:
|
||||
frontier_store (nano::rocksdb_store & store);
|
||||
frontier_store (nano::rocksdb::store & store);
|
||||
void put (nano::write_transaction const &, nano::block_hash const &, nano::account const &) override;
|
||||
nano::account get (nano::transaction const &, nano::block_hash const &) const override;
|
||||
void del (nano::write_transaction const &, nano::block_hash const &) override;
|
||||
|
@ -20,7 +20,7 @@ namespace rocksdb
|
|||
void for_each_par (std::function<void (nano::read_transaction const &, nano::store_iterator<nano::block_hash, nano::account>, nano::store_iterator<nano::block_hash, nano::account>)> const & action_a) const override;
|
||||
|
||||
private:
|
||||
nano::rocksdb_store & store;
|
||||
nano::rocksdb::store & store;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include <nano/node/rocksdb/online_weight_store.hpp>
|
||||
#include <nano/node/rocksdb/rocksdb.hpp>
|
||||
|
||||
nano::rocksdb::online_weight_store::online_weight_store (nano::rocksdb_store & store_a) :
|
||||
nano::rocksdb::online_weight_store::online_weight_store (nano::rocksdb::store & store_a) :
|
||||
store{ store_a }
|
||||
{
|
||||
}
|
||||
|
@ -9,13 +9,13 @@ nano::rocksdb::online_weight_store::online_weight_store (nano::rocksdb_store & s
|
|||
void nano::rocksdb::online_weight_store::put (nano::write_transaction const & transaction, uint64_t time, nano::amount const & amount)
|
||||
{
|
||||
auto status = store.put (transaction, tables::online_weight, time, amount);
|
||||
release_assert_success (store, status);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
||||
void nano::rocksdb::online_weight_store::del (nano::write_transaction const & transaction, uint64_t time)
|
||||
{
|
||||
auto status = store.del (transaction, tables::online_weight, time);
|
||||
release_assert_success (store, status);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
||||
nano::store_iterator<uint64_t, nano::amount> nano::rocksdb::online_weight_store::begin (nano::transaction const & transaction) const
|
||||
|
@ -41,5 +41,5 @@ size_t nano::rocksdb::online_weight_store::count (nano::transaction const & tran
|
|||
void nano::rocksdb::online_weight_store::clear (nano::write_transaction const & transaction)
|
||||
{
|
||||
auto status = store.drop (transaction, tables::online_weight);
|
||||
release_assert_success (store, status);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
|
|
@ -4,16 +4,16 @@
|
|||
|
||||
namespace nano
|
||||
{
|
||||
class rocksdb_store;
|
||||
namespace rocksdb
|
||||
{
|
||||
class store;
|
||||
class online_weight_store : public nano::online_weight_store
|
||||
{
|
||||
private:
|
||||
nano::rocksdb_store & store;
|
||||
nano::rocksdb::store & store;
|
||||
|
||||
public:
|
||||
explicit online_weight_store (nano::rocksdb_store & store_a);
|
||||
explicit online_weight_store (nano::rocksdb::store & store_a);
|
||||
void put (nano::write_transaction const & transaction_a, uint64_t time_a, nano::amount const & amount_a) override;
|
||||
void del (nano::write_transaction const & transaction_a, uint64_t time_a) override;
|
||||
nano::store_iterator<uint64_t, nano::amount> begin (nano::transaction const & transaction_a) const override;
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
#include <nano/node/rocksdb/peer_store.hpp>
|
||||
#include <nano/node/rocksdb/rocksdb.hpp>
|
||||
|
||||
nano::rocksdb::peer_store::peer_store (nano::rocksdb_store & store) :
|
||||
nano::rocksdb::peer_store::peer_store (nano::rocksdb::store & store) :
|
||||
store{ store } {};
|
||||
|
||||
void nano::rocksdb::peer_store::put (nano::write_transaction const & transaction, nano::endpoint_key const & endpoint)
|
||||
{
|
||||
auto status = store.put_key (transaction, tables::peers, endpoint);
|
||||
release_assert_success (store, status);
|
||||
auto status = store.put (transaction, tables::peers, endpoint, nullptr);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
||||
void nano::rocksdb::peer_store::del (nano::write_transaction const & transaction, nano::endpoint_key const & endpoint)
|
||||
{
|
||||
auto status = store.del (transaction, tables::peers, endpoint);
|
||||
release_assert_success (store, status);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
||||
bool nano::rocksdb::peer_store::exists (nano::transaction const & transaction, nano::endpoint_key const & endpoint) const
|
||||
|
@ -29,7 +29,7 @@ size_t nano::rocksdb::peer_store::count (nano::transaction const & transaction)
|
|||
void nano::rocksdb::peer_store::clear (nano::write_transaction const & transaction)
|
||||
{
|
||||
auto status = store.drop (transaction, tables::peers);
|
||||
release_assert_success (store, status);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
||||
nano::store_iterator<nano::endpoint_key, nano::no_value> nano::rocksdb::peer_store::begin (nano::transaction const & transaction) const
|
||||
|
|
|
@ -4,16 +4,16 @@
|
|||
|
||||
namespace nano
|
||||
{
|
||||
class rocksdb_store;
|
||||
namespace rocksdb
|
||||
{
|
||||
class store;
|
||||
class peer_store : public nano::peer_store
|
||||
{
|
||||
private:
|
||||
nano::rocksdb_store & store;
|
||||
nano::rocksdb::store & store;
|
||||
|
||||
public:
|
||||
explicit peer_store (nano::rocksdb_store & store_a);
|
||||
explicit peer_store (nano::rocksdb::store & store_a);
|
||||
void put (nano::write_transaction const & transaction_a, nano::endpoint_key const & endpoint_a) override;
|
||||
void del (nano::write_transaction const & transaction_a, nano::endpoint_key const & endpoint_a) override;
|
||||
bool exists (nano::transaction const & transaction_a, nano::endpoint_key const & endpoint_a) const override;
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
#include <nano/node/lmdb/pending_store.hpp>
|
||||
#include <nano/node/rocksdb/rocksdb.hpp>
|
||||
#include <nano/secure/parallel_traversal.hpp>
|
||||
|
||||
nano::rocksdb::pending_store::pending_store (nano::rocksdb_store & store) :
|
||||
nano::rocksdb::pending_store::pending_store (nano::rocksdb::store & store) :
|
||||
store{ store } {};
|
||||
|
||||
void nano::rocksdb::pending_store::put (nano::write_transaction const & transaction, nano::pending_key const & key, nano::pending_info const & pending)
|
||||
{
|
||||
auto status = store.put (transaction, tables::pending, key, pending);
|
||||
release_assert_success (store, status);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
||||
void nano::rocksdb::pending_store::del (nano::write_transaction const & transaction, nano::pending_key const & key)
|
||||
{
|
||||
auto status = store.del (transaction, tables::pending, key);
|
||||
release_assert_success (store, status);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
||||
bool nano::rocksdb::pending_store::get (nano::transaction const & transaction, nano::pending_key const & key, nano::pending_info & pending)
|
||||
|
|
|
@ -4,16 +4,16 @@
|
|||
|
||||
namespace nano
|
||||
{
|
||||
class rocksdb_store;
|
||||
namespace rocksdb
|
||||
{
|
||||
class store;
|
||||
class pending_store : public nano::pending_store
|
||||
{
|
||||
private:
|
||||
nano::rocksdb_store & store;
|
||||
nano::rocksdb::store & store;
|
||||
|
||||
public:
|
||||
explicit pending_store (nano::rocksdb_store & store_a);
|
||||
explicit pending_store (nano::rocksdb::store & store_a);
|
||||
void put (nano::write_transaction const & transaction_a, nano::pending_key const & key_a, nano::pending_info const & pending_info_a) override;
|
||||
void del (nano::write_transaction const & transaction_a, nano::pending_key const & key_a) override;
|
||||
bool get (nano::transaction const & transaction_a, nano::pending_key const & key_a, nano::pending_info & pending_a) override;
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
#include <nano/node/rocksdb/pruned_store.hpp>
|
||||
#include <nano/node/rocksdb/rocksdb.hpp>
|
||||
#include <nano/secure/parallel_traversal.hpp>
|
||||
|
||||
nano::rocksdb::pruned_store::pruned_store (nano::rocksdb_store & store_a) :
|
||||
nano::rocksdb::pruned_store::pruned_store (nano::rocksdb::store & store_a) :
|
||||
store{ store_a } {};
|
||||
|
||||
void nano::rocksdb::pruned_store::put (nano::write_transaction const & transaction_a, nano::block_hash const & hash_a)
|
||||
{
|
||||
auto status = store.put_key (transaction_a, tables::pruned, hash_a);
|
||||
release_assert_success (store, status);
|
||||
auto status = store.put (transaction_a, tables::pruned, hash_a, nullptr);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
||||
void nano::rocksdb::pruned_store::del (nano::write_transaction const & transaction_a, nano::block_hash const & hash_a)
|
||||
{
|
||||
auto status = store.del (transaction_a, tables::pruned, hash_a);
|
||||
release_assert_success (store, status);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
||||
bool nano::rocksdb::pruned_store::exists (nano::transaction const & transaction, nano::block_hash const & hash_a) const
|
||||
|
@ -41,7 +42,7 @@ size_t nano::rocksdb::pruned_store::count (nano::transaction const & transaction
|
|||
void nano::rocksdb::pruned_store::clear (nano::write_transaction const & transaction_a)
|
||||
{
|
||||
auto status = store.drop (transaction_a, tables::pruned);
|
||||
release_assert_success (store, status);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
||||
nano::store_iterator<nano::block_hash, std::nullptr_t> nano::rocksdb::pruned_store::begin (nano::transaction const & transaction_a, nano::block_hash const & hash_a) const
|
||||
|
|
|
@ -4,16 +4,16 @@
|
|||
|
||||
namespace nano
|
||||
{
|
||||
class rocksdb_store;
|
||||
namespace rocksdb
|
||||
{
|
||||
class store;
|
||||
class pruned_store : public nano::pruned_store
|
||||
{
|
||||
private:
|
||||
nano::rocksdb_store & store;
|
||||
nano::rocksdb::store & store;
|
||||
|
||||
public:
|
||||
explicit pruned_store (nano::rocksdb_store & store_a);
|
||||
explicit pruned_store (nano::rocksdb::store & store_a);
|
||||
void put (nano::write_transaction const & transaction_a, nano::block_hash const & hash_a) override;
|
||||
void del (nano::write_transaction const & transaction_a, nano::block_hash const & hash_a) override;
|
||||
bool exists (nano::transaction const & transaction_a, nano::block_hash const & hash_a) const override;
|
||||
|
|
|
@ -63,10 +63,9 @@ void rocksdb_val::convert_buffer_to_value ()
|
|||
}
|
||||
}
|
||||
|
||||
nano::rocksdb_store::rocksdb_store (nano::logger_mt & logger_a, boost::filesystem::path const & path_a, nano::ledger_constants & constants, nano::rocksdb_config const & rocksdb_config_a, bool open_read_only_a) :
|
||||
nano::rocksdb::store::store (nano::logger_mt & logger_a, boost::filesystem::path const & path_a, nano::ledger_constants & constants, nano::rocksdb_config const & rocksdb_config_a, bool open_read_only_a) :
|
||||
// clang-format off
|
||||
store_partial{
|
||||
constants,
|
||||
nano::store{
|
||||
block_store,
|
||||
frontier_store,
|
||||
account_store,
|
||||
|
@ -114,7 +113,7 @@ nano::rocksdb_store::rocksdb_store (nano::logger_mt & logger_a, boost::filesyste
|
|||
}
|
||||
}
|
||||
|
||||
std::unordered_map<char const *, nano::tables> nano::rocksdb_store::create_cf_name_table_map () const
|
||||
std::unordered_map<char const *, nano::tables> nano::rocksdb::store::create_cf_name_table_map () const
|
||||
{
|
||||
std::unordered_map<char const *, nano::tables> map{ { ::rocksdb::kDefaultColumnFamilyName.c_str (), tables::default_unused },
|
||||
{ "frontiers", tables::frontiers },
|
||||
|
@ -134,7 +133,7 @@ std::unordered_map<char const *, nano::tables> nano::rocksdb_store::create_cf_na
|
|||
return map;
|
||||
}
|
||||
|
||||
void nano::rocksdb_store::open (bool & error_a, boost::filesystem::path const & path_a, bool open_read_only_a)
|
||||
void nano::rocksdb::store::open (bool & error_a, boost::filesystem::path const & path_a, bool open_read_only_a)
|
||||
{
|
||||
auto column_families = create_column_families ();
|
||||
auto options = get_db_options ();
|
||||
|
@ -169,7 +168,7 @@ void nano::rocksdb_store::open (bool & error_a, boost::filesystem::path const &
|
|||
{
|
||||
auto transaction = tx_begin_read ();
|
||||
auto version_l = version.get (transaction);
|
||||
if (version_l > version_number)
|
||||
if (version_l > version_current)
|
||||
{
|
||||
error_a = true;
|
||||
logger.always_log (boost::str (boost::format ("The version of the ledger (%1%) is too high for this node") % version_l));
|
||||
|
@ -177,7 +176,7 @@ void nano::rocksdb_store::open (bool & error_a, boost::filesystem::path const &
|
|||
}
|
||||
}
|
||||
|
||||
void nano::rocksdb_store::generate_tombstone_map ()
|
||||
void nano::rocksdb::store::generate_tombstone_map ()
|
||||
{
|
||||
tombstone_map.emplace (std::piecewise_construct, std::forward_as_tuple (nano::tables::unchecked), std::forward_as_tuple (0, 50000));
|
||||
tombstone_map.emplace (std::piecewise_construct, std::forward_as_tuple (nano::tables::blocks), std::forward_as_tuple (0, 25000));
|
||||
|
@ -185,7 +184,7 @@ void nano::rocksdb_store::generate_tombstone_map ()
|
|||
tombstone_map.emplace (std::piecewise_construct, std::forward_as_tuple (nano::tables::pending), std::forward_as_tuple (0, 25000));
|
||||
}
|
||||
|
||||
rocksdb::ColumnFamilyOptions nano::rocksdb_store::get_common_cf_options (std::shared_ptr<::rocksdb::TableFactory> const & table_factory_a, unsigned long long memtable_size_bytes_a) const
|
||||
rocksdb::ColumnFamilyOptions nano::rocksdb::store::get_common_cf_options (std::shared_ptr<::rocksdb::TableFactory> const & table_factory_a, unsigned long long memtable_size_bytes_a) const
|
||||
{
|
||||
::rocksdb::ColumnFamilyOptions cf_options;
|
||||
cf_options.table_factory = table_factory_a;
|
||||
|
@ -217,7 +216,7 @@ rocksdb::ColumnFamilyOptions nano::rocksdb_store::get_common_cf_options (std::sh
|
|||
return cf_options;
|
||||
}
|
||||
|
||||
rocksdb::ColumnFamilyOptions nano::rocksdb_store::get_cf_options (std::string const & cf_name_a) const
|
||||
rocksdb::ColumnFamilyOptions nano::rocksdb::store::get_cf_options (std::string const & cf_name_a) const
|
||||
{
|
||||
::rocksdb::ColumnFamilyOptions cf_options;
|
||||
auto const memtable_size_bytes = base_memtable_size_bytes ();
|
||||
|
@ -311,7 +310,7 @@ rocksdb::ColumnFamilyOptions nano::rocksdb_store::get_cf_options (std::string co
|
|||
return cf_options;
|
||||
}
|
||||
|
||||
std::vector<rocksdb::ColumnFamilyDescriptor> nano::rocksdb_store::create_column_families ()
|
||||
std::vector<rocksdb::ColumnFamilyDescriptor> nano::rocksdb::store::create_column_families ()
|
||||
{
|
||||
std::vector<::rocksdb::ColumnFamilyDescriptor> column_families;
|
||||
for (auto & [cf_name, table] : cf_name_table_map)
|
||||
|
@ -322,7 +321,7 @@ std::vector<rocksdb::ColumnFamilyDescriptor> nano::rocksdb_store::create_column_
|
|||
return column_families;
|
||||
}
|
||||
|
||||
nano::write_transaction nano::rocksdb_store::tx_begin_write (std::vector<nano::tables> const & tables_requiring_locks_a, std::vector<nano::tables> const & tables_no_locks_a)
|
||||
nano::write_transaction nano::rocksdb::store::tx_begin_write (std::vector<nano::tables> const & tables_requiring_locks_a, std::vector<nano::tables> const & tables_no_locks_a)
|
||||
{
|
||||
std::unique_ptr<nano::write_rocksdb_txn> txn;
|
||||
release_assert (optimistic_db != nullptr);
|
||||
|
@ -342,17 +341,17 @@ nano::write_transaction nano::rocksdb_store::tx_begin_write (std::vector<nano::t
|
|||
return nano::write_transaction{ std::move (txn) };
|
||||
}
|
||||
|
||||
nano::read_transaction nano::rocksdb_store::tx_begin_read () const
|
||||
nano::read_transaction nano::rocksdb::store::tx_begin_read () const
|
||||
{
|
||||
return nano::read_transaction{ std::make_unique<nano::read_rocksdb_txn> (db.get ()) };
|
||||
}
|
||||
|
||||
std::string nano::rocksdb_store::vendor_get () const
|
||||
std::string nano::rocksdb::store::vendor_get () const
|
||||
{
|
||||
return boost::str (boost::format ("RocksDB %1%.%2%.%3%") % ROCKSDB_MAJOR % ROCKSDB_MINOR % ROCKSDB_PATCH);
|
||||
}
|
||||
|
||||
rocksdb::ColumnFamilyHandle * nano::rocksdb_store::table_to_column_family (tables table_a) const
|
||||
rocksdb::ColumnFamilyHandle * nano::rocksdb::store::table_to_column_family (tables table_a) const
|
||||
{
|
||||
auto & handles_l = handles;
|
||||
auto get_handle = [&handles_l] (char const * name) {
|
||||
|
@ -395,7 +394,7 @@ rocksdb::ColumnFamilyHandle * nano::rocksdb_store::table_to_column_family (table
|
|||
}
|
||||
}
|
||||
|
||||
bool nano::rocksdb_store::exists (nano::transaction const & transaction_a, tables table_a, nano::rocksdb_val const & key_a) const
|
||||
bool nano::rocksdb::store::exists (nano::transaction const & transaction_a, tables table_a, nano::rocksdb_val const & key_a) const
|
||||
{
|
||||
::rocksdb::PinnableSlice slice;
|
||||
::rocksdb::Status status;
|
||||
|
@ -413,7 +412,7 @@ bool nano::rocksdb_store::exists (nano::transaction const & transaction_a, table
|
|||
return (status.ok ());
|
||||
}
|
||||
|
||||
int nano::rocksdb_store::del (nano::write_transaction const & transaction_a, tables table_a, nano::rocksdb_val const & key_a)
|
||||
int nano::rocksdb::store::del (nano::write_transaction const & transaction_a, tables table_a, nano::rocksdb_val const & key_a)
|
||||
{
|
||||
debug_assert (transaction_a.contains (table_a));
|
||||
// RocksDB does not report not_found status, it is a pre-condition that the key exists
|
||||
|
@ -422,7 +421,7 @@ int nano::rocksdb_store::del (nano::write_transaction const & transaction_a, tab
|
|||
return tx (transaction_a)->Delete (table_to_column_family (table_a), key_a).code ();
|
||||
}
|
||||
|
||||
void nano::rocksdb_store::flush_tombstones_check (tables table_a)
|
||||
void nano::rocksdb::store::flush_tombstones_check (tables table_a)
|
||||
{
|
||||
// Update the number of deletes for some tables, and force a flush if there are too many tombstones
|
||||
// as it can affect read performance.
|
||||
|
@ -437,18 +436,18 @@ void nano::rocksdb_store::flush_tombstones_check (tables table_a)
|
|||
}
|
||||
}
|
||||
|
||||
void nano::rocksdb_store::flush_table (nano::tables table_a)
|
||||
void nano::rocksdb::store::flush_table (nano::tables table_a)
|
||||
{
|
||||
db->Flush (::rocksdb::FlushOptions{}, table_to_column_family (table_a));
|
||||
}
|
||||
|
||||
rocksdb::Transaction * nano::rocksdb_store::tx (nano::transaction const & transaction_a) const
|
||||
rocksdb::Transaction * nano::rocksdb::store::tx (nano::transaction const & transaction_a) const
|
||||
{
|
||||
debug_assert (!is_read (transaction_a));
|
||||
return static_cast<::rocksdb::Transaction *> (transaction_a.get_handle ());
|
||||
}
|
||||
|
||||
int nano::rocksdb_store::get (nano::transaction const & transaction_a, tables table_a, nano::rocksdb_val const & key_a, nano::rocksdb_val & value_a) const
|
||||
int nano::rocksdb::store::get (nano::transaction const & transaction_a, tables table_a, nano::rocksdb_val const & key_a, nano::rocksdb_val & value_a) const
|
||||
{
|
||||
::rocksdb::ReadOptions options;
|
||||
::rocksdb::PinnableSlice slice;
|
||||
|
@ -472,29 +471,29 @@ int nano::rocksdb_store::get (nano::transaction const & transaction_a, tables ta
|
|||
return status.code ();
|
||||
}
|
||||
|
||||
int nano::rocksdb_store::put (nano::write_transaction const & transaction_a, tables table_a, nano::rocksdb_val const & key_a, nano::rocksdb_val const & value_a)
|
||||
int nano::rocksdb::store::put (nano::write_transaction const & transaction_a, tables table_a, nano::rocksdb_val const & key_a, nano::rocksdb_val const & value_a)
|
||||
{
|
||||
debug_assert (transaction_a.contains (table_a));
|
||||
auto txn = tx (transaction_a);
|
||||
return txn->Put (table_to_column_family (table_a), key_a, value_a).code ();
|
||||
}
|
||||
|
||||
bool nano::rocksdb_store::not_found (int status) const
|
||||
bool nano::rocksdb::store::not_found (int status) const
|
||||
{
|
||||
return (status_code_not_found () == status);
|
||||
}
|
||||
|
||||
bool nano::rocksdb_store::success (int status) const
|
||||
bool nano::rocksdb::store::success (int status) const
|
||||
{
|
||||
return (static_cast<int> (::rocksdb::Status::Code::kOk) == status);
|
||||
}
|
||||
|
||||
int nano::rocksdb_store::status_code_not_found () const
|
||||
int nano::rocksdb::store::status_code_not_found () const
|
||||
{
|
||||
return static_cast<int> (::rocksdb::Status::Code::kNotFound);
|
||||
}
|
||||
|
||||
uint64_t nano::rocksdb_store::count (nano::transaction const & transaction_a, tables table_a) const
|
||||
uint64_t nano::rocksdb::store::count (nano::transaction const & transaction_a, tables table_a) const
|
||||
{
|
||||
uint64_t sum = 0;
|
||||
// Peers/online weight are small enough that they can just be iterated to get accurate counts.
|
||||
|
@ -560,7 +559,7 @@ uint64_t nano::rocksdb_store::count (nano::transaction const & transaction_a, ta
|
|||
return sum;
|
||||
}
|
||||
|
||||
int nano::rocksdb_store::drop (nano::write_transaction const & transaction_a, tables table_a)
|
||||
int nano::rocksdb::store::drop (nano::write_transaction const & transaction_a, tables table_a)
|
||||
{
|
||||
debug_assert (transaction_a.contains (table_a));
|
||||
auto col = table_to_column_family (table_a);
|
||||
|
@ -587,7 +586,7 @@ int nano::rocksdb_store::drop (nano::write_transaction const & transaction_a, ta
|
|||
return status;
|
||||
}
|
||||
|
||||
int nano::rocksdb_store::clear (::rocksdb::ColumnFamilyHandle * column_family)
|
||||
int nano::rocksdb::store::clear (::rocksdb::ColumnFamilyHandle * column_family)
|
||||
{
|
||||
// Dropping completely removes the column
|
||||
auto name = column_family->GetName ();
|
||||
|
@ -605,7 +604,7 @@ int nano::rocksdb_store::clear (::rocksdb::ColumnFamilyHandle * column_family)
|
|||
return status.code ();
|
||||
}
|
||||
|
||||
void nano::rocksdb_store::construct_column_family_mutexes ()
|
||||
void nano::rocksdb::store::construct_column_family_mutexes ()
|
||||
{
|
||||
for (auto table : all_tables ())
|
||||
{
|
||||
|
@ -613,7 +612,7 @@ void nano::rocksdb_store::construct_column_family_mutexes ()
|
|||
}
|
||||
}
|
||||
|
||||
rocksdb::Options nano::rocksdb_store::get_db_options ()
|
||||
rocksdb::Options nano::rocksdb::store::get_db_options ()
|
||||
{
|
||||
::rocksdb::Options db_options;
|
||||
db_options.create_if_missing = true;
|
||||
|
@ -652,7 +651,7 @@ rocksdb::Options nano::rocksdb_store::get_db_options ()
|
|||
return db_options;
|
||||
}
|
||||
|
||||
rocksdb::BlockBasedTableOptions nano::rocksdb_store::get_active_table_options (std::size_t lru_size) const
|
||||
rocksdb::BlockBasedTableOptions nano::rocksdb::store::get_active_table_options (std::size_t lru_size) const
|
||||
{
|
||||
::rocksdb::BlockBasedTableOptions table_options;
|
||||
|
||||
|
@ -681,7 +680,7 @@ rocksdb::BlockBasedTableOptions nano::rocksdb_store::get_active_table_options (s
|
|||
return table_options;
|
||||
}
|
||||
|
||||
rocksdb::BlockBasedTableOptions nano::rocksdb_store::get_small_table_options () const
|
||||
rocksdb::BlockBasedTableOptions nano::rocksdb::store::get_small_table_options () const
|
||||
{
|
||||
::rocksdb::BlockBasedTableOptions table_options;
|
||||
// Improve point lookup performance be using the data block hash index (uses about 5% more space).
|
||||
|
@ -691,7 +690,7 @@ rocksdb::BlockBasedTableOptions nano::rocksdb_store::get_small_table_options ()
|
|||
return table_options;
|
||||
}
|
||||
|
||||
rocksdb::ColumnFamilyOptions nano::rocksdb_store::get_small_cf_options (std::shared_ptr<::rocksdb::TableFactory> const & table_factory_a) const
|
||||
rocksdb::ColumnFamilyOptions nano::rocksdb::store::get_small_cf_options (std::shared_ptr<::rocksdb::TableFactory> const & table_factory_a) const
|
||||
{
|
||||
auto const memtable_size_bytes = 10000;
|
||||
auto cf_options = get_common_cf_options (table_factory_a, memtable_size_bytes);
|
||||
|
@ -705,7 +704,7 @@ rocksdb::ColumnFamilyOptions nano::rocksdb_store::get_small_cf_options (std::sha
|
|||
return cf_options;
|
||||
}
|
||||
|
||||
::rocksdb::ColumnFamilyOptions nano::rocksdb_store::get_active_cf_options (std::shared_ptr<::rocksdb::TableFactory> const & table_factory_a, unsigned long long memtable_size_bytes_a) const
|
||||
::rocksdb::ColumnFamilyOptions nano::rocksdb::store::get_active_cf_options (std::shared_ptr<::rocksdb::TableFactory> const & table_factory_a, unsigned long long memtable_size_bytes_a) const
|
||||
{
|
||||
auto cf_options = get_common_cf_options (table_factory_a, memtable_size_bytes_a);
|
||||
|
||||
|
@ -721,7 +720,7 @@ rocksdb::ColumnFamilyOptions nano::rocksdb_store::get_small_cf_options (std::sha
|
|||
return cf_options;
|
||||
}
|
||||
|
||||
void nano::rocksdb_store::on_flush (::rocksdb::FlushJobInfo const & flush_job_info_a)
|
||||
void nano::rocksdb::store::on_flush (::rocksdb::FlushJobInfo const & flush_job_info_a)
|
||||
{
|
||||
// Reset appropriate tombstone counters
|
||||
if (auto it = tombstone_map.find (cf_name_table_map[flush_job_info_a.cf_name.c_str ()]); it != tombstone_map.end ())
|
||||
|
@ -730,12 +729,12 @@ void nano::rocksdb_store::on_flush (::rocksdb::FlushJobInfo const & flush_job_in
|
|||
}
|
||||
}
|
||||
|
||||
std::vector<nano::tables> nano::rocksdb_store::all_tables () const
|
||||
std::vector<nano::tables> nano::rocksdb::store::all_tables () const
|
||||
{
|
||||
return std::vector<nano::tables>{ tables::accounts, tables::blocks, tables::confirmation_height, tables::final_votes, tables::frontiers, tables::meta, tables::online_weight, tables::peers, tables::pending, tables::pruned, tables::unchecked, tables::vote };
|
||||
}
|
||||
|
||||
bool nano::rocksdb_store::copy_db (boost::filesystem::path const & destination_path)
|
||||
bool nano::rocksdb::store::copy_db (boost::filesystem::path const & destination_path)
|
||||
{
|
||||
std::unique_ptr<::rocksdb::BackupEngine> backup_engine;
|
||||
{
|
||||
|
@ -799,23 +798,23 @@ bool nano::rocksdb_store::copy_db (boost::filesystem::path const & destination_p
|
|||
// Open it so that it flushes all WAL files
|
||||
if (status.ok ())
|
||||
{
|
||||
nano::rocksdb_store rocksdb_store (logger, destination_path.string (), constants, rocksdb_config, false);
|
||||
nano::rocksdb::store rocksdb_store{ logger, destination_path.string (), constants, rocksdb_config, false };
|
||||
return !rocksdb_store.init_error ();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void nano::rocksdb_store::rebuild_db (nano::write_transaction const & transaction_a)
|
||||
void nano::rocksdb::store::rebuild_db (nano::write_transaction const & transaction_a)
|
||||
{
|
||||
// Not available for RocksDB
|
||||
}
|
||||
|
||||
bool nano::rocksdb_store::init_error () const
|
||||
bool nano::rocksdb::store::init_error () const
|
||||
{
|
||||
return error;
|
||||
}
|
||||
|
||||
void nano::rocksdb_store::serialize_memory_stats (boost::property_tree::ptree & json)
|
||||
void nano::rocksdb::store::serialize_memory_stats (boost::property_tree::ptree & json)
|
||||
{
|
||||
uint64_t val;
|
||||
|
||||
|
@ -862,32 +861,29 @@ void nano::rocksdb_store::serialize_memory_stats (boost::property_tree::ptree &
|
|||
json.put ("block-cache-usage", val);
|
||||
}
|
||||
|
||||
unsigned long long nano::rocksdb_store::blocks_memtable_size_bytes () const
|
||||
unsigned long long nano::rocksdb::store::blocks_memtable_size_bytes () const
|
||||
{
|
||||
return base_memtable_size_bytes ();
|
||||
}
|
||||
|
||||
unsigned long long nano::rocksdb_store::base_memtable_size_bytes () const
|
||||
unsigned long long nano::rocksdb::store::base_memtable_size_bytes () const
|
||||
{
|
||||
return 1024ULL * 1024 * rocksdb_config.memory_multiplier * base_memtable_size;
|
||||
}
|
||||
|
||||
// This is a ratio of the blocks memtable size to keep total write transaction commit size down.
|
||||
unsigned nano::rocksdb_store::max_block_write_batch_num () const
|
||||
unsigned nano::rocksdb::store::max_block_write_batch_num () const
|
||||
{
|
||||
return max_block_write_batch_num_m;
|
||||
}
|
||||
|
||||
std::string nano::rocksdb_store::error_string (int status) const
|
||||
std::string nano::rocksdb::store::error_string (int status) const
|
||||
{
|
||||
return std::to_string (status);
|
||||
}
|
||||
|
||||
nano::rocksdb_store::tombstone_info::tombstone_info (uint64_t num_since_last_flush_a, uint64_t const max_a) :
|
||||
nano::rocksdb::store::tombstone_info::tombstone_info (uint64_t num_since_last_flush_a, uint64_t const max_a) :
|
||||
num_since_last_flush (num_since_last_flush_a),
|
||||
max (max_a)
|
||||
{
|
||||
}
|
||||
|
||||
// Explicitly instantiate
|
||||
template class nano::store_partial<rocksdb::Slice, nano::rocksdb_store>;
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#include <nano/node/rocksdb/unchecked_store.hpp>
|
||||
#include <nano/node/rocksdb/version_store.hpp>
|
||||
#include <nano/secure/common.hpp>
|
||||
#include <nano/secure/store_partial.hpp>
|
||||
|
||||
#include <rocksdb/db.h>
|
||||
#include <rocksdb/filter_policy.h>
|
||||
|
@ -30,137 +29,145 @@ namespace nano
|
|||
{
|
||||
class logging_mt;
|
||||
class rocksdb_config;
|
||||
class rocksdb_store;
|
||||
class rocksdb_block_store_tombstone_count_Test;
|
||||
|
||||
/**
|
||||
namespace rocksdb
|
||||
{
|
||||
/**
|
||||
* rocksdb implementation of the block store
|
||||
*/
|
||||
class rocksdb_store : public store_partial<::rocksdb::Slice, rocksdb_store>
|
||||
{
|
||||
private:
|
||||
nano::rocksdb::account_store account_store;
|
||||
nano::rocksdb::block_store block_store;
|
||||
nano::rocksdb::confirmation_height_store confirmation_height_store;
|
||||
nano::rocksdb::final_vote_store final_vote_store;
|
||||
nano::rocksdb::frontier_store frontier_store;
|
||||
nano::rocksdb::online_weight_store online_weight_store;
|
||||
nano::rocksdb::peer_store peer_store;
|
||||
nano::rocksdb::pending_store pending_store;
|
||||
nano::rocksdb::pruned_store pruned_store;
|
||||
nano::rocksdb::unchecked_store unchecked_store;
|
||||
nano::rocksdb::version_store version_store;
|
||||
|
||||
public:
|
||||
friend class nano::rocksdb::account_store;
|
||||
friend class nano::rocksdb::block_store;
|
||||
friend class nano::rocksdb::confirmation_height_store;
|
||||
friend class nano::rocksdb::final_vote_store;
|
||||
friend class nano::rocksdb::frontier_store;
|
||||
friend class nano::rocksdb::online_weight_store;
|
||||
friend class nano::rocksdb::peer_store;
|
||||
friend class nano::rocksdb::pending_store;
|
||||
friend class nano::rocksdb::pruned_store;
|
||||
friend class nano::rocksdb::unchecked_store;
|
||||
friend class nano::rocksdb::version_store;
|
||||
|
||||
explicit rocksdb_store (nano::logger_mt &, boost::filesystem::path const &, nano::ledger_constants & constants, nano::rocksdb_config const & = nano::rocksdb_config{}, bool open_read_only = false);
|
||||
|
||||
nano::write_transaction tx_begin_write (std::vector<nano::tables> const & tables_requiring_lock = {}, std::vector<nano::tables> const & tables_no_lock = {}) override;
|
||||
nano::read_transaction tx_begin_read () const override;
|
||||
|
||||
std::string vendor_get () const override;
|
||||
|
||||
uint64_t count (nano::transaction const & transaction_a, tables table_a) const override;
|
||||
|
||||
bool exists (nano::transaction const & transaction_a, tables table_a, nano::rocksdb_val const & key_a) const;
|
||||
int get (nano::transaction const & transaction_a, tables table_a, nano::rocksdb_val const & key_a, nano::rocksdb_val & value_a) const;
|
||||
int put (nano::write_transaction const & transaction_a, tables table_a, nano::rocksdb_val const & key_a, nano::rocksdb_val const & value_a);
|
||||
int del (nano::write_transaction const & transaction_a, tables table_a, nano::rocksdb_val const & key_a);
|
||||
|
||||
void serialize_memory_stats (boost::property_tree::ptree &) override;
|
||||
|
||||
bool copy_db (boost::filesystem::path const & destination) override;
|
||||
void rebuild_db (nano::write_transaction const & transaction_a) override;
|
||||
|
||||
unsigned max_block_write_batch_num () const override;
|
||||
|
||||
template <typename Key, typename Value>
|
||||
nano::store_iterator<Key, Value> make_iterator (nano::transaction const & transaction_a, tables table_a, bool const direction_asc = true) const
|
||||
class store : public nano::store
|
||||
{
|
||||
return nano::store_iterator<Key, Value> (std::make_unique<nano::rocksdb_iterator<Key, Value>> (db.get (), transaction_a, table_to_column_family (table_a), nullptr, direction_asc));
|
||||
}
|
||||
private:
|
||||
nano::rocksdb::account_store account_store;
|
||||
nano::rocksdb::block_store block_store;
|
||||
nano::rocksdb::confirmation_height_store confirmation_height_store;
|
||||
nano::rocksdb::final_vote_store final_vote_store;
|
||||
nano::rocksdb::frontier_store frontier_store;
|
||||
nano::rocksdb::online_weight_store online_weight_store;
|
||||
nano::rocksdb::peer_store peer_store;
|
||||
nano::rocksdb::pending_store pending_store;
|
||||
nano::rocksdb::pruned_store pruned_store;
|
||||
nano::rocksdb::unchecked_store unchecked_store;
|
||||
nano::rocksdb::version_store version_store;
|
||||
|
||||
template <typename Key, typename Value>
|
||||
nano::store_iterator<Key, Value> make_iterator (nano::transaction const & transaction_a, tables table_a, nano::rocksdb_val const & key) const
|
||||
{
|
||||
return nano::store_iterator<Key, Value> (std::make_unique<nano::rocksdb_iterator<Key, Value>> (db.get (), transaction_a, table_to_column_family (table_a), &key, true));
|
||||
}
|
||||
|
||||
bool init_error () const override;
|
||||
|
||||
std::string error_string (int status) const override;
|
||||
|
||||
private:
|
||||
bool error{ false };
|
||||
nano::logger_mt & logger;
|
||||
nano::ledger_constants & constants;
|
||||
// Optimistic transactions are used in write mode
|
||||
::rocksdb::OptimisticTransactionDB * optimistic_db = nullptr;
|
||||
std::unique_ptr<::rocksdb::DB> db;
|
||||
std::vector<std::unique_ptr<::rocksdb::ColumnFamilyHandle>> handles;
|
||||
std::shared_ptr<::rocksdb::TableFactory> small_table_factory;
|
||||
std::unordered_map<nano::tables, nano::mutex> write_lock_mutexes;
|
||||
nano::rocksdb_config rocksdb_config;
|
||||
unsigned const max_block_write_batch_num_m;
|
||||
|
||||
class tombstone_info
|
||||
{
|
||||
public:
|
||||
tombstone_info (uint64_t, uint64_t const);
|
||||
std::atomic<uint64_t> num_since_last_flush;
|
||||
uint64_t const max;
|
||||
friend class nano::rocksdb::account_store;
|
||||
friend class nano::rocksdb::block_store;
|
||||
friend class nano::rocksdb::confirmation_height_store;
|
||||
friend class nano::rocksdb::final_vote_store;
|
||||
friend class nano::rocksdb::frontier_store;
|
||||
friend class nano::rocksdb::online_weight_store;
|
||||
friend class nano::rocksdb::peer_store;
|
||||
friend class nano::rocksdb::pending_store;
|
||||
friend class nano::rocksdb::pruned_store;
|
||||
friend class nano::rocksdb::unchecked_store;
|
||||
friend class nano::rocksdb::version_store;
|
||||
|
||||
explicit store (nano::logger_mt &, boost::filesystem::path const &, nano::ledger_constants & constants, nano::rocksdb_config const & = nano::rocksdb_config{}, bool open_read_only = false);
|
||||
|
||||
nano::write_transaction tx_begin_write (std::vector<nano::tables> const & tables_requiring_lock = {}, std::vector<nano::tables> const & tables_no_lock = {}) override;
|
||||
nano::read_transaction tx_begin_read () const override;
|
||||
|
||||
std::string vendor_get () const override;
|
||||
|
||||
uint64_t count (nano::transaction const & transaction_a, tables table_a) const override;
|
||||
|
||||
bool exists (nano::transaction const & transaction_a, tables table_a, nano::rocksdb_val const & key_a) const;
|
||||
int get (nano::transaction const & transaction_a, tables table_a, nano::rocksdb_val const & key_a, nano::rocksdb_val & value_a) const;
|
||||
int put (nano::write_transaction const & transaction_a, tables table_a, nano::rocksdb_val const & key_a, nano::rocksdb_val const & value_a);
|
||||
int del (nano::write_transaction const & transaction_a, tables table_a, nano::rocksdb_val const & key_a);
|
||||
|
||||
void serialize_memory_stats (boost::property_tree::ptree &) override;
|
||||
|
||||
bool copy_db (boost::filesystem::path const & destination) override;
|
||||
void rebuild_db (nano::write_transaction const & transaction_a) override;
|
||||
|
||||
unsigned max_block_write_batch_num () const override;
|
||||
|
||||
template <typename Key, typename Value>
|
||||
nano::store_iterator<Key, Value> make_iterator (nano::transaction const & transaction_a, tables table_a, bool const direction_asc = true) const
|
||||
{
|
||||
return nano::store_iterator<Key, Value> (std::make_unique<nano::rocksdb_iterator<Key, Value>> (db.get (), transaction_a, table_to_column_family (table_a), nullptr, direction_asc));
|
||||
}
|
||||
|
||||
template <typename Key, typename Value>
|
||||
nano::store_iterator<Key, Value> make_iterator (nano::transaction const & transaction_a, tables table_a, nano::rocksdb_val const & key) const
|
||||
{
|
||||
return nano::store_iterator<Key, Value> (std::make_unique<nano::rocksdb_iterator<Key, Value>> (db.get (), transaction_a, table_to_column_family (table_a), &key, true));
|
||||
}
|
||||
|
||||
bool init_error () const override;
|
||||
|
||||
std::string error_string (int status) const override;
|
||||
|
||||
private:
|
||||
bool error{ false };
|
||||
nano::logger_mt & logger;
|
||||
nano::ledger_constants & constants;
|
||||
// Optimistic transactions are used in write mode
|
||||
::rocksdb::OptimisticTransactionDB * optimistic_db = nullptr;
|
||||
std::unique_ptr<::rocksdb::DB> db;
|
||||
std::vector<std::unique_ptr<::rocksdb::ColumnFamilyHandle>> handles;
|
||||
std::shared_ptr<::rocksdb::TableFactory> small_table_factory;
|
||||
std::unordered_map<nano::tables, nano::mutex> write_lock_mutexes;
|
||||
nano::rocksdb_config rocksdb_config;
|
||||
unsigned const max_block_write_batch_num_m;
|
||||
|
||||
class tombstone_info
|
||||
{
|
||||
public:
|
||||
tombstone_info (uint64_t, uint64_t const);
|
||||
std::atomic<uint64_t> num_since_last_flush;
|
||||
uint64_t const max;
|
||||
};
|
||||
|
||||
std::unordered_map<nano::tables, tombstone_info> tombstone_map;
|
||||
std::unordered_map<char const *, nano::tables> cf_name_table_map;
|
||||
|
||||
::rocksdb::Transaction * tx (nano::transaction const & transaction_a) const;
|
||||
std::vector<nano::tables> all_tables () const;
|
||||
|
||||
bool not_found (int status) const override;
|
||||
bool success (int status) const override;
|
||||
void release_assert_success (int const status) const
|
||||
{
|
||||
if (!success (status))
|
||||
{
|
||||
release_assert (false, error_string (status));
|
||||
}
|
||||
}
|
||||
int status_code_not_found () const override;
|
||||
int drop (nano::write_transaction const &, tables) override;
|
||||
|
||||
::rocksdb::ColumnFamilyHandle * table_to_column_family (tables table_a) const;
|
||||
int clear (::rocksdb::ColumnFamilyHandle * column_family);
|
||||
|
||||
void open (bool & error_a, boost::filesystem::path const & path_a, bool open_read_only_a);
|
||||
|
||||
void construct_column_family_mutexes ();
|
||||
::rocksdb::Options get_db_options ();
|
||||
::rocksdb::ColumnFamilyOptions get_common_cf_options (std::shared_ptr<::rocksdb::TableFactory> const & table_factory_a, unsigned long long memtable_size_bytes_a) const;
|
||||
::rocksdb::ColumnFamilyOptions get_active_cf_options (std::shared_ptr<::rocksdb::TableFactory> const & table_factory_a, unsigned long long memtable_size_bytes_a) const;
|
||||
::rocksdb::ColumnFamilyOptions get_small_cf_options (std::shared_ptr<::rocksdb::TableFactory> const & table_factory_a) const;
|
||||
::rocksdb::BlockBasedTableOptions get_active_table_options (std::size_t lru_size) const;
|
||||
::rocksdb::BlockBasedTableOptions get_small_table_options () const;
|
||||
::rocksdb::ColumnFamilyOptions get_cf_options (std::string const & cf_name_a) const;
|
||||
|
||||
void on_flush (::rocksdb::FlushJobInfo const &);
|
||||
void flush_table (nano::tables table_a);
|
||||
void flush_tombstones_check (nano::tables table_a);
|
||||
void generate_tombstone_map ();
|
||||
std::unordered_map<char const *, nano::tables> create_cf_name_table_map () const;
|
||||
|
||||
std::vector<::rocksdb::ColumnFamilyDescriptor> create_column_families ();
|
||||
unsigned long long base_memtable_size_bytes () const;
|
||||
unsigned long long blocks_memtable_size_bytes () const;
|
||||
|
||||
constexpr static int base_memtable_size = 16;
|
||||
constexpr static int base_block_cache_size = 8;
|
||||
|
||||
friend class nano::rocksdb_block_store_tombstone_count_Test;
|
||||
};
|
||||
|
||||
std::unordered_map<nano::tables, tombstone_info> tombstone_map;
|
||||
std::unordered_map<char const *, nano::tables> cf_name_table_map;
|
||||
|
||||
::rocksdb::Transaction * tx (nano::transaction const & transaction_a) const;
|
||||
std::vector<nano::tables> all_tables () const;
|
||||
|
||||
bool not_found (int status) const override;
|
||||
bool success (int status) const override;
|
||||
int status_code_not_found () const override;
|
||||
int drop (nano::write_transaction const &, tables) override;
|
||||
|
||||
::rocksdb::ColumnFamilyHandle * table_to_column_family (tables table_a) const;
|
||||
int clear (::rocksdb::ColumnFamilyHandle * column_family);
|
||||
|
||||
void open (bool & error_a, boost::filesystem::path const & path_a, bool open_read_only_a);
|
||||
|
||||
void construct_column_family_mutexes ();
|
||||
::rocksdb::Options get_db_options ();
|
||||
::rocksdb::ColumnFamilyOptions get_common_cf_options (std::shared_ptr<::rocksdb::TableFactory> const & table_factory_a, unsigned long long memtable_size_bytes_a) const;
|
||||
::rocksdb::ColumnFamilyOptions get_active_cf_options (std::shared_ptr<::rocksdb::TableFactory> const & table_factory_a, unsigned long long memtable_size_bytes_a) const;
|
||||
::rocksdb::ColumnFamilyOptions get_small_cf_options (std::shared_ptr<::rocksdb::TableFactory> const & table_factory_a) const;
|
||||
::rocksdb::BlockBasedTableOptions get_active_table_options (std::size_t lru_size) const;
|
||||
::rocksdb::BlockBasedTableOptions get_small_table_options () const;
|
||||
::rocksdb::ColumnFamilyOptions get_cf_options (std::string const & cf_name_a) const;
|
||||
|
||||
void on_flush (::rocksdb::FlushJobInfo const &);
|
||||
void flush_table (nano::tables table_a);
|
||||
void flush_tombstones_check (nano::tables table_a);
|
||||
void generate_tombstone_map ();
|
||||
std::unordered_map<char const *, nano::tables> create_cf_name_table_map () const;
|
||||
|
||||
std::vector<::rocksdb::ColumnFamilyDescriptor> create_column_families ();
|
||||
unsigned long long base_memtable_size_bytes () const;
|
||||
unsigned long long blocks_memtable_size_bytes () const;
|
||||
|
||||
constexpr static int base_memtable_size = 16;
|
||||
constexpr static int base_block_cache_size = 8;
|
||||
|
||||
friend class rocksdb_block_store_tombstone_count_Test;
|
||||
};
|
||||
|
||||
extern template class store_partial<::rocksdb::Slice, rocksdb_store>;
|
||||
}
|
||||
} // namespace rocksdb
|
||||
} // namespace nano
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
#include <nano/node/lmdb/unchecked_store.hpp>
|
||||
#include <nano/node/rocksdb/rocksdb.hpp>
|
||||
#include <nano/secure/parallel_traversal.hpp>
|
||||
|
||||
nano::rocksdb::unchecked_store::unchecked_store (nano::rocksdb_store & store_a) :
|
||||
nano::rocksdb::unchecked_store::unchecked_store (nano::rocksdb::store & store_a) :
|
||||
store (store_a){};
|
||||
|
||||
void nano::rocksdb::unchecked_store::clear (nano::write_transaction const & transaction_a)
|
||||
{
|
||||
auto status = store.drop (transaction_a, tables::unchecked);
|
||||
release_assert_success (store, status);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
||||
void nano::rocksdb::unchecked_store::put (nano::write_transaction const & transaction_a, nano::hash_or_account const & dependency, nano::unchecked_info const & info)
|
||||
{
|
||||
auto status = store.put (transaction_a, tables::unchecked, nano::unchecked_key{ dependency, info.block->hash () }, info);
|
||||
release_assert_success (store, status);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
||||
bool nano::rocksdb::unchecked_store::exists (nano::transaction const & transaction_a, nano::unchecked_key const & key)
|
||||
|
@ -27,7 +28,7 @@ bool nano::rocksdb::unchecked_store::exists (nano::transaction const & transacti
|
|||
void nano::rocksdb::unchecked_store::del (nano::write_transaction const & transaction_a, nano::unchecked_key const & key_a)
|
||||
{
|
||||
auto status (store.del (transaction_a, tables::unchecked, key_a));
|
||||
release_assert_success (store, status);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
||||
nano::store_iterator<nano::unchecked_key, nano::unchecked_info> nano::rocksdb::unchecked_store::end () const
|
||||
|
|
|
@ -4,16 +4,16 @@
|
|||
|
||||
namespace nano
|
||||
{
|
||||
class mdb_store;
|
||||
namespace rocksdb
|
||||
{
|
||||
class store;
|
||||
class unchecked_store : public nano::unchecked_store
|
||||
{
|
||||
private:
|
||||
nano::rocksdb_store & store;
|
||||
nano::rocksdb::store & store;
|
||||
|
||||
public:
|
||||
unchecked_store (nano::rocksdb_store & store_a);
|
||||
unchecked_store (nano::rocksdb::store & store_a);
|
||||
|
||||
void clear (nano::write_transaction const & transaction_a) override;
|
||||
void put (nano::write_transaction const & transaction_a, nano::hash_or_account const & dependency, nano::unchecked_info const & info_a) override;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include <nano/node/rocksdb/rocksdb.hpp>
|
||||
#include <nano/node/rocksdb/version_store.hpp>
|
||||
|
||||
nano::rocksdb::version_store::version_store (nano::rocksdb_store & store_a) :
|
||||
nano::rocksdb::version_store::version_store (nano::rocksdb::store & store_a) :
|
||||
store{ store_a } {};
|
||||
|
||||
void nano::rocksdb::version_store::put (nano::write_transaction const & transaction_a, int version)
|
||||
|
@ -9,7 +9,7 @@ void nano::rocksdb::version_store::put (nano::write_transaction const & transact
|
|||
nano::uint256_union version_key{ 1 };
|
||||
nano::uint256_union version_value (version);
|
||||
auto status = store.put (transaction_a, tables::meta, version_key, version_value);
|
||||
release_assert_success (store, status);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
||||
int nano::rocksdb::version_store::get (nano::transaction const & transaction_a) const
|
||||
|
@ -17,7 +17,7 @@ int nano::rocksdb::version_store::get (nano::transaction const & transaction_a)
|
|||
nano::uint256_union version_key{ 1 };
|
||||
nano::rocksdb_val data;
|
||||
auto status = store.get (transaction_a, tables::meta, version_key, data);
|
||||
int result = store.minimum_version;
|
||||
int result = store.version_minimum;
|
||||
if (store.success (status))
|
||||
{
|
||||
nano::uint256_union version_value{ data };
|
||||
|
|
|
@ -4,16 +4,16 @@
|
|||
|
||||
namespace nano
|
||||
{
|
||||
class rocksdb_store;
|
||||
namespace rocksdb
|
||||
{
|
||||
class store;
|
||||
class version_store : public nano::version_store
|
||||
{
|
||||
protected:
|
||||
nano::rocksdb_store & store;
|
||||
nano::rocksdb::store & store;
|
||||
|
||||
public:
|
||||
explicit version_store (nano::rocksdb_store & store_a);
|
||||
explicit version_store (nano::rocksdb::store & store_a);
|
||||
void put (nano::write_transaction const & transaction_a, int version_a) override;
|
||||
int get (nano::transaction const & transaction_a) const override;
|
||||
};
|
||||
|
|
|
@ -1390,7 +1390,7 @@ nano::wallets::wallets (bool error_a, nano::node & node_a) :
|
|||
char const * store_path;
|
||||
mdb_env_get_path (env, &store_path);
|
||||
boost::filesystem::path const path (store_path);
|
||||
nano::mdb_store::create_backup_file (env, path, node_a.logger);
|
||||
nano::lmdb::store::create_backup_file (env, path, node_a.logger);
|
||||
}
|
||||
for (auto & item : items)
|
||||
{
|
||||
|
@ -1700,7 +1700,7 @@ void nano::wallets::ongoing_compute_reps ()
|
|||
|
||||
void nano::wallets::split_if_needed (nano::transaction & transaction_destination, nano::store & store_a)
|
||||
{
|
||||
auto store_l (dynamic_cast<nano::mdb_store *> (&store_a));
|
||||
auto store_l = dynamic_cast<nano::lmdb::store *> (&store_a);
|
||||
if (store_l != nullptr)
|
||||
{
|
||||
if (items.empty ())
|
||||
|
|
|
@ -521,7 +521,7 @@ TEST (history, short_text)
|
|||
nano::ledger ledger (*store, system.nodes[0]->stats, nano::dev::constants);
|
||||
{
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::keypair key;
|
||||
auto latest (ledger.latest (transaction, nano::dev::genesis_key.pub));
|
||||
nano::send_block send (latest, nano::dev::genesis_key.pub, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (latest));
|
||||
|
@ -561,7 +561,7 @@ TEST (history, pruned_source)
|
|||
// Basic pruning for legacy blocks. Previous block is pruned, source is pruned
|
||||
{
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, nano::dev::constants);
|
||||
auto latest (ledger.latest (transaction, nano::dev::genesis_key.pub));
|
||||
nano::send_block send1 (latest, nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - 100, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (latest));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code);
|
||||
|
|
|
@ -41,7 +41,6 @@ add_library(
|
|||
${CMAKE_BINARY_DIR}/bootstrap_weights_beta.cpp
|
||||
store.hpp
|
||||
store.cpp
|
||||
store_partial.hpp
|
||||
buffer.hpp
|
||||
common.hpp
|
||||
common.cpp
|
||||
|
|
|
@ -901,6 +901,11 @@ bool nano::ledger::block_or_pruned_exists (nano::transaction const & transaction
|
|||
return store.block.exists (transaction_a, hash_a);
|
||||
}
|
||||
|
||||
bool nano::ledger::root_exists (nano::transaction const & transaction_a, nano::root const & root_a)
|
||||
{
|
||||
return store.block.exists (transaction_a, root_a.as_block_hash ()) || store.account.exists (transaction_a, root_a.as_account ());
|
||||
}
|
||||
|
||||
std::string nano::ledger::block_text (char const * hash_a)
|
||||
{
|
||||
return block_text (nano::block_hash (hash_a));
|
||||
|
|
|
@ -48,6 +48,7 @@ public:
|
|||
nano::block_hash representative_calculated (nano::transaction const &, nano::block_hash const &);
|
||||
bool block_or_pruned_exists (nano::block_hash const &) const;
|
||||
bool block_or_pruned_exists (nano::transaction const &, nano::block_hash const &) const;
|
||||
bool root_exists (nano::transaction const &, nano::root const &);
|
||||
std::string block_text (char const *);
|
||||
std::string block_text (nano::block_hash const &);
|
||||
bool is_send (nano::transaction const &, nano::state_block const &) const;
|
||||
|
|
32
nano/secure/parallel_traversal.hpp
Normal file
32
nano/secure/parallel_traversal.hpp
Normal file
|
@ -0,0 +1,32 @@
|
|||
#pragma once
|
||||
|
||||
#include <nano/lib/threading.hpp>
|
||||
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
template <typename T>
|
||||
void parallel_traversal (std::function<void (T const &, T const &, bool const)> const & action)
|
||||
{
|
||||
// Between 10 and 40 threads, scales well even in low power systems as long as actions are I/O bound
|
||||
unsigned const thread_count = std::max (10u, std::min (40u, 10 * std::thread::hardware_concurrency ()));
|
||||
T const value_max{ std::numeric_limits<T>::max () };
|
||||
T const split = value_max / thread_count;
|
||||
std::vector<std::thread> threads;
|
||||
threads.reserve (thread_count);
|
||||
for (unsigned thread (0); thread < thread_count; ++thread)
|
||||
{
|
||||
T const start = thread * split;
|
||||
T const end = (thread + 1) * split;
|
||||
bool const is_last = thread == thread_count - 1;
|
||||
|
||||
threads.emplace_back ([&action, start, end, is_last] {
|
||||
nano::thread_role::set (nano::thread_role::name::db_parallel_traversal);
|
||||
action (start, end, is_last);
|
||||
});
|
||||
}
|
||||
for (auto & thread : threads)
|
||||
{
|
||||
thread.join ();
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
#include <nano/lib/threading.hpp>
|
||||
#include <nano/lib/timer.hpp>
|
||||
#include <nano/secure/store.hpp>
|
||||
|
||||
nano::representative_visitor::representative_visitor (nano::transaction const & transaction_a, nano::store & store_a) :
|
||||
|
@ -134,6 +135,26 @@ nano::store::store (
|
|||
}
|
||||
// clang-format on
|
||||
|
||||
/**
|
||||
* 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 nano::store::initialize (nano::write_transaction const & transaction_a, nano::ledger_cache & ledger_cache_a, nano::ledger_constants & constants)
|
||||
{
|
||||
debug_assert (constants.genesis->has_sideband ());
|
||||
debug_assert (account.begin (transaction_a) == account.end ());
|
||||
auto hash_l (constants.genesis->hash ());
|
||||
block.put (transaction_a, hash_l, *constants.genesis);
|
||||
++ledger_cache_a.block_count;
|
||||
confirmation_height.put (transaction_a, constants.genesis->account (), nano::confirmation_height_info{ 1, constants.genesis->hash () });
|
||||
++ledger_cache_a.cemented_count;
|
||||
ledger_cache_a.final_votes_confirmation_canary = (constants.final_votes_canary_account == constants.genesis->account () && 1 >= constants.final_votes_canary_height);
|
||||
account.put (transaction_a, constants.genesis->account (), { hash_l, constants.genesis->account (), constants.genesis->hash (), std::numeric_limits<nano::uint128_t>::max (), nano::seconds_since_epoch (), 1, nano::epoch::epoch_0 });
|
||||
++ledger_cache_a.account_count;
|
||||
ledger_cache_a.rep_weights.representation_put (constants.genesis->account (), std::numeric_limits<nano::uint128_t>::max ());
|
||||
frontier.put (transaction_a, hash_l, constants.genesis->account ());
|
||||
}
|
||||
|
||||
auto nano::unchecked_store::equal_range (nano::transaction const & transaction, nano::block_hash const & dependency) -> std::pair<iterator, iterator>
|
||||
{
|
||||
nano::unchecked_key begin_l{ dependency, 0 };
|
||||
|
|
|
@ -845,13 +845,20 @@ public:
|
|||
);
|
||||
// clang-format on
|
||||
virtual ~store () = default;
|
||||
virtual void initialize (nano::write_transaction const &, nano::ledger_cache &) = 0;
|
||||
virtual bool root_exists (nano::transaction const &, nano::root const &) = 0;
|
||||
void initialize (nano::write_transaction const & transaction_a, nano::ledger_cache & ledger_cache_a, nano::ledger_constants & constants);
|
||||
virtual uint64_t count (nano::transaction const & transaction_a, tables table_a) const = 0;
|
||||
virtual int drop (nano::write_transaction const & transaction_a, tables table_a) = 0;
|
||||
virtual bool not_found (int status) const = 0;
|
||||
virtual bool success (int status) const = 0;
|
||||
virtual int status_code_not_found () const = 0;
|
||||
virtual std::string error_string (int status) const = 0;
|
||||
|
||||
block_store & block;
|
||||
frontier_store & frontier;
|
||||
account_store & account;
|
||||
pending_store & pending;
|
||||
static int constexpr version_minimum{ 14 };
|
||||
static int constexpr version_current{ 21 };
|
||||
|
||||
private:
|
||||
unchecked_store & unchecked;
|
||||
|
|
|
@ -1,191 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <nano/lib/config.hpp>
|
||||
#include <nano/lib/rep_weights.hpp>
|
||||
#include <nano/lib/threading.hpp>
|
||||
#include <nano/lib/timer.hpp>
|
||||
#include <nano/secure/buffer.hpp>
|
||||
#include <nano/secure/store.hpp>
|
||||
|
||||
#include <crypto/cryptopp/words.h>
|
||||
|
||||
#include <thread>
|
||||
|
||||
class store_partial;
|
||||
namespace
|
||||
{
|
||||
template <typename T>
|
||||
void parallel_traversal (std::function<void (T const &, T const &, bool const)> const & action);
|
||||
}
|
||||
|
||||
namespace nano
|
||||
{
|
||||
template <typename Val, typename Derived_Store>
|
||||
class store_partial;
|
||||
|
||||
template <typename Val, typename Derived_Store>
|
||||
void release_assert_success (store_partial<Val, Derived_Store> const & store, int const status);
|
||||
|
||||
/** This base class implements the store interface functions which have DB agnostic functionality. It also maps all the store classes. */
|
||||
template <typename Val, typename Derived_Store>
|
||||
class store_partial : public store
|
||||
{
|
||||
friend void release_assert_success<Val, Derived_Store> (store_partial<Val, Derived_Store> const &, int const);
|
||||
|
||||
public:
|
||||
// clang-format off
|
||||
store_partial (
|
||||
nano::ledger_constants & constants,
|
||||
nano::block_store & block_store_a,
|
||||
nano::frontier_store & frontier_store_a,
|
||||
nano::account_store & account_store_a,
|
||||
nano::pending_store & pending_store_a,
|
||||
nano::unchecked_store & unchecked_store_a,
|
||||
nano::online_weight_store & online_weight_store_a,
|
||||
nano::pruned_store & pruned_store_a,
|
||||
nano::peer_store & peer_store_a,
|
||||
nano::confirmation_height_store & confirmation_height_store_a,
|
||||
nano::final_vote_store & final_vote_store_a,
|
||||
nano::version_store & version_store_a) :
|
||||
constants{ constants },
|
||||
store{
|
||||
block_store_a,
|
||||
frontier_store_a,
|
||||
account_store_a,
|
||||
pending_store_a,
|
||||
unchecked_store_a,
|
||||
online_weight_store_a,
|
||||
pruned_store_a,
|
||||
peer_store_a,
|
||||
confirmation_height_store_a,
|
||||
final_vote_store_a,
|
||||
version_store_a
|
||||
}
|
||||
{}
|
||||
// clang-format on
|
||||
|
||||
/**
|
||||
* 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::ledger_cache & ledger_cache_a) override
|
||||
{
|
||||
debug_assert (constants.genesis->has_sideband ());
|
||||
debug_assert (account.begin (transaction_a) == account.end ());
|
||||
auto hash_l (constants.genesis->hash ());
|
||||
block.put (transaction_a, hash_l, *constants.genesis);
|
||||
++ledger_cache_a.block_count;
|
||||
confirmation_height.put (transaction_a, constants.genesis->account (), nano::confirmation_height_info{ 1, constants.genesis->hash () });
|
||||
++ledger_cache_a.cemented_count;
|
||||
ledger_cache_a.final_votes_confirmation_canary = (constants.final_votes_canary_account == constants.genesis->account () && 1 >= constants.final_votes_canary_height);
|
||||
account.put (transaction_a, constants.genesis->account (), { hash_l, constants.genesis->account (), constants.genesis->hash (), std::numeric_limits<nano::uint128_t>::max (), nano::seconds_since_epoch (), 1, nano::epoch::epoch_0 });
|
||||
++ledger_cache_a.account_count;
|
||||
ledger_cache_a.rep_weights.representation_put (constants.genesis->account (), std::numeric_limits<nano::uint128_t>::max ());
|
||||
frontier.put (transaction_a, hash_l, constants.genesis->account ());
|
||||
}
|
||||
|
||||
bool root_exists (nano::transaction const & transaction_a, nano::root const & root_a) override
|
||||
{
|
||||
return block.exists (transaction_a, root_a.as_block_hash ()) || account.exists (transaction_a, root_a.as_account ());
|
||||
}
|
||||
|
||||
bool exists (nano::transaction const & transaction_a, tables table_a, nano::db_val<Val> const & key_a) const
|
||||
{
|
||||
return static_cast<const Derived_Store &> (*this).exists (transaction_a, table_a, key_a);
|
||||
}
|
||||
|
||||
template <typename Key, typename Value>
|
||||
nano::store_iterator<Key, Value> make_iterator (nano::transaction const & transaction_a, tables table_a, bool const direction_asc = true) const
|
||||
{
|
||||
return static_cast<Derived_Store const &> (*this).template make_iterator<Key, Value> (transaction_a, table_a, direction_asc);
|
||||
}
|
||||
|
||||
template <typename Key, typename Value>
|
||||
nano::store_iterator<Key, Value> make_iterator (nano::transaction const & transaction_a, tables table_a, nano::db_val<Val> const & key) const
|
||||
{
|
||||
return static_cast<Derived_Store const &> (*this).template make_iterator<Key, Value> (transaction_a, table_a, key);
|
||||
}
|
||||
|
||||
int const minimum_version{ 14 };
|
||||
|
||||
protected:
|
||||
nano::ledger_constants & constants;
|
||||
int const version_number{ 21 };
|
||||
|
||||
uint64_t count (nano::transaction const & transaction_a, std::initializer_list<tables> dbs_a) const
|
||||
{
|
||||
uint64_t total_count = 0;
|
||||
for (auto db : dbs_a)
|
||||
{
|
||||
total_count += count (transaction_a, db);
|
||||
}
|
||||
return total_count;
|
||||
}
|
||||
|
||||
int get (nano::transaction const & transaction_a, tables table_a, nano::db_val<Val> const & key_a, nano::db_val<Val> & value_a) const
|
||||
{
|
||||
return static_cast<Derived_Store const &> (*this).get (transaction_a, table_a, key_a, value_a);
|
||||
}
|
||||
|
||||
int put (nano::write_transaction const & transaction_a, tables table_a, nano::db_val<Val> const & key_a, nano::db_val<Val> const & value_a)
|
||||
{
|
||||
return static_cast<Derived_Store &> (*this).put (transaction_a, table_a, key_a, value_a);
|
||||
}
|
||||
|
||||
// Put only key without value
|
||||
int put_key (nano::write_transaction const & transaction_a, tables table_a, nano::db_val<Val> const & key_a)
|
||||
{
|
||||
return this->put (transaction_a, table_a, key_a, nano::db_val<Val>{ nullptr });
|
||||
}
|
||||
|
||||
int del (nano::write_transaction const & transaction_a, tables table_a, nano::db_val<Val> const & key_a)
|
||||
{
|
||||
return static_cast<Derived_Store &> (*this).del (transaction_a, table_a, key_a);
|
||||
}
|
||||
|
||||
virtual uint64_t count (nano::transaction const & transaction_a, tables table_a) const = 0;
|
||||
virtual int drop (nano::write_transaction const & transaction_a, tables table_a) = 0;
|
||||
virtual bool not_found (int status) const = 0;
|
||||
virtual bool success (int status) const = 0;
|
||||
virtual int status_code_not_found () const = 0;
|
||||
virtual std::string error_string (int status) const = 0;
|
||||
};
|
||||
|
||||
template <typename Val, typename Derived_Store>
|
||||
void release_assert_success (store_partial<Val, Derived_Store> const & store, int const status)
|
||||
{
|
||||
if (!store.success (status))
|
||||
{
|
||||
release_assert (false, store.error_string (status));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
template <typename T>
|
||||
void parallel_traversal (std::function<void (T const &, T const &, bool const)> const & action)
|
||||
{
|
||||
// Between 10 and 40 threads, scales well even in low power systems as long as actions are I/O bound
|
||||
unsigned const thread_count = std::max (10u, std::min (40u, 10 * std::thread::hardware_concurrency ()));
|
||||
T const value_max{ std::numeric_limits<T>::max () };
|
||||
T const split = value_max / thread_count;
|
||||
std::vector<std::thread> threads;
|
||||
threads.reserve (thread_count);
|
||||
for (unsigned thread (0); thread < thread_count; ++thread)
|
||||
{
|
||||
T const start = thread * split;
|
||||
T const end = (thread + 1) * split;
|
||||
bool const is_last = thread == thread_count - 1;
|
||||
|
||||
threads.emplace_back ([&action, start, end, is_last] {
|
||||
nano::thread_role::set (nano::thread_role::name::db_parallel_traversal);
|
||||
action (start, end, is_last);
|
||||
});
|
||||
}
|
||||
for (auto & thread : threads)
|
||||
{
|
||||
thread.join ();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -119,7 +119,7 @@ TEST (ledger, deep_account_compute)
|
|||
nano::stat stats;
|
||||
nano::ledger ledger (*store, stats, nano::dev::constants);
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
nano::keypair key;
|
||||
auto balance (nano::dev::constants.genesis_amount - 1);
|
||||
|
@ -1049,7 +1049,7 @@ TEST (confirmation_height, many_accounts_send_receive_self_no_elections)
|
|||
|
||||
{
|
||||
auto transaction (store->tx_begin_write ());
|
||||
store->initialize (transaction, ledger.cache);
|
||||
store->initialize (transaction, ledger.cache, ledger.constants);
|
||||
|
||||
// Send from genesis account to all other accounts and create open block for them
|
||||
for (auto i = 0; i < num_accounts; ++i)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue