Skip to content

Commit

Permalink
Add transition_priority method to election class
Browse files Browse the repository at this point in the history
  • Loading branch information
gr0vity-dev committed Dec 3, 2024
1 parent d3b180a commit a5bf4d7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
19 changes: 19 additions & 0 deletions nano/node/election.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,25 @@ void nano::election::transition_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 ()
{
nano::lock_guard<nano::mutex> guard{ mutex };
Expand Down
1 change: 1 addition & 0 deletions nano/node/election.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class election final : public std::enable_shared_from_this<election>
public: // State transitions
bool transition_time (nano::confirmation_solicitor &);
void transition_active ();
bool transition_priority ();
void cancel ();

public: // Status
Expand Down

0 comments on commit a5bf4d7

Please sign in to comment.