Calculate votes for local representatives in block_confirm (#1534)

* Add recursive_mutex to foreach_representative

To prevent node.unlock_search assert

Initially part of v17 https://github.com/nanocurrency/raiblocks/pull/1409

* Calculate votes for local representatives in block_confirm

* Use vote_generator

* Fix

* Make vote_generator public

* Improve node.unlock_search test

* Formatting
This commit is contained in:
Sergey Kroshnin 2019-01-28 20:33:17 +03:00 committed by GitHub
commit dcc2d0f5e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 1 deletions

View file

@ -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<std::recursive_mutex> lock (system.wallet (0)->store.mutex);

View file

@ -2635,6 +2635,11 @@ void nano::node::block_confirm (std::shared_ptr<nano::block> 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 ()

View file

@ -433,6 +433,7 @@ public:
bool have_blocks ();
void process_blocks ();
nano::process_return process_one (nano::transaction const &, std::shared_ptr<nano::block>, 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<nano::node>