diff --git a/nano/core_test/active_transactions.cpp b/nano/core_test/active_transactions.cpp index 6da1b28580..99f3abd228 100644 --- a/nano/core_test/active_transactions.cpp +++ b/nano/core_test/active_transactions.cpp @@ -1,7 +1,7 @@ #include #include -#include #include +#include #include #include #include @@ -418,7 +418,7 @@ TEST (active_transactions, inactive_votes_cache_multiple_votes) ASSERT_TIMELY (5s, node.inactive_vote_cache.find (send1->hash ())); ASSERT_TIMELY (5s, node.inactive_vote_cache.find (send1->hash ())->voters.size () == 2); ASSERT_EQ (1, node.inactive_vote_cache.cache_size ()); - node.scheduler.buckets.activate (nano::dev::genesis_key.pub, node.store.tx_begin_read ()); + node.scheduler.priority.activate (nano::dev::genesis_key.pub, node.store.tx_begin_read ()); std::shared_ptr election; ASSERT_TIMELY (5s, election = node.active.election (send1->qualified_root ())); ASSERT_EQ (3, election->votes ().size ()); // 2 votes and 1 default not_an_acount @@ -996,7 +996,7 @@ TEST (active_transactions, confirmation_consistency) system.deadline_set (5s); while (!node.ledger.block_confirmed (node.store.tx_begin_read (), block->hash ())) { - node.scheduler.buckets.activate (nano::dev::genesis_key.pub, node.store.tx_begin_read ()); + node.scheduler.priority.activate (nano::dev::genesis_key.pub, node.store.tx_begin_read ()); ASSERT_NO_ERROR (system.poll (5ms)); } ASSERT_NO_ERROR (system.poll_until_true (1s, [&node, &block, i] { @@ -1140,19 +1140,19 @@ TEST (active_transactions, activate_account_chain) ASSERT_EQ (nano::process_result::progress, node.process (*open).code); ASSERT_EQ (nano::process_result::progress, node.process (*receive).code); - node.scheduler.buckets.activate (nano::dev::genesis_key.pub, node.store.tx_begin_read ()); + node.scheduler.priority.activate (nano::dev::genesis_key.pub, node.store.tx_begin_read ()); ASSERT_TIMELY (5s, node.active.election (send->qualified_root ())); auto election1 = node.active.election (send->qualified_root ()); ASSERT_EQ (1, node.active.size ()); ASSERT_EQ (1, election1->blocks ().count (send->hash ())); - node.scheduler.buckets.activate (nano::dev::genesis_key.pub, node.store.tx_begin_read ()); + node.scheduler.priority.activate (nano::dev::genesis_key.pub, node.store.tx_begin_read ()); auto election2 = node.active.election (send->qualified_root ()); ASSERT_EQ (election2, election1); election1->force_confirm (); ASSERT_TIMELY (3s, node.block_confirmed (send->hash ())); // On cementing, the next election is started ASSERT_TIMELY (3s, node.active.active (send2->qualified_root ())); - node.scheduler.buckets.activate (nano::dev::genesis_key.pub, node.store.tx_begin_read ()); + node.scheduler.priority.activate (nano::dev::genesis_key.pub, node.store.tx_begin_read ()); auto election3 = node.active.election (send2->qualified_root ()); ASSERT_NE (nullptr, election3); ASSERT_EQ (1, election3->blocks ().count (send2->hash ())); @@ -1161,11 +1161,11 @@ TEST (active_transactions, activate_account_chain) // On cementing, the next election is started ASSERT_TIMELY (3s, node.active.active (open->qualified_root ())); ASSERT_TIMELY (3s, node.active.active (send3->qualified_root ())); - node.scheduler.buckets.activate (nano::dev::genesis_key.pub, node.store.tx_begin_read ()); + node.scheduler.priority.activate (nano::dev::genesis_key.pub, node.store.tx_begin_read ()); auto election4 = node.active.election (send3->qualified_root ()); ASSERT_NE (nullptr, election4); ASSERT_EQ (1, election4->blocks ().count (send3->hash ())); - node.scheduler.buckets.activate (key.pub, node.store.tx_begin_read ()); + node.scheduler.priority.activate (key.pub, node.store.tx_begin_read ()); auto election5 = node.active.election (open->qualified_root ()); ASSERT_NE (nullptr, election5); ASSERT_EQ (1, election5->blocks ().count (open->hash ())); @@ -1173,7 +1173,7 @@ TEST (active_transactions, activate_account_chain) ASSERT_TIMELY (3s, node.block_confirmed (open->hash ())); // Until send3 is also confirmed, the receive block should not activate std::this_thread::sleep_for (200ms); - node.scheduler.buckets.activate (key.pub, node.store.tx_begin_read ()); + node.scheduler.priority.activate (key.pub, node.store.tx_begin_read ()); election4->force_confirm (); ASSERT_TIMELY (3s, node.block_confirmed (send3->hash ())); ASSERT_TIMELY (3s, node.active.active (receive->qualified_root ())); @@ -1314,7 +1314,7 @@ TEST (active_transactions, vacancy) ASSERT_EQ (nano::process_result::progress, node.process (*send).code); ASSERT_EQ (1, node.active.vacancy ()); ASSERT_EQ (0, node.active.size ()); - node.scheduler.buckets.activate (nano::dev::genesis_key.pub, node.store.tx_begin_read ()); + node.scheduler.priority.activate (nano::dev::genesis_key.pub, node.store.tx_begin_read ()); ASSERT_TIMELY (1s, updated); updated = false; ASSERT_EQ (0, node.active.vacancy ()); @@ -1393,11 +1393,11 @@ TEST (active_transactions, fifo) ASSERT_EQ (nano::process_result::progress, node.process (*receive2).code); // Ensure first transaction becomes active - node.scheduler.buckets.manual (receive1); + node.scheduler.priority.manual (receive1); ASSERT_TIMELY (5s, node.active.election (receive1->qualified_root ()) != nullptr); // Ensure second transaction becomes active - node.scheduler.buckets.manual (receive2); + node.scheduler.priority.manual (receive2); ASSERT_TIMELY (5s, node.active.election (receive2->qualified_root ()) != nullptr); // Ensure excess transactions get trimmed @@ -1503,7 +1503,7 @@ TEST (active_transactions, allow_limited_overflow) // Insert the first part of the blocks into normal election scheduler for (auto const & block : blocks1) { - node.scheduler.buckets.activate (block->account (), node.store.tx_begin_read ()); + node.scheduler.priority.activate (block->account (), node.store.tx_begin_read ()); } // Ensure number of active elections reaches AEC limit and there is no overfill @@ -1565,7 +1565,7 @@ TEST (active_transactions, allow_limited_overflow_adapt) // Insert the first part of the blocks into normal election scheduler for (auto const & block : blocks1) { - node.scheduler.buckets.activate (block->account (), node.store.tx_begin_read ()); + node.scheduler.priority.activate (block->account (), node.store.tx_begin_read ()); } // Ensure number of active elections reaches AEC limit and there is no overfill diff --git a/nano/core_test/conflicts.cpp b/nano/core_test/conflicts.cpp index 95ab8213a4..b37bd9560b 100644 --- a/nano/core_test/conflicts.cpp +++ b/nano/core_test/conflicts.cpp @@ -1,6 +1,6 @@ #include -#include #include +#include #include #include @@ -27,7 +27,7 @@ TEST (conflicts, start_stop) node1.work_generate_blocking (*send1); ASSERT_EQ (nano::process_result::progress, node1.process (*send1).code); ASSERT_EQ (0, node1.active.size ()); - node1.scheduler.buckets.activate (nano::dev::genesis_key.pub, node1.store.tx_begin_read ()); + node1.scheduler.priority.activate (nano::dev::genesis_key.pub, node1.store.tx_begin_read ()); ASSERT_TIMELY (5s, node1.active.election (send1->qualified_root ())); auto election1 = node1.active.election (send1->qualified_root ()); ASSERT_EQ (1, node1.active.size ()); @@ -60,7 +60,7 @@ TEST (conflicts, add_existing) ASSERT_TIMELY (5s, node1.block (send1->hash ())); // instruct the election scheduler to trigger an election for send1 - node1.scheduler.buckets.activate (nano::dev::genesis_key.pub, node1.store.tx_begin_read ()); + node1.scheduler.priority.activate (nano::dev::genesis_key.pub, node1.store.tx_begin_read ()); // wait for election to be started before processing send2 ASSERT_TIMELY (5s, node1.active.active (*send1)); @@ -167,7 +167,7 @@ TEST (conflicts, add_two) // activate elections for the previous two send blocks (to account3) that we did not forcefully confirm // - node->scheduler.buckets.activate (account3.pub, node->store.tx_begin_read ()); + node->scheduler.priority.activate (account3.pub, node->store.tx_begin_read ()); ASSERT_TIMELY (5s, node->active.election ((*send3)->qualified_root ()) != nullptr); ASSERT_TIMELY (5s, node->active.election ((*send4)->qualified_root ()) != nullptr); diff --git a/nano/core_test/election.cpp b/nano/core_test/election.cpp index 569c1b056a..db86268819 100644 --- a/nano/core_test/election.cpp +++ b/nano/core_test/election.cpp @@ -1,6 +1,6 @@ #include -#include #include +#include #include #include #include @@ -150,7 +150,7 @@ TEST (election, quorum_minimum_confirm_success) .build_shared (); node1.work_generate_blocking (*send1); node1.process_active (send1); - node1.scheduler.buckets.activate (nano::dev::genesis_key.pub, node1.store.tx_begin_read ()); + node1.scheduler.priority.activate (nano::dev::genesis_key.pub, node1.store.tx_begin_read ()); ASSERT_TIMELY (5s, node1.active.election (send1->qualified_root ())); auto election = node1.active.election (send1->qualified_root ()); ASSERT_NE (nullptr, election); diff --git a/nano/core_test/election_scheduler.cpp b/nano/core_test/election_scheduler.cpp index cf69b56fa0..3ed8e93a12 100644 --- a/nano/core_test/election_scheduler.cpp +++ b/nano/core_test/election_scheduler.cpp @@ -1,5 +1,5 @@ -#include #include +#include #include #include @@ -28,7 +28,7 @@ TEST (election_scheduler, activate_one_timely) .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); system.nodes[0]->ledger.process (system.nodes[0]->store.tx_begin_write (), *send1); - system.nodes[0]->scheduler.buckets.activate (nano::dev::genesis_key.pub, system.nodes[0]->store.tx_begin_read ()); + system.nodes[0]->scheduler.priority.activate (nano::dev::genesis_key.pub, system.nodes[0]->store.tx_begin_read ()); ASSERT_TIMELY (5s, system.nodes[0]->active.election (send1->qualified_root ())); } @@ -46,7 +46,7 @@ TEST (election_scheduler, activate_one_flush) .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); system.nodes[0]->ledger.process (system.nodes[0]->store.tx_begin_write (), *send1); - system.nodes[0]->scheduler.buckets.activate (nano::dev::genesis_key.pub, system.nodes[0]->store.tx_begin_read ()); + system.nodes[0]->scheduler.priority.activate (nano::dev::genesis_key.pub, system.nodes[0]->store.tx_begin_read ()); ASSERT_TIMELY (5s, system.nodes[0]->active.election (send1->qualified_root ())); } @@ -115,7 +115,7 @@ TEST (election_scheduler, no_vacancy) ASSERT_EQ (nano::process_result::progress, node.process (*block1).code); // There is vacancy so it should be inserted - node.scheduler.buckets.activate (nano::dev::genesis_key.pub, node.store.tx_begin_read ()); + node.scheduler.priority.activate (nano::dev::genesis_key.pub, node.store.tx_begin_read ()); std::shared_ptr election{}; ASSERT_TIMELY (5s, (election = node.active.election (block1->qualified_root ())) != nullptr); @@ -131,14 +131,14 @@ TEST (election_scheduler, no_vacancy) ASSERT_EQ (nano::process_result::progress, node.process (*block2).code); // There is no vacancy so it should stay queued - node.scheduler.buckets.activate (key.pub, node.store.tx_begin_read ()); - ASSERT_TIMELY (5s, node.scheduler.buckets.size () == 1); + node.scheduler.priority.activate (key.pub, node.store.tx_begin_read ()); + ASSERT_TIMELY (5s, node.scheduler.priority.size () == 1); ASSERT_TRUE (node.active.election (block2->qualified_root ()) == nullptr); // Election confirmed, next in queue should begin election->force_confirm (); ASSERT_TIMELY (5s, node.active.election (block2->qualified_root ()) != nullptr); - ASSERT_TRUE (node.scheduler.buckets.empty ()); + ASSERT_TRUE (node.scheduler.priority.empty ()); } // Ensure that election_scheduler::flush terminates even if no elections can currently be queued e.g. shutdown or no active_transactions vacancy @@ -162,9 +162,9 @@ TEST (election_scheduler, flush_vacancy) .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); ASSERT_EQ (nano::process_result::progress, node.process (*send).code); - node.scheduler.buckets.activate (nano::dev::genesis_key.pub, node.store.tx_begin_read ()); + node.scheduler.priority.activate (nano::dev::genesis_key.pub, node.store.tx_begin_read ()); // Ensure this call does not block, even though no elections can be activated. - node.scheduler.buckets.flush (); + node.scheduler.priority.flush (); ASSERT_EQ (0, node.active.size ()); - ASSERT_EQ (1, node.scheduler.buckets.size ()); + ASSERT_EQ (1, node.scheduler.priority.size ()); } diff --git a/nano/core_test/ledger.cpp b/nano/core_test/ledger.cpp index b2c043a2ae..43fe65c314 100644 --- a/nano/core_test/ledger.cpp +++ b/nano/core_test/ledger.cpp @@ -2,8 +2,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -913,7 +913,7 @@ TEST (votes, check_signature) auto transaction (node1.store.tx_begin_write ()); ASSERT_EQ (nano::process_result::progress, node1.ledger.process (transaction, *send1).code); } - node1.scheduler.buckets.activate (nano::dev::genesis_key.pub, node1.store.tx_begin_read ()); + node1.scheduler.priority.activate (nano::dev::genesis_key.pub, node1.store.tx_begin_read ()); ASSERT_TIMELY (5s, node1.active.election (send1->qualified_root ())); auto election1 = node1.active.election (send1->qualified_root ()); ASSERT_EQ (1, election1->votes ().size ()); @@ -984,7 +984,7 @@ TEST (votes, add_existing) .build (); node1.work_generate_blocking (*send1); ASSERT_EQ (nano::process_result::progress, node1.ledger.process (node1.store.tx_begin_write (), *send1).code); - node1.scheduler.buckets.activate (nano::dev::genesis_key.pub, node1.store.tx_begin_read ()); + node1.scheduler.priority.activate (nano::dev::genesis_key.pub, node1.store.tx_begin_read ()); ASSERT_TIMELY (5s, node1.active.election (send1->qualified_root ())); auto election1 = node1.active.election (send1->qualified_root ()); auto vote1 (std::make_shared (nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, nano::vote::timestamp_min * 1, 0, std::vector{ send1->hash () })); diff --git a/nano/core_test/network.cpp b/nano/core_test/network.cpp index 55efe9355b..c9ebbcd90f 100644 --- a/nano/core_test/network.cpp +++ b/nano/core_test/network.cpp @@ -1,7 +1,7 @@ #include #include -#include #include +#include #include #include #include @@ -366,7 +366,7 @@ TEST (receivable_processor, confirm_insufficient_pos) .build_shared (); node1.work_generate_blocking (*block1); ASSERT_EQ (nano::process_result::progress, node1.process (*block1).code); - node1.scheduler.buckets.activate (nano::dev::genesis_key.pub, node1.store.tx_begin_read ()); + node1.scheduler.priority.activate (nano::dev::genesis_key.pub, node1.store.tx_begin_read ()); nano::keypair key1; auto vote (std::make_shared (key1.pub, key1.prv, 0, 0, std::vector{ block1->hash () })); nano::confirm_ack con1{ nano::dev::network_params.network, vote }; @@ -389,7 +389,7 @@ TEST (receivable_processor, confirm_sufficient_pos) .build_shared (); node1.work_generate_blocking (*block1); ASSERT_EQ (nano::process_result::progress, node1.process (*block1).code); - node1.scheduler.buckets.activate (nano::dev::genesis_key.pub, node1.store.tx_begin_read ()); + node1.scheduler.priority.activate (nano::dev::genesis_key.pub, node1.store.tx_begin_read ()); auto vote (std::make_shared (nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, 0, 0, std::vector{ block1->hash () })); nano::confirm_ack con1{ nano::dev::network_params.network, vote }; auto channel1 = std::make_shared (node1, node1); diff --git a/nano/core_test/node.cpp b/nano/core_test/node.cpp index 270c0f99a2..20f5ae3188 100644 --- a/nano/core_test/node.cpp +++ b/nano/core_test/node.cpp @@ -1,7 +1,7 @@ #include #include -#include #include +#include #include #include #include @@ -987,7 +987,7 @@ TEST (node, fork_open_flip) // give block open1 to node1, manually trigger an election for open1 and ensure it is in the ledger node1.process_active (open1); ASSERT_TIMELY (5s, node1.block (open1->hash ()) != nullptr); - node1.scheduler.buckets.manual (open1); + node1.scheduler.priority.manual (open1); ASSERT_TIMELY (5s, (election = node1.active.election (open1->qualified_root ())) != nullptr); election->transition_active (); @@ -1000,7 +1000,7 @@ TEST (node, fork_open_flip) // ensure open2 is in node2 ledger (and therefore has sideband) and manually trigger an election for open2 ASSERT_TIMELY (5s, node2.block (open2->hash ()) != nullptr); - node2.scheduler.buckets.manual (open2); + node2.scheduler.priority.manual (open2); ASSERT_TIMELY (5s, (election = node2.active.election (open2->qualified_root ())) != nullptr); election->transition_active (); @@ -1415,7 +1415,7 @@ TEST (node, rep_self_vote) ASSERT_EQ (nano::process_result::progress, node0->process (*block0).code); auto & active = node0->active; auto & scheduler = node0->scheduler; - scheduler.buckets.activate (nano::dev::genesis_key.pub, node0->store.tx_begin_read ()); + scheduler.priority.activate (nano::dev::genesis_key.pub, node0->store.tx_begin_read ()); ASSERT_TIMELY (5s, active.election (block0->qualified_root ())); auto election1 = active.election (block0->qualified_root ()); ASSERT_NE (nullptr, election1); diff --git a/nano/node/CMakeLists.txt b/nano/node/CMakeLists.txt index d31b63aabf..28d9c7c5dc 100644 --- a/nano/node/CMakeLists.txt +++ b/nano/node/CMakeLists.txt @@ -196,14 +196,14 @@ add_library( rocksdb/rocksdb_iterator.hpp rocksdb/rocksdb_txn.hpp rocksdb/rocksdb_txn.cpp - scheduler/buckets.hpp - scheduler/buckets.cpp scheduler/component.hpp scheduler/component.cpp scheduler/hinted.hpp scheduler/hinted.cpp scheduler/optimistic.hpp scheduler/optimistic.cpp + scheduler/priority.hpp + scheduler/priority.cpp signatures.hpp signatures.cpp state_block_signature_verification.hpp diff --git a/nano/node/active_transactions.cpp b/nano/node/active_transactions.cpp index 34e1141ac3..6511aa8247 100644 --- a/nano/node/active_transactions.cpp +++ b/nano/node/active_transactions.cpp @@ -5,8 +5,8 @@ #include #include #include -#include #include +#include #include #include @@ -151,13 +151,13 @@ void nano::active_transactions::block_cemented_callback (std::shared_ptr #include #include -#include +#include #include nano::backlog_population::backlog_population (const config & config_a, nano::store & store_a, nano::stats & stats_a) : diff --git a/nano/node/node.cpp b/nano/node/node.cpp index 5b3142dc00..b0bc3e0371 100644 --- a/nano/node/node.cpp +++ b/nano/node/node.cpp @@ -5,10 +5,10 @@ #include #include #include -#include #include #include #include +#include #include #include #include @@ -205,7 +205,7 @@ nano::node::node (boost::asio::io_context & io_ctx_a, boost::filesystem::path co block_broadcast{ network, block_arrival, !flags.disable_block_processor_republishing }, block_publisher{ active }, gap_tracker{ gap_cache }, - process_live_dispatcher{ ledger, scheduler.buckets, inactive_vote_cache, websocket } + process_live_dispatcher{ ledger, scheduler.priority, inactive_vote_cache, websocket } { block_broadcast.connect (block_processor); block_publisher.connect (block_processor); @@ -220,7 +220,7 @@ nano::node::node (boost::asio::io_context & io_ctx_a, boost::filesystem::path co }; backlog.activate_callback.add ([this] (nano::transaction const & transaction, nano::account const & account, nano::account_info const & account_info, nano::confirmation_height_info const & conf_info) { - scheduler.buckets.activate (account, transaction); + scheduler.priority.activate (account, transaction); scheduler.optimistic.activate (account, account_info, conf_info); }); @@ -228,7 +228,7 @@ nano::node::node (boost::asio::io_context & io_ctx_a, boost::filesystem::path co { // Notify election schedulers when AEC frees election slot active.vacancy_update = [this] () { - scheduler.buckets.notify (); + scheduler.priority.notify (); scheduler.hinted.notify (); scheduler.optimistic.notify (); }; @@ -576,7 +576,7 @@ std::unique_ptr nano::collect_container_info (no composite->add_component (collect_container_info (node.confirmation_height_processor, "confirmation_height_processor")); composite->add_component (collect_container_info (node.distributed_work, "distributed_work")); composite->add_component (collect_container_info (node.aggregator, "request_aggregator")); - composite->add_component (node.scheduler.buckets.collect_container_info ("election_scheduler")); + composite->add_component (node.scheduler.priority.collect_container_info ("priority_scheduler")); composite->add_component (node.inactive_vote_cache.collect_container_info ("inactive_vote_cache")); composite->add_component (collect_container_info (node.generator, "vote_generator")); composite->add_component (collect_container_info (node.final_generator, "vote_generator_final")); @@ -689,7 +689,7 @@ void nano::node::start () generator.start (); final_generator.start (); scheduler.optimistic.start (); - scheduler.buckets.start (); + scheduler.priority.start (); backlog.start (); scheduler.hinted.start (); bootstrap_server.start (); @@ -723,7 +723,7 @@ void nano::node::stop () block_processor.stop (); aggregator.stop (); vote_processor.stop (); - scheduler.buckets.stop (); + scheduler.priority.stop (); scheduler.optimistic.stop (); scheduler.hinted.stop (); active.stop (); @@ -1265,8 +1265,8 @@ void nano::node::add_initial_peers () std::shared_ptr nano::node::block_confirm (std::shared_ptr const & block_a) { - scheduler.buckets.manual (block_a); - scheduler.buckets.flush (); + scheduler.priority.manual (block_a); + scheduler.priority.flush (); auto election = active.election (block_a->qualified_root ()); if (election != nullptr) { diff --git a/nano/node/process_live_dispatcher.cpp b/nano/node/process_live_dispatcher.cpp index 8a18e3b1ee..2b231a5258 100644 --- a/nano/node/process_live_dispatcher.cpp +++ b/nano/node/process_live_dispatcher.cpp @@ -1,14 +1,14 @@ #include #include #include -#include +#include #include #include #include #include #include -nano::process_live_dispatcher::process_live_dispatcher (nano::ledger & ledger, nano::scheduler::buckets & scheduler, nano::vote_cache & inactive_vote_cache, nano::websocket_server & websocket) : +nano::process_live_dispatcher::process_live_dispatcher (nano::ledger & ledger, nano::scheduler::priority & scheduler, nano::vote_cache & inactive_vote_cache, nano::websocket_server & websocket) : ledger{ ledger }, scheduler{ scheduler }, inactive_vote_cache{ inactive_vote_cache }, diff --git a/nano/node/process_live_dispatcher.hpp b/nano/node/process_live_dispatcher.hpp index 2255d8065d..23206544d1 100644 --- a/nano/node/process_live_dispatcher.hpp +++ b/nano/node/process_live_dispatcher.hpp @@ -12,14 +12,14 @@ class transaction; namespace scheduler { - class buckets; + class priority; } // Observes confirmed blocks and dispatches the process_live function. class process_live_dispatcher { public: - process_live_dispatcher (nano::ledger & ledger, nano::scheduler::buckets & scheduler, nano::vote_cache & inactive_vote_cache, nano::websocket_server & websocket); + process_live_dispatcher (nano::ledger & ledger, nano::scheduler::priority & scheduler, nano::vote_cache & inactive_vote_cache, nano::websocket_server & websocket); void connect (nano::block_processor & block_processor); private: @@ -28,7 +28,7 @@ class process_live_dispatcher void process_live (nano::block const & block, nano::transaction const & transaction); nano::ledger & ledger; - nano::scheduler::buckets & scheduler; + nano::scheduler::priority & scheduler; nano::vote_cache & inactive_vote_cache; nano::websocket_server & websocket; }; diff --git a/nano/node/scheduler/component.cpp b/nano/node/scheduler/component.cpp index 069bdba124..5303f52fa8 100644 --- a/nano/node/scheduler/component.cpp +++ b/nano/node/scheduler/component.cpp @@ -1,14 +1,14 @@ #include -#include #include #include #include +#include nano::scheduler::component::component (nano::node & node) : optimistic_impl{ std::make_unique (node.config.optimistic_scheduler, node, node.ledger, node.active, node.network_params.network, node.stats) }, - buckets_impl{ std::make_unique (node, node.stats) }, + priority_impl{ std::make_unique (node, node.stats) }, hinted_impl{ std::make_unique (nano::scheduler::hinted::config{ node.config }, node, node.inactive_vote_cache, node.active, node.online_reps, node.stats) }, - buckets{ *buckets_impl }, + priority{ *priority_impl }, hinted{ *hinted_impl }, optimistic{ *optimistic_impl } { diff --git a/nano/node/scheduler/component.hpp b/nano/node/scheduler/component.hpp index 3b5fb18919..0af9b41c1c 100644 --- a/nano/node/scheduler/component.hpp +++ b/nano/node/scheduler/component.hpp @@ -2,23 +2,26 @@ #include +namespace nano +{ +class node; +} namespace nano::scheduler { -class buckets; class hinted; -class node; class optimistic; +class priority; class component { std::unique_ptr optimistic_impl; - std::unique_ptr buckets_impl; + std::unique_ptr priority_impl; std::unique_ptr hinted_impl; public: explicit component (nano::node & node); - nano::scheduler::buckets & buckets; + nano::scheduler::priority & priority; nano::scheduler::hinted & hinted; nano::scheduler::optimistic & optimistic; }; diff --git a/nano/node/scheduler/buckets.cpp b/nano/node/scheduler/priority.cpp similarity index 70% rename from nano/node/scheduler/buckets.cpp rename to nano/node/scheduler/priority.cpp index bcb13e4f37..b2c7006c62 100644 --- a/nano/node/scheduler/buckets.cpp +++ b/nano/node/scheduler/priority.cpp @@ -1,19 +1,19 @@ #include -#include +#include -nano::scheduler::buckets::buckets (nano::node & node_a, nano::stats & stats_a) : +nano::scheduler::priority::priority (nano::node & node_a, nano::stats & stats_a) : node{ node_a }, stats{ stats_a } { } -nano::scheduler::buckets::~buckets () +nano::scheduler::priority::~priority () { // Thread must be stopped before destruction debug_assert (!thread.joinable ()); } -void nano::scheduler::buckets::start () +void nano::scheduler::priority::start () { debug_assert (!thread.joinable ()); @@ -23,7 +23,7 @@ void nano::scheduler::buckets::start () } }; } -void nano::scheduler::buckets::stop () +void nano::scheduler::priority::stop () { { nano::lock_guard lock{ mutex }; @@ -33,14 +33,14 @@ void nano::scheduler::buckets::stop () nano::join_or_pass (thread); } -void nano::scheduler::buckets::manual (std::shared_ptr const & block_a, boost::optional const & previous_balance_a, nano::election_behavior election_behavior_a) +void nano::scheduler::priority::manual (std::shared_ptr const & block_a, boost::optional const & previous_balance_a, nano::election_behavior election_behavior_a) { nano::lock_guard lock{ mutex }; manual_queue.push_back (std::make_tuple (block_a, previous_balance_a, election_behavior_a)); notify (); } -bool nano::scheduler::buckets::activate (nano::account const & account_a, nano::transaction const & transaction) +bool nano::scheduler::priority::activate (nano::account const & account_a, nano::transaction const & transaction) { debug_assert (!account_a.is_zero ()); auto info = node.ledger.account_info (transaction, account_a); @@ -60,7 +60,7 @@ bool nano::scheduler::buckets::activate (nano::account const & account_a, nano:: auto balance = node.ledger.balance (transaction, hash); auto previous_balance = node.ledger.balance (transaction, conf_info.frontier); nano::lock_guard lock{ mutex }; - priority.push (info->modified, block, std::max (balance, previous_balance)); + buckets.push (info->modified, block, std::max (balance, previous_balance)); notify (); return true; // Activated } @@ -69,7 +69,7 @@ bool nano::scheduler::buckets::activate (nano::account const & account_a, nano:: return false; // Not activated } -void nano::scheduler::buckets::flush () +void nano::scheduler::priority::flush () { nano::unique_lock lock{ mutex }; condition.wait (lock, [this] () { @@ -77,44 +77,44 @@ void nano::scheduler::buckets::flush () }); } -void nano::scheduler::buckets::notify () +void nano::scheduler::priority::notify () { condition.notify_all (); } -std::size_t nano::scheduler::buckets::size () const +std::size_t nano::scheduler::priority::size () const { nano::lock_guard lock{ mutex }; - return priority.size () + manual_queue.size (); + return buckets.size () + manual_queue.size (); } -bool nano::scheduler::buckets::empty_locked () const +bool nano::scheduler::priority::empty_locked () const { - return priority.empty () && manual_queue.empty (); + return buckets.empty () && manual_queue.empty (); } -bool nano::scheduler::buckets::empty () const +bool nano::scheduler::priority::empty () const { nano::lock_guard lock{ mutex }; return empty_locked (); } -std::size_t nano::scheduler::buckets::priority_queue_size () const +std::size_t nano::scheduler::priority::priority_queue_size () const { - return priority.size (); + return buckets.size (); } -bool nano::scheduler::buckets::priority_queue_predicate () const +bool nano::scheduler::priority::priority_queue_predicate () const { - return node.active.vacancy () > 0 && !priority.empty (); + return node.active.vacancy () > 0 && !buckets.empty (); } -bool nano::scheduler::buckets::manual_queue_predicate () const +bool nano::scheduler::priority::manual_queue_predicate () const { return !manual_queue.empty (); } -void nano::scheduler::buckets::run () +void nano::scheduler::priority::run () { nano::unique_lock lock{ mutex }; while (!stopped) @@ -137,8 +137,8 @@ void nano::scheduler::buckets::run () } else if (priority_queue_predicate ()) { - auto block = priority.top (); - priority.pop (); + auto block = buckets.top (); + buckets.pop (); lock.unlock (); stats.inc (nano::stat::type::election_scheduler, nano::stat::detail::insert_priority); auto result = node.active.insert (block); @@ -161,12 +161,12 @@ void nano::scheduler::buckets::run () } } -std::unique_ptr nano::scheduler::buckets::collect_container_info (std::string const & name) +std::unique_ptr nano::scheduler::priority::collect_container_info (std::string const & name) { nano::unique_lock lock{ mutex }; auto composite = std::make_unique (name); composite->add_component (std::make_unique (container_info{ "manual_queue", manual_queue.size (), sizeof (decltype (manual_queue)::value_type) })); - composite->add_component (priority.collect_container_info ("priority")); + composite->add_component (buckets.collect_container_info ("buckets")); return composite; } diff --git a/nano/node/scheduler/buckets.hpp b/nano/node/scheduler/priority.hpp similarity index 93% rename from nano/node/scheduler/buckets.hpp rename to nano/node/scheduler/priority.hpp index 9646690766..3343f64cdf 100644 --- a/nano/node/scheduler/buckets.hpp +++ b/nano/node/scheduler/priority.hpp @@ -19,11 +19,11 @@ class node; namespace nano::scheduler { -class buckets final +class priority final { public: - buckets (nano::node &, nano::stats &); - ~buckets (); + priority (nano::node &, nano::stats &); + ~priority (); void start (); void stop (); @@ -54,7 +54,7 @@ class buckets final bool priority_queue_predicate () const; bool manual_queue_predicate () const; - nano::prioritization priority; + nano::prioritization buckets; std::deque, boost::optional, nano::election_behavior>> manual_queue; bool stopped{ false }; diff --git a/nano/rpc_test/rpc.cpp b/nano/rpc_test/rpc.cpp index 169ee76103..e60bb70d3a 100644 --- a/nano/rpc_test/rpc.cpp +++ b/nano/rpc_test/rpc.cpp @@ -5,8 +5,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -1559,7 +1559,7 @@ TEST (rpc, process_subtype_open) ASSERT_EQ (nano::process_result::progress, node1->process (*send).code); ASSERT_EQ (nano::process_result::progress, node2.process (*send).code); auto const rpc_ctx = add_rpc (system, node1); - node1->scheduler.buckets.manual (send); + node1->scheduler.priority.manual (send); auto open = builder .state () .account (key.pub) @@ -1608,7 +1608,7 @@ TEST (rpc, process_subtype_receive) ASSERT_EQ (nano::process_result::progress, node1->process (*send).code); ASSERT_EQ (nano::process_result::progress, node2.process (*send).code); auto const rpc_ctx = add_rpc (system, node1); - node1->scheduler.buckets.manual (send); + node1->scheduler.priority.manual (send); auto receive = builder .state () .account (nano::dev::genesis_key.pub) @@ -2448,7 +2448,7 @@ TEST (rpc, account_representative_set_epoch_2_insufficient_work) ASSERT_NE (nullptr, system.upgrade_genesis_epoch (*node, nano::epoch::epoch_2)); // speed up the cementing process, otherwise the node waits for frontiers confirmation to notice the unconfirmed epoch blocks, which takes time - node->scheduler.buckets.activate (nano::dev::genesis_key.pub, node->store.tx_begin_read ()); + node->scheduler.priority.activate (nano::dev::genesis_key.pub, node->store.tx_begin_read ()); // wait for the epoch blocks to be cemented ASSERT_TIMELY (5s, node->get_confirmation_height (node->store.tx_begin_read (), nano::dev::genesis_key.pub) == 3); @@ -6964,12 +6964,12 @@ TEST (node, election_scheduler_container_info) // process the block and wait for it to show up in the election scheduler node->process_active (send1); - ASSERT_TIMELY (10s, node->scheduler.buckets.size () == 1); + ASSERT_TIMELY (10s, node->scheduler.priority.size () == 1); // now check the RPC call boost::property_tree::ptree request; request.put ("action", "stats"); request.put ("type", "objects"); auto response = wait_response (system, rpc_ctx, request); - auto es = response.get_child ("node").get_child ("election_scheduler"); + auto es = response.get_child ("node").get_child ("priority_scheduler"); } diff --git a/nano/slow_test/node.cpp b/nano/slow_test/node.cpp index 18ed359e0a..280ce6dff1 100644 --- a/nano/slow_test/node.cpp +++ b/nano/slow_test/node.cpp @@ -1,8 +1,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -677,7 +677,7 @@ TEST (confirmation_height, many_accounts_single_confirmation) { auto block = node->block (last_open_hash); ASSERT_NE (nullptr, block); - node->scheduler.buckets.manual (block); + node->scheduler.priority.manual (block); std::shared_ptr election; ASSERT_TIMELY (10s, (election = node->active.election (block->qualified_root ())) != nullptr); election->force_confirm (); @@ -760,7 +760,7 @@ TEST (confirmation_height, many_accounts_many_confirmations) // Confirm all of the accounts for (auto & open_block : open_blocks) { - node->scheduler.buckets.manual (open_block); + node->scheduler.priority.manual (open_block); std::shared_ptr election; ASSERT_TIMELY (10s, (election = node->active.election (open_block->qualified_root ())) != nullptr); election->force_confirm (); @@ -900,7 +900,7 @@ TEST (confirmation_height, long_chains) // Call block confirm on the existing receive block on the genesis account which will confirm everything underneath on both accounts { - node->scheduler.buckets.manual (receive1); + node->scheduler.priority.manual (receive1); std::shared_ptr election; ASSERT_TIMELY (10s, (election = node->active.election (receive1->qualified_root ())) != nullptr); election->force_confirm (); @@ -2225,7 +2225,7 @@ TEST (node, wallet_create_block_confirm_conflicts) // Call block confirm on the top level send block which will confirm everything underneath on both accounts. { auto block = node->store.block.get (node->store.tx_begin_read (), latest); - node->scheduler.buckets.manual (block); + node->scheduler.priority.manual (block); std::shared_ptr election; ASSERT_TIMELY (10s, (election = node->active.election (block->qualified_root ())) != nullptr); election->force_confirm (); @@ -2319,7 +2319,7 @@ TEST (system, block_sequence) std::string message; for (auto i : system.nodes) { - message += boost::str (boost::format ("N:%1% b:%2% c:%3% a:%4% s:%5% p:%6%\n") % std::to_string (i->network.port) % std::to_string (i->ledger.cache.block_count) % std::to_string (i->ledger.cache.cemented_count) % std::to_string (i->active.size ()) % std::to_string (i->scheduler.buckets.size ()) % std::to_string (i->network.size ())); + message += boost::str (boost::format ("N:%1% b:%2% c:%3% a:%4% s:%5% p:%6%\n") % std::to_string (i->network.port) % std::to_string (i->ledger.cache.block_count) % std::to_string (i->ledger.cache.cemented_count) % std::to_string (i->active.size ()) % std::to_string (i->scheduler.priority.size ()) % std::to_string (i->network.size ())); nano::lock_guard lock{ i->active.mutex }; for (auto const & j : i->active.roots) { diff --git a/nano/test_common/testutil.cpp b/nano/test_common/testutil.cpp index 0480913c89..0232f61671 100644 --- a/nano/test_common/testutil.cpp +++ b/nano/test_common/testutil.cpp @@ -1,6 +1,6 @@ #include -#include #include +#include #include #include #include @@ -156,7 +156,7 @@ bool nano::test::activate (nano::node & node, std::vector hash // Block does not exist in the ledger yet return false; } - node.scheduler.buckets.manual (disk_block); + node.scheduler.priority.manual (disk_block); } return true; } @@ -237,7 +237,7 @@ std::shared_ptr nano::test::start_election (nano::test::system & block_l = node_a.block (hash_a); } - node_a.scheduler.buckets.manual (block_l); + node_a.scheduler.priority.manual (block_l); // wait for the election to appear std::shared_ptr election = node_a.active.election (block_l->qualified_root ());