Skip to content

Commit

Permalink
Run node::process_confirmed from worker thread (nanocurrency#3958)
Browse files Browse the repository at this point in the history
This does database lookup and was called from vote processor thread
  • Loading branch information
pwojcikdev authored and clemahieu committed Oct 1, 2022
1 parent 98fd595 commit fcea645
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions nano/core_test/active_transactions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1219,9 +1219,9 @@ TEST (active_transactions, activate_inactive)
ASSERT_NE (nullptr, election);
election->force_confirm ();

ASSERT_TIMELY (3s, !node.confirmation_height_processor.is_processing_added_block (send2->hash ()));
ASSERT_TRUE (node.block_confirmed (send2->hash ()));
ASSERT_TRUE (node.block_confirmed (send->hash ()));
ASSERT_TIMELY (5s, !node.confirmation_height_processor.is_processing_added_block (send2->hash ()));
ASSERT_TIMELY (5s, node.block_confirmed (send2->hash ()));
ASSERT_TIMELY (5s, node.block_confirmed (send->hash ()));

ASSERT_EQ (1, node.stats.count (nano::stat::type::confirmation_observer, nano::stat::detail::inactive_conf_height, nano::stat::dir::out));
ASSERT_EQ (1, node.stats.count (nano::stat::type::confirmation_observer, nano::stat::detail::active_quorum, nano::stat::dir::out));
Expand Down
4 changes: 3 additions & 1 deletion nano/node/election.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ void nano::election::confirm_once (nano::unique_lock<nano::mutex> & lock_a, nano
status.type = type_a;
auto const status_l = status;
lock_a.unlock ();
node.process_confirmed (status_l);

node.background ([node_l = node.shared (), status_l, confirmation_action_l = confirmation_action] () {
node_l->process_confirmed (status_l);

if (confirmation_action_l)
{
confirmation_action_l (status_l.winner);
Expand Down

0 comments on commit fcea645

Please sign in to comment.