Remove priority::flush function

Fixes election.construction test where election might become active/inactive before it can be polled in the test. Removes election_scheduler.flush_vacancy which only tested the flush function.
This commit is contained in:
Colin LeMahieu 2023-09-04 15:41:41 +01:00
commit 2ce2378a50
No known key found for this signature in database
GPG key ID: 43708520C8DFB938
5 changed files with 2 additions and 43 deletions

View file

@ -13,10 +13,8 @@ TEST (election, construction)
{
nano::test::system system (1);
auto & node = *system.nodes[0];
node.start_election (nano::dev::genesis);
ASSERT_TIMELY (5s, node.active.election (nano::dev::genesis->qualified_root ()));
auto election = node.active.election (nano::dev::genesis->qualified_root ());
election->transition_active ();
auto election = std::make_shared<nano::election> (
node, nano::dev::genesis, [] (auto const &) {}, [] (auto const &) {}, nano::election_behavior::normal);
}
TEST (election, behavior)

View file

@ -140,31 +140,3 @@ TEST (election_scheduler, no_vacancy)
ASSERT_TIMELY (5s, node.active.election (block2->qualified_root ()) != nullptr);
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
TEST (election_scheduler, flush_vacancy)
{
nano::test::system system;
nano::node_config config = system.default_config ();
// No elections can be activated
config.active_elections_size = 0;
auto & node = *system.add_node (config);
nano::state_block_builder builder;
nano::keypair key;
auto send = builder.make_block ()
.account (nano::dev::genesis_key.pub)
.previous (nano::dev::genesis->hash ())
.representative (nano::dev::genesis_key.pub)
.link (key.pub)
.balance (nano::dev::constants.genesis_amount - nano::Gxrb_ratio)
.sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub)
.work (*system.work.generate (nano::dev::genesis->hash ()))
.build_shared ();
ASSERT_EQ (nano::process_result::progress, node.process (*send).code);
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.priority.flush ();
ASSERT_EQ (0, node.active.size ());
ASSERT_EQ (1, node.scheduler.priority.size ());
}

View file

@ -1266,7 +1266,6 @@ void nano::node::add_initial_peers ()
void nano::node::start_election (std::shared_ptr<nano::block> const & block)
{
scheduler.priority.manual (block);
scheduler.priority.flush ();
}
bool nano::node::block_confirmed (nano::block_hash const & hash_a)

View file

@ -69,14 +69,6 @@ bool nano::scheduler::priority::activate (nano::account const & account_a, nano:
return false; // Not activated
}
void nano::scheduler::priority::flush ()
{
nano::unique_lock<nano::mutex> lock{ mutex };
condition.wait (lock, [this] () {
return stopped || empty_locked () || node.active.vacancy () <= 0;
});
}
void nano::scheduler::priority::notify ()
{
condition.notify_all ();

View file

@ -36,8 +36,6 @@ public:
* @return true if account was activated
*/
bool activate (nano::account const &, nano::transaction const &);
// Blocks until no more elections can be activated or there are no more elections to activate
void flush ();
void notify ();
std::size_t size () const;
bool empty () const;