Skip to content

Commit

Permalink
Erase representatives with full queues when adding to confirmation so…
Browse files Browse the repository at this point in the history
…licitor

With this change less processing happens for elections that won't fit in the solicitor.
  • Loading branch information
guilhermelawless committed Mar 10, 2020
1 parent 9b7f30a commit 72fac4a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion nano/node/confirmation_solicitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ bool nano::confirmation_solicitor::add (nano::election const & election_a)
debug_assert (prepared);
auto const max_channel_requests (max_confirm_req_batches * nano::network::confirm_req_hashes_max);
unsigned count = 0;
for (auto i (representatives.begin ()), n (representatives.end ()); i != n && count < max_election_requests; ++i)
for (auto i (representatives.begin ()); i != representatives.end () && count < max_election_requests;)
{
bool full_queue (false);
auto rep (*i);
if (election_a.last_votes.find (rep.account) == election_a.last_votes.end ())
{
Expand All @@ -48,7 +49,12 @@ bool nano::confirmation_solicitor::add (nano::election const & election_a)
request_queue.emplace_back (election_a.status.winner->hash (), election_a.status.winner->root ());
++count;
}
else
{
full_queue = true;
}
}
i = !full_queue ? i + 1 : representatives.erase (i);
}
return count == 0;
}
Expand Down

0 comments on commit 72fac4a

Please sign in to comment.