Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Style fix, pass transaction as first argument. #4592

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions nano/core_test/active_transactions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ TEST (inactive_votes_cache, multiple_votes)

ASSERT_TIMELY_EQ (5s, node.vote_cache.find (send1->hash ()).size (), 2);
ASSERT_EQ (1, node.vote_cache.size ());
node.scheduler.priority.activate (nano::dev::genesis_key.pub, node.ledger.tx_begin_read ());
node.scheduler.priority.activate (node.ledger.tx_begin_read (), nano::dev::genesis_key.pub);
std::shared_ptr<nano::election> 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
Expand Down Expand Up @@ -1018,7 +1018,7 @@ TEST (active_transactions, confirmation_consistency)
system.deadline_set (5s);
while (!node.ledger.confirmed.block_exists_or_pruned (node.ledger.tx_begin_read (), block->hash ()))
{
node.scheduler.priority.activate (nano::dev::genesis_key.pub, node.ledger.tx_begin_read ());
node.scheduler.priority.activate (node.ledger.tx_begin_read (), nano::dev::genesis_key.pub);
ASSERT_NO_ERROR (system.poll (5ms));
}
ASSERT_NO_ERROR (system.poll_until_true (1s, [&node, &block, i] {
Expand Down Expand Up @@ -1160,19 +1160,19 @@ TEST (active_transactions, activate_account_chain)
ASSERT_EQ (nano::block_status::progress, node.process (open));
ASSERT_EQ (nano::block_status::progress, node.process (receive));

node.scheduler.priority.activate (nano::dev::genesis_key.pub, node.ledger.tx_begin_read ());
node.scheduler.priority.activate (node.ledger.tx_begin_read (), nano::dev::genesis_key.pub);
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.priority.activate (nano::dev::genesis_key.pub, node.ledger.tx_begin_read ());
node.scheduler.priority.activate (node.ledger.tx_begin_read (), nano::dev::genesis_key.pub);
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.priority.activate (nano::dev::genesis_key.pub, node.ledger.tx_begin_read ());
node.scheduler.priority.activate (node.ledger.tx_begin_read (), nano::dev::genesis_key.pub);
auto election3 = node.active.election (send2->qualified_root ());
ASSERT_NE (nullptr, election3);
ASSERT_EQ (1, election3->blocks ().count (send2->hash ()));
Expand All @@ -1181,19 +1181,19 @@ 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.priority.activate (nano::dev::genesis_key.pub, node.ledger.tx_begin_read ());
node.scheduler.priority.activate (node.ledger.tx_begin_read (), nano::dev::genesis_key.pub);
auto election4 = node.active.election (send3->qualified_root ());
ASSERT_NE (nullptr, election4);
ASSERT_EQ (1, election4->blocks ().count (send3->hash ()));
node.scheduler.priority.activate (key.pub, node.ledger.tx_begin_read ());
node.scheduler.priority.activate (node.ledger.tx_begin_read (), key.pub);
auto election5 = node.active.election (open->qualified_root ());
ASSERT_NE (nullptr, election5);
ASSERT_EQ (1, election5->blocks ().count (open->hash ()));
election5->force_confirm ();
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.priority.activate (key.pub, node.ledger.tx_begin_read ());
node.scheduler.priority.activate (node.ledger.tx_begin_read (), key.pub);
election4->force_confirm ();
ASSERT_TIMELY (3s, node.block_confirmed (send3->hash ()));
ASSERT_TIMELY (3s, node.active.active (receive->qualified_root ()));
Expand Down Expand Up @@ -1334,7 +1334,7 @@ TEST (active_transactions, vacancy)
ASSERT_EQ (nano::block_status::progress, node.process (send));
ASSERT_EQ (1, node.active.vacancy ());
ASSERT_EQ (0, node.active.size ());
node.scheduler.priority.activate (nano::dev::genesis_key.pub, node.ledger.tx_begin_read ());
node.scheduler.priority.activate (node.ledger.tx_begin_read (), nano::dev::genesis_key.pub);
ASSERT_TIMELY (1s, updated);
updated = false;
ASSERT_EQ (0, node.active.vacancy ());
Expand Down Expand Up @@ -1524,7 +1524,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.priority.activate (block->account (), node.ledger.tx_begin_read ());
node.scheduler.priority.activate (node.ledger.tx_begin_read (), block->account ());
}

// Ensure number of active elections reaches AEC limit and there is no overfill
Expand Down Expand Up @@ -1586,7 +1586,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.priority.activate (block->account (), node.ledger.tx_begin_read ());
node.scheduler.priority.activate (node.ledger.tx_begin_read (), block->account ());
}

// Ensure number of active elections reaches AEC limit and there is no overfill
Expand Down
4 changes: 2 additions & 2 deletions nano/core_test/conflicts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ TEST (conflicts, start_stop)
node1.work_generate_blocking (*send1);
ASSERT_EQ (nano::block_status::progress, node1.process (send1));
ASSERT_EQ (0, node1.active.size ());
node1.scheduler.priority.activate (nano::dev::genesis_key.pub, node1.ledger.tx_begin_read ());
node1.scheduler.priority.activate (node1.ledger.tx_begin_read (), nano::dev::genesis_key.pub);
ASSERT_TIMELY (5s, node1.active.election (send1->qualified_root ()));
auto election1 = node1.active.election (send1->qualified_root ());
ASSERT_EQ (1, node1.active.size ());
Expand Down Expand Up @@ -64,7 +64,7 @@ TEST (conflicts, add_existing)
ASSERT_TIMELY (5s, node1.block (send1->hash ()));

// instruct the election scheduler to trigger an election for send1
node1.scheduler.priority.activate (nano::dev::genesis_key.pub, node1.ledger.tx_begin_read ());
node1.scheduler.priority.activate (node1.ledger.tx_begin_read (), nano::dev::genesis_key.pub);

// wait for election to be started before processing send2
ASSERT_TIMELY (5s, node1.active.active (*send1));
Expand Down
2 changes: 1 addition & 1 deletion nano/core_test/election.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ TEST (election, quorum_minimum_confirm_success)
.build ();
node1.work_generate_blocking (*send1);
node1.process_active (send1);
node1.scheduler.priority.activate (nano::dev::genesis_key.pub, node1.ledger.tx_begin_read ());
node1.scheduler.priority.activate (node1.ledger.tx_begin_read (), nano::dev::genesis_key.pub);
ASSERT_TIMELY (5s, node1.active.election (send1->qualified_root ()));
auto election = node1.active.election (send1->qualified_root ());
ASSERT_NE (nullptr, election);
Expand Down
8 changes: 4 additions & 4 deletions nano/core_test/election_scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ TEST (election_scheduler, activate_one_timely)
.work (*system.work.generate (nano::dev::genesis->hash ()))
.build ();
system.nodes[0]->ledger.process (system.nodes[0]->ledger.tx_begin_write (), send1);
system.nodes[0]->scheduler.priority.activate (nano::dev::genesis_key.pub, system.nodes[0]->ledger.tx_begin_read ());
system.nodes[0]->scheduler.priority.activate (system.nodes[0]->ledger.tx_begin_read (), nano::dev::genesis_key.pub);
ASSERT_TIMELY (5s, system.nodes[0]->active.election (send1->qualified_root ()));
}

