Run node::process_confirmed from worker thread (#3958)

This does database lookup and was called from vote processor thread
This commit is contained in:
Piotr Wójcik 2022-09-28 12:12:10 +02:00 committed by GitHub
commit 37860c6476
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View file

@ -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));

View file

@ -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);