diff --git a/nano/core_test/active_elections.cpp b/nano/core_test/active_elections.cpp index 38c599df17..3b30dcf409 100644 --- a/nano/core_test/active_elections.cpp +++ b/nano/core_test/active_elections.cpp @@ -1408,7 +1408,7 @@ TEST (active_elections, bound_election_winners) { // Prevent cementing of confirmed blocks - auto guard = node.ledger.tx_begin_write ({}, nano::store::writer::testing); + auto guard = node.ledger.tx_begin_write (nano::store::writer::testing); // Ensure that when the number of election winners reaches the limit, AEC vacancy reflects that ASSERT_TRUE (node.active.vacancy (nano::election_behavior::priority) > 0); diff --git a/nano/core_test/ledger.cpp b/nano/core_test/ledger.cpp index 809ac7b6fc..83d87fe1d8 100644 --- a/nano/core_test/ledger.cpp +++ b/nano/core_test/ledger.cpp @@ -5819,21 +5819,21 @@ TEST (ledger_transaction, write_wait_order) std::latch latch3{ 1 }; auto fut1 = std::async (std::launch::async, [&] { - auto tx = ctx.ledger ().tx_begin_write ({}, nano::store::writer::generic); + auto tx = ctx.ledger ().tx_begin_write (nano::store::writer::generic); acquired1 = true; latch1.wait (); // Wait for the signal to drop tx }); WAIT (250ms); // Allow thread to start auto fut2 = std::async (std::launch::async, [&ctx, &acquired2, &latch2] { - auto tx = ctx.ledger ().tx_begin_write ({}, nano::store::writer::blockprocessor); + auto tx = ctx.ledger ().tx_begin_write (nano::store::writer::blockprocessor); acquired2 = true; latch2.wait (); // Wait for the signal to drop tx }); WAIT (250ms); // Allow thread to start auto fut3 = std::async (std::launch::async, [&ctx, &acquired3, &latch3] { - auto tx = ctx.ledger ().tx_begin_write ({}, nano::store::writer::confirmation_height); + auto tx = ctx.ledger ().tx_begin_write (nano::store::writer::confirmation_height); acquired3 = true; latch3.wait (); // Wait for the signal to drop tx }); @@ -5855,4 +5855,4 @@ TEST (ledger_transaction, write_wait_order) // Signal to continue and drop the third transaction latch3.count_down (); -} \ No newline at end of file +} diff --git a/nano/node/blockprocessor.cpp b/nano/node/blockprocessor.cpp index ba4c8a84fc..9bf2348b59 100644 --- a/nano/node/blockprocessor.cpp +++ b/nano/node/blockprocessor.cpp @@ -319,7 +319,7 @@ auto nano::block_processor::process_batch (nano::unique_lock & lock lock.unlock (); - auto transaction = node.ledger.tx_begin_write ({ tables::accounts, tables::blocks, tables::pending, tables::rep_weights }, nano::store::writer::blockprocessor); + auto transaction = node.ledger.tx_begin_write (nano::store::writer::blockprocessor); nano::timer timer; timer.start (); diff --git a/nano/node/confirming_set.cpp b/nano/node/confirming_set.cpp index 867aa80e1c..5459d0f4f7 100644 --- a/nano/node/confirming_set.cpp +++ b/nano/node/confirming_set.cpp @@ -162,7 +162,7 @@ void nano::confirming_set::run_batch (std::unique_lock & lock) }; { - auto transaction = ledger.tx_begin_write ({ nano::tables::confirmation_height }, nano::store::writer::confirmation_height); + auto transaction = ledger.tx_begin_write (nano::store::writer::confirmation_height); for (auto const & hash : batch) { do diff --git a/nano/node/node.cpp b/nano/node/node.cpp index 9a3b35e2cd..e60e21832a 100644 --- a/nano/node/node.cpp +++ b/nano/node/node.cpp @@ -323,7 +323,7 @@ nano::node::node (std::shared_ptr io_ctx_a, std::filesy if (!is_initialized && !flags.read_only) { - auto const transaction (store.tx_begin_write ({ tables::accounts, tables::blocks, tables::confirmation_height, tables::rep_weights })); + auto const transaction = store.tx_begin_write (); // Store was empty meaning we just created it, add the genesis block store.initialize (transaction, ledger.cache, ledger.constants); } @@ -572,7 +572,7 @@ void nano::node::process_active (std::shared_ptr const & incoming) nano::block_status nano::node::process (std::shared_ptr block) { - auto const transaction = ledger.tx_begin_write ({ tables::accounts, tables::blocks, tables::pending, tables::rep_weights }, nano::store::writer::node); + auto const transaction = ledger.tx_begin_write (nano::store::writer::node); return process (transaction, block); } @@ -787,7 +787,7 @@ nano::uint128_t nano::node::minimum_principal_weight () void nano::node::long_inactivity_cleanup () { bool perform_cleanup = false; - auto const transaction (store.tx_begin_write ({ tables::online_weight, tables::peers })); + auto const transaction = store.tx_begin_write (); if (store.online_weight.count (transaction) > 0) { auto sample (store.online_weight.rbegin (transaction)); @@ -994,7 +994,7 @@ void nano::node::ledger_pruning (uint64_t const batch_size_a, bool bootstrap_wei transaction_write_count = 0; if (!pruning_targets.empty () && !stopped) { - auto write_transaction = ledger.tx_begin_write ({ tables::blocks, tables::pruned }, nano::store::writer::pruning); + auto write_transaction = ledger.tx_begin_write (nano::store::writer::pruning); while (!pruning_targets.empty () && transaction_write_count < batch_size_a && !stopped) { auto const & pruning_hash (pruning_targets.front ()); @@ -1348,4 +1348,4 @@ nano::keypair nano::load_or_create_node_id (std::filesystem::path const & applic release_assert (!ofs.fail ()); return kp; } -} \ No newline at end of file +} diff --git a/nano/node/online_reps.cpp b/nano/node/online_reps.cpp index 3fdd2442dd..3b35b3c5c3 100644 --- a/nano/node/online_reps.cpp +++ b/nano/node/online_reps.cpp @@ -40,7 +40,7 @@ void nano::online_reps::sample () lock.unlock (); nano::uint128_t trend_l; { - auto transaction (ledger.store.tx_begin_write ({ tables::online_weight })); + auto transaction = ledger.store.tx_begin_write (); // Discard oldest entries while (ledger.store.online_weight.count (transaction) >= config.network_params.node.max_weight_samples) { diff --git a/nano/node/peer_history.cpp b/nano/node/peer_history.cpp index bf1fa099bb..1c605d9015 100644 --- a/nano/node/peer_history.cpp +++ b/nano/node/peer_history.cpp @@ -81,7 +81,7 @@ void nano::peer_history::run () void nano::peer_history::run_one () { auto live_peers = network.list (); - auto transaction = store.tx_begin_write ({ tables::peers }); + auto transaction = store.tx_begin_write (); // Add or update live peers for (auto const & peer : live_peers) diff --git a/nano/node/vote_generator.cpp b/nano/node/vote_generator.cpp index 4809e873ee..3bdbedee31 100644 --- a/nano/node/vote_generator.cpp +++ b/nano/node/vote_generator.cpp @@ -123,7 +123,7 @@ void nano::vote_generator::process_batch (std::deque & batch) if (is_final) { - transaction_variant_t transaction_variant{ ledger.tx_begin_write ({ tables::final_votes }, nano::store::writer::voting_final) }; + transaction_variant_t transaction_variant{ ledger.tx_begin_write (nano::store::writer::voting_final) }; verify_batch (transaction_variant, batch); diff --git a/nano/secure/ledger.cpp b/nano/secure/ledger.cpp index daf73eacb1..4396c798ce 100644 --- a/nano/secure/ledger.cpp +++ b/nano/secure/ledger.cpp @@ -732,10 +732,10 @@ nano::ledger::~ledger () { } -auto nano::ledger::tx_begin_write (std::vector const & tables_to_lock, nano::store::writer guard_type) const -> secure::write_transaction +auto nano::ledger::tx_begin_write (nano::store::writer guard_type) const -> secure::write_transaction { auto guard = store.write_queue.wait (guard_type); - auto txn = store.tx_begin_write (tables_to_lock); + auto txn = store.tx_begin_write (); return secure::write_transaction{ std::move (txn), std::move (guard) }; } @@ -1292,7 +1292,7 @@ bool nano::ledger::migrate_lmdb_to_rocksdb (std::filesystem::path const & data_p std::atomic count = 0; store.block.for_each_par ( [&] (store::read_transaction const & /*unused*/, auto i, auto n) { - auto rocksdb_transaction (rocksdb_store->tx_begin_write ({}, { nano::tables::blocks })); + auto rocksdb_transaction = rocksdb_store->tx_begin_write (); for (; i != n; ++i) { rocksdb_transaction.refresh_if_needed (); @@ -1317,7 +1317,7 @@ bool nano::ledger::migrate_lmdb_to_rocksdb (std::filesystem::path const & data_p count = 0; store.pending.for_each_par ( [&] (store::read_transaction const & /*unused*/, auto i, auto n) { - auto rocksdb_transaction (rocksdb_store->tx_begin_write ({}, { nano::tables::pending })); + auto rocksdb_transaction = rocksdb_store->tx_begin_write (); for (; i != n; ++i) { rocksdb_transaction.refresh_if_needed (); @@ -1335,7 +1335,7 @@ bool nano::ledger::migrate_lmdb_to_rocksdb (std::filesystem::path const & data_p count = 0; store.confirmation_height.for_each_par ( [&] (store::read_transaction const & /*unused*/, auto i, auto n) { - auto rocksdb_transaction (rocksdb_store->tx_begin_write ({}, { nano::tables::confirmation_height })); + auto rocksdb_transaction = rocksdb_store->tx_begin_write (); for (; i != n; ++i) { rocksdb_transaction.refresh_if_needed (); @@ -1353,7 +1353,7 @@ bool nano::ledger::migrate_lmdb_to_rocksdb (std::filesystem::path const & data_p count = 0; store.account.for_each_par ( [&] (store::read_transaction const & /*unused*/, auto i, auto n) { - auto rocksdb_transaction (rocksdb_store->tx_begin_write ({}, { nano::tables::accounts })); + auto rocksdb_transaction = rocksdb_store->tx_begin_write (); for (; i != n; ++i) { rocksdb_transaction.refresh_if_needed (); @@ -1371,7 +1371,7 @@ bool nano::ledger::migrate_lmdb_to_rocksdb (std::filesystem::path const & data_p count = 0; store.rep_weight.for_each_par ( [&] (store::read_transaction const & /*unused*/, auto i, auto n) { - auto rocksdb_transaction (rocksdb_store->tx_begin_write ({}, { nano::tables::rep_weights })); + auto rocksdb_transaction = rocksdb_store->tx_begin_write (); for (; i != n; ++i) { rocksdb_transaction.refresh_if_needed (); @@ -1389,7 +1389,7 @@ bool nano::ledger::migrate_lmdb_to_rocksdb (std::filesystem::path const & data_p count = 0; store.pruned.for_each_par ( [&] (store::read_transaction const & /*unused*/, auto i, auto n) { - auto rocksdb_transaction (rocksdb_store->tx_begin_write ({}, { nano::tables::pruned })); + auto rocksdb_transaction = rocksdb_store->tx_begin_write (); for (; i != n; ++i) { rocksdb_transaction.refresh_if_needed (); @@ -1407,7 +1407,7 @@ bool nano::ledger::migrate_lmdb_to_rocksdb (std::filesystem::path const & data_p count = 0; store.final_vote.for_each_par ( [&] (store::read_transaction const & /*unused*/, auto i, auto n) { - auto rocksdb_transaction (rocksdb_store->tx_begin_write ({}, { nano::tables::final_votes })); + auto rocksdb_transaction = rocksdb_store->tx_begin_write (); for (; i != n; ++i) { rocksdb_transaction.refresh_if_needed (); diff --git a/nano/secure/ledger.hpp b/nano/secure/ledger.hpp index 3419731e11..4e3f45d5fd 100644 --- a/nano/secure/ledger.hpp +++ b/nano/secure/ledger.hpp @@ -39,7 +39,7 @@ class ledger final ~ledger (); /** Start read-write transaction */ - secure::write_transaction tx_begin_write (std::vector const & tables_to_lock = {}, nano::store::writer guard_type = nano::store::writer::generic) const; + secure::write_transaction tx_begin_write (nano::store::writer guard_type = nano::store::writer::generic) const; /** Start read-only transaction */ secure::read_transaction tx_begin_read () const; diff --git a/nano/store/component.hpp b/nano/store/component.hpp index e85de20aa4..f36f837efe 100644 --- a/nano/store/component.hpp +++ b/nano/store/component.hpp @@ -96,7 +96,7 @@ namespace store virtual bool init_error () const = 0; /** Start read-write transaction */ - virtual write_transaction tx_begin_write (std::vector const & tables_to_lock = {}, std::vector const & tables_no_lock = {}) = 0; + virtual write_transaction tx_begin_write () = 0; /** Start read-only transaction */ virtual read_transaction tx_begin_read () const = 0; diff --git a/nano/store/lmdb/lmdb.cpp b/nano/store/lmdb/lmdb.cpp index b9bc04721a..a9d83eb483 100644 --- a/nano/store/lmdb/lmdb.cpp +++ b/nano/store/lmdb/lmdb.cpp @@ -162,7 +162,7 @@ void nano::store::lmdb::component::serialize_memory_stats (boost::property_tree: json.put ("page_size", stats.ms_psize); } -nano::store::write_transaction nano::store::lmdb::component::tx_begin_write (std::vector const &, std::vector const &) +nano::store::write_transaction nano::store::lmdb::component::tx_begin_write () { return env.tx_begin_write (create_txn_callbacks ()); } diff --git a/nano/store/lmdb/lmdb.hpp b/nano/store/lmdb/lmdb.hpp index 290b19f813..5920caa4b1 100644 --- a/nano/store/lmdb/lmdb.hpp +++ b/nano/store/lmdb/lmdb.hpp @@ -64,7 +64,7 @@ class component : public nano::store::component public: component (nano::logger &, std::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); - store::write_transaction tx_begin_write (std::vector const & tables_requiring_lock = {}, std::vector const & tables_no_lock = {}) override; + store::write_transaction tx_begin_write () override; store::read_transaction tx_begin_read () const override; std::string vendor_get () const override; diff --git a/nano/store/rocksdb/rocksdb.cpp b/nano/store/rocksdb/rocksdb.cpp index d17cbe28e9..391364fa8a 100644 --- a/nano/store/rocksdb/rocksdb.cpp +++ b/nano/store/rocksdb/rocksdb.cpp @@ -417,9 +417,9 @@ std::vector nano::store::rocksdb::component::cr return column_families; } -nano::store::write_transaction nano::store::rocksdb::component::tx_begin_write (std::vector const &, std::vector const &) +nano::store::write_transaction nano::store::rocksdb::component::tx_begin_write () { - release_assert (db != nullptr); + release_assert (transaction_db != nullptr); return store::write_transaction{ std::make_unique (transaction_db) }; } diff --git a/nano/store/rocksdb/rocksdb.hpp b/nano/store/rocksdb/rocksdb.hpp index 643a67a672..1d964b8ee1 100644 --- a/nano/store/rocksdb/rocksdb.hpp +++ b/nano/store/rocksdb/rocksdb.hpp @@ -66,7 +66,7 @@ class component : public nano::store::component explicit component (nano::logger &, std::filesystem::path const &, nano::ledger_constants & constants, nano::rocksdb_config const & = nano::rocksdb_config{}, bool open_read_only = false); - store::write_transaction tx_begin_write (std::vector const & tables_requiring_lock = {}, std::vector const & tables_no_lock = {}) override; + store::write_transaction tx_begin_write () override; store::read_transaction tx_begin_read () const override; std::string vendor_get () const override; diff --git a/nano/test_common/testutil.cpp b/nano/test_common/testutil.cpp index 59554846fa..06e5ed505d 100644 --- a/nano/test_common/testutil.cpp +++ b/nano/test_common/testutil.cpp @@ -68,7 +68,7 @@ nano::account nano::test::random_account () bool nano::test::process (nano::node & node, std::vector> blocks) { - auto const transaction = node.ledger.tx_begin_write ({ tables::accounts, tables::blocks, tables::pending, tables::rep_weights }); + auto const transaction = node.ledger.tx_begin_write (); for (auto & block : blocks) { auto result = node.process (transaction, block);