Make use of transition_priority() in active_elections
This commit is contained in:
parent
a5bf4d76f6
commit
cb39f8d70b
2 changed files with 19 additions and 0 deletions
|
|
@ -426,6 +426,8 @@ enum class detail
|
||||||
// active
|
// active
|
||||||
insert,
|
insert,
|
||||||
insert_failed,
|
insert_failed,
|
||||||
|
transition_priority,
|
||||||
|
transition_priority_failed,
|
||||||
election_cleanup,
|
election_cleanup,
|
||||||
|
|
||||||
// active_elections
|
// active_elections
|
||||||
|
|
|
||||||
|
|
@ -435,6 +435,23 @@ nano::election_insertion_result nano::active_elections::insert (std::shared_ptr<
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
result.election = existing->election;
|
result.election = existing->election;
|
||||||
|
|
||||||
|
// Upgrade to priority election to enable immediate vote broadcasting.
|
||||||
|
auto previous_behavior = result.election->behavior ();
|
||||||
|
if (election_behavior_a == nano::election_behavior::priority && previous_behavior != nano::election_behavior::priority)
|
||||||
|
{
|
||||||
|
bool transitioned = result.election->transition_priority ();
|
||||||
|
if (transitioned)
|
||||||
|
{
|
||||||
|
count_by_behavior[previous_behavior]--;
|
||||||
|
count_by_behavior[election_behavior_a]++;
|
||||||
|
node.stats.inc (nano::stat::type::active_elections, nano::stat::detail::transition_priority);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
node.stats.inc (nano::stat::type::active_elections, nano::stat::detail::transition_priority_failed);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lock.unlock ();
|
lock.unlock ();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue