From e4b491754ac098ddfc9295c982a41b7a163d8268 Mon Sep 17 00:00:00 2001 From: Colin LeMahieu Date: Wed, 20 Mar 2024 10:36:59 +0000 Subject: [PATCH] Remove unused code related to trying to externally set election status --- nano/node/election.cpp | 35 ++++++----------------------------- nano/node/election.hpp | 7 +++---- 2 files changed, 9 insertions(+), 33 deletions(-) diff --git a/nano/node/election.cpp b/nano/node/election.cpp index d179dabd..a41136e4 100644 --- a/nano/node/election.cpp +++ b/nano/node/election.cpp @@ -34,7 +34,7 @@ nano::election::election (nano::node & node_a, std::shared_ptr cons last_blocks.emplace (block_a->hash (), block_a); } -void nano::election::confirm_once (nano::unique_lock & lock_a, nano::election_status_type type_a) +void nano::election::confirm_once (nano::unique_lock & lock_a) { debug_assert (lock_a.owns_lock ()); @@ -51,7 +51,6 @@ void nano::election::confirm_once (nano::unique_lock & lock_a, nano status.confirmation_request_count = confirmation_request_count; status.block_count = nano::narrow_cast (last_blocks.size ()); status.voter_count = nano::narrow_cast (last_votes.size ()); - status.type = type_a; auto const status_l = status; node.active.recently_confirmed.put (qualified_root, status_l.winner->hash ()); @@ -403,44 +402,22 @@ void nano::election::confirm_if_quorum (nano::unique_lock & lock_a) } if (final_weight >= node.online_reps.delta ()) { - confirm_once (lock_a, nano::election_status_type::active_confirmed_quorum); + confirm_once (lock_a); } } } -boost::optional nano::election::try_confirm (nano::block_hash const & hash) +void nano::election::try_confirm (nano::block_hash const & hash) { - boost::optional status_type; nano::unique_lock election_lock{ mutex }; auto winner = status.winner; if (winner && winner->hash () == hash) { - // Determine if the block was confirmed explicitly via election confirmation or implicitly via confirmation height if (!confirmed_locked ()) { - confirm_once (election_lock, nano::election_status_type::active_confirmation_height); - status_type = nano::election_status_type::active_confirmation_height; - } - else - { - status_type = nano::election_status_type::active_confirmed_quorum; + confirm_once (election_lock); } } - else - { - status_type = boost::optional{}; - } - return status_type; -} - -nano::election_status nano::election::set_status_type (nano::election_status_type status_type) -{ - nano::unique_lock election_lk{ mutex }; - status.type = status_type; - status.confirmation_request_count = confirmation_request_count; - nano::election_status status_l{ status }; - election_lk.unlock (); - return status_l; } std::shared_ptr nano::election::find (nano::block_hash const & hash_a) const @@ -709,11 +686,11 @@ bool nano::election::replace_by_weight (nano::unique_lock & lock_a, return replaced; } -void nano::election::force_confirm (nano::election_status_type type_a) +void nano::election::force_confirm () { release_assert (node.network_params.network.is_dev_network ()); nano::unique_lock lock{ mutex }; - confirm_once (lock, type_a); + confirm_once (lock); } std::unordered_map> nano::election::blocks () const diff --git a/nano/node/election.hpp b/nano/node/election.hpp index 63e75827..59cf2ea9 100644 --- a/nano/node/election.hpp +++ b/nano/node/election.hpp @@ -146,8 +146,7 @@ public: // Interface bool publish (std::shared_ptr const & block_a); // Confirm this block if quorum is met void confirm_if_quorum (nano::unique_lock &); - boost::optional try_confirm (nano::block_hash const & hash); - nano::election_status set_status_type (nano::election_status_type status_type); + void try_confirm (nano::block_hash const & hash); /** * Broadcasts vote for the current winner of this election @@ -173,7 +172,7 @@ private: bool confirmed_locked () const; nano::election_extended_status current_status_locked () const; // lock_a does not own the mutex on return - void confirm_once (nano::unique_lock & lock_a, nano::election_status_type = nano::election_status_type::active_confirmed_quorum); + void confirm_once (nano::unique_lock & lock_a); bool broadcast_block_predicate () const; void broadcast_block (nano::confirmation_solicitor &); void send_confirm_req (nano::confirmation_solicitor &); @@ -217,7 +216,7 @@ private: // Constants friend class confirmation_solicitor; public: // Only used in tests - void force_confirm (nano::election_status_type = nano::election_status_type::active_confirmed_quorum); + void force_confirm (); std::unordered_map votes () const; std::unordered_map> blocks () const;