Expand All @@ -50,7 +50,7 @@ TEST (election_scheduler, activate_one_flush)
.work (*system.work.generate (nano::dev::genesis->hash ()))
.build ();
system.nodes[0]->ledger.process (system.nodes[0]->ledger.tx_begin_write (), send1);
system.nodes[0]->scheduler.priority.activate (nano::dev::genesis_key.pub, system.nodes[0]->ledger.tx_begin_read ());
system.nodes[0]->scheduler.priority.activate (system.nodes[0]->ledger.tx_begin_read (), nano::dev::genesis_key.pub);
ASSERT_TIMELY (5s, system.nodes[0]->active.election (send1->qualified_root ()));
}

Expand Down Expand Up @@ -121,7 +121,7 @@ TEST (election_scheduler, no_vacancy)
ASSERT_EQ (nano::block_status::progress, node.process (block1));

// There is vacancy so it should be inserted
node.scheduler.priority.activate (nano::dev::genesis_key.pub, node.ledger.tx_begin_read ());
node.scheduler.priority.activate (node.ledger.tx_begin_read (), nano::dev::genesis_key.pub);
std::shared_ptr<nano::election> election{};
ASSERT_TIMELY (5s, (election = node.active.election (block1->qualified_root ())) != nullptr);

Expand All @@ -137,7 +137,7 @@ TEST (election_scheduler, no_vacancy)
ASSERT_EQ (nano::block_status::progress, node.process (block2));

// There is no vacancy so it should stay queued
node.scheduler.priority.activate (key.pub, node.ledger.tx_begin_read ());
node.scheduler.priority.activate (node.ledger.tx_begin_read (), key.pub);
ASSERT_TIMELY_EQ (5s, node.scheduler.priority.size (), 1);
ASSERT_EQ (node.active.election (block2->qualified_root ()), nullptr);

Expand Down
4 changes: 2 additions & 2 deletions nano/core_test/ledger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ TEST (votes, check_signature)
auto transaction = node1.ledger.tx_begin_write ();
ASSERT_EQ (nano::block_status::progress, node1.ledger.process (transaction, send1));
}
node1.scheduler.priority.activate (nano::dev::genesis_key.pub, node1.ledger.tx_begin_read ());
node1.scheduler.priority.activate (node1.ledger.tx_begin_read (), nano::dev::genesis_key.pub);
ASSERT_TIMELY (5s, node1.active.election (send1->qualified_root ()));
auto election1 = node1.active.election (send1->qualified_root ());
ASSERT_EQ (1, election1->votes ().size ());
Expand Down Expand Up @@ -1034,7 +1034,7 @@ TEST (votes, add_existing)
.build ();
node1.work_generate_blocking (*send1);
ASSERT_EQ (nano::block_status::progress, node1.ledger.process (node1.ledger.tx_begin_write (), send1));
node1.scheduler.priority.activate (nano::dev::genesis_key.pub, node1.ledger.tx_begin_read ());
node1.scheduler.priority.activate (node1.ledger.tx_begin_read (), nano::dev::genesis_key.pub);
ASSERT_TIMELY (5s, node1.active.election (send1->qualified_root ()));
auto election1 = node1.active.election (send1->qualified_root ());
auto vote1 = nano::test::make_vote (nano::dev::genesis_key, { send1 }, nano::vote::timestamp_min * 1, 0);
Expand Down
4 changes: 2 additions & 2 deletions nano/core_test/network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ TEST (receivable_processor, confirm_insufficient_pos)
.build ();
node1.work_generate_blocking (*block1);
ASSERT_EQ (nano::block_status::progress, node1.process (block1));
node1.scheduler.priority.activate (nano::dev::genesis_key.pub, node1.ledger.tx_begin_read ());
node1.scheduler.priority.activate (node1.ledger.tx_begin_read (), nano::dev::genesis_key.pub);
nano::keypair key1;
auto vote = nano::test::make_vote (key1, { block1 }, 0, 0);
nano::confirm_ack con1{ nano::dev::network_params.network, vote };
Expand All @@ -393,7 +393,7 @@ TEST (receivable_processor, confirm_sufficient_pos)
.build ();
node1.work_generate_blocking (*block1);
ASSERT_EQ (nano::block_status::progress, node1.process (block1));
node1.scheduler.priority.activate (nano::dev::genesis_key.pub, node1.ledger.tx_begin_read ());
node1.scheduler.priority.activate (node1.ledger.tx_begin_read (), nano::dev::genesis_key.pub);
auto vote = nano::test::make_vote (nano::dev::genesis_key, { block1 }, 0, 0);
nano::confirm_ack con1{ nano::dev::network_params.network, vote };
auto channel1 = std::make_shared<nano::transport::inproc::channel> (node1, node1);
Expand Down
4 changes: 2 additions & 2 deletions nano/core_test/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1362,7 +1362,7 @@ TEST (node, rep_self_vote)
ASSERT_EQ (nano::block_status::progress, node0->process (block0));
auto & active = node0->active;
auto & scheduler = node0->scheduler;
scheduler.priority.activate (nano::dev::genesis_key.pub, node0->ledger.tx_begin_read ());
scheduler.priority.activate (node0->ledger.tx_begin_read (), nano::dev::genesis_key.pub);
ASSERT_TIMELY (5s, active.election (block0->qualified_root ()));
auto election1 = active.election (block0->qualified_root ());
ASSERT_NE (nullptr, election1);
Expand Down Expand Up @@ -3897,4 +3897,4 @@ TEST (node, port_mapping)
nano::test::system system;
auto node = system.add_node ();
node->port_mapping.refresh_devices ();
}
}
4 changes: 2 additions & 2 deletions nano/node/active_transactions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,12 @@ void nano::active_transactions::notify_observers (nano::secure::read_transaction

void nano::active_transactions::activate_successors (nano::secure::read_transaction const & transaction, std::shared_ptr<nano::block> const & block)
{
node.scheduler.priority.activate (block->account (), transaction);
node.scheduler.priority.activate (transaction, block->account ());

// Start or vote for the next unconfirmed block in the destination account
if (block->is_send () && !block->destination ().is_zero () && block->destination () != block->account ())
{
node.scheduler.priority.activate (block->destination (), transaction);
node.scheduler.priority.activate (transaction, block->destination ());
}
}

Expand Down
2 changes: 1 addition & 1 deletion nano/node/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ nano::node::node (std::shared_ptr<boost::asio::io_context> io_ctx_a, std::filesy
};

backlog.activate_callback.add ([this] (secure::transaction const & transaction, nano::account const & account) {
scheduler.priority.activate (account, transaction);
scheduler.priority.activate (transaction, account);
scheduler.optimistic.activate (transaction, account);
});

Expand Down
2 changes: 1 addition & 1 deletion nano/node/process_live_dispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void nano::process_live_dispatcher::process_live (nano::block const & block, sec
// Start collecting quorum on block
if (ledger.dependents_confirmed (transaction, block))
{
scheduler.activate (block.account (), transaction);
scheduler.activate (transaction, block.account ());
}

if (websocket.server && websocket.server->any_subscriber (nano::websocket::topic::new_unconfirmed_block))
Expand Down
2 changes: 1 addition & 1 deletion nano/node/scheduler/priority.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void nano::scheduler::priority::stop ()
nano::join_or_pass (thread);
}

bool nano::scheduler::priority::activate (nano::account const & account, secure::transaction const & transaction)
bool nano::scheduler::priority::activate (secure::transaction const & transaction, nano::account const & account)
{
debug_assert (!account.is_zero ());
auto head = node.ledger.confirmed.account_head (transaction, account);
Expand Down
2 changes: 1 addition & 1 deletion nano/node/scheduler/priority.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class priority final
* Activates the first unconfirmed block of \p account_a
* @return true if account was activated
*/
bool activate (nano::account const &, secure::transaction const &);
bool activate (secure::transaction const &, nano::account const &);
void notify ();
std::size_t size () const;
bool empty () const;
Expand Down
2 changes: 1 addition & 1 deletion nano/rpc_test/rpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2456,7 +2456,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.priority.activate (nano::dev::genesis_key.pub, node->ledger.tx_begin_read ());
node->scheduler.priority.activate (node->ledger.tx_begin_read (), nano::dev::genesis_key.pub);

// wait for the epoch blocks to be cemented
ASSERT_TIMELY_EQ (5s, node->ledger.confirmed.account_height (node->ledger.tx_begin_read (), nano::dev::genesis_key.pub), 3);
Expand Down
Loading