diff --git a/nano/core_test/node.cpp b/nano/core_test/node.cpp index 8f7c10e0..3590485b 100644 --- a/nano/core_test/node.cpp +++ b/nano/core_test/node.cpp @@ -368,6 +368,10 @@ TEST (node, unlock_search) { ASSERT_NO_ERROR (system.poll ()); } + while (!system.nodes[0]->active.roots.empty ()) + { + ASSERT_NO_ERROR (system.poll ()); + } system.wallet (0)->insert_adhoc (key2.prv); { std::lock_guard lock (system.wallet (0)->store.mutex); diff --git a/nano/node/node.cpp b/nano/node/node.cpp index 99acbdc6..4e1a35dc 100644 --- a/nano/node/node.cpp +++ b/nano/node/node.cpp @@ -2635,6 +2635,11 @@ void nano::node::block_confirm (std::shared_ptr block_a) { active.start (block_a); network.broadcast_confirm_req (block_a); + // Calculate votes for local representatives + if (config.enable_voting && active.active (*block_a)) + { + block_processor.generator.add (block_a->hash ()); + } } nano::uint128_t nano::node::delta () diff --git a/nano/node/node.hpp b/nano/node/node.hpp index aa636e6b..e69a8e80 100644 --- a/nano/node/node.hpp +++ b/nano/node/node.hpp @@ -433,6 +433,7 @@ public: bool have_blocks (); void process_blocks (); nano::process_return process_one (nano::transaction const &, std::shared_ptr, std::chrono::steady_clock::time_point = std::chrono::steady_clock::now (), bool = false); + nano::vote_generator generator; private: void queue_unchecked (nano::transaction const &, nano::block_hash const &, std::chrono::steady_clock::time_point = std::chrono::steady_clock::time_point ()); @@ -454,7 +455,6 @@ private: static size_t const rolled_back_max = 1024; std::condition_variable condition; nano::node & node; - nano::vote_generator generator; std::mutex mutex; }; class node : public std::enable_shared_from_this