Add transition_priority method to election class
This commit is contained in:
parent
d3b180a2c5
commit
a5bf4d76f6
2 changed files with 20 additions and 0 deletions
|
|
@ -183,6 +183,25 @@ void nano::election::transition_active ()
|
||||||
state_change (nano::election_state::passive, nano::election_state::active);
|
state_change (nano::election_state::passive, nano::election_state::active);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool nano::election::transition_priority ()
|
||||||
|
{
|
||||||
|
nano::lock_guard<nano::mutex> guard{ mutex };
|
||||||
|
|
||||||
|
if (behavior_m == nano::election_behavior::priority || behavior_m == nano::election_behavior::manual)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
behavior_m = nano::election_behavior::priority;
|
||||||
|
last_vote = std::chrono::steady_clock::time_point{}; // allow new outgoing votes immediately
|
||||||
|
|
||||||
|
node.logger.debug (nano::log::type::election, "Transitioned election behavior to priority from {} for root: {}",
|
||||||
|
to_string (behavior_m),
|
||||||
|
qualified_root.to_string ());
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void nano::election::cancel ()
|
void nano::election::cancel ()
|
||||||
{
|
{
|
||||||
nano::lock_guard<nano::mutex> guard{ mutex };
|
nano::lock_guard<nano::mutex> guard{ mutex };
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,7 @@ private: // State management
|
||||||
public: // State transitions
|
public: // State transitions
|
||||||
bool transition_time (nano::confirmation_solicitor &);
|
bool transition_time (nano::confirmation_solicitor &);
|
||||||
void transition_active ();
|
void transition_active ();
|
||||||
|
bool transition_priority ();
|
||||||
void cancel ();
|
void cancel ();
|
||||||
|
|
||||||
public: // Status
|
public: // Status
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue