diff --git a/nano/node/election.cpp b/nano/node/election.cpp index 10425115..a3d07b9a 100644 --- a/nano/node/election.cpp +++ b/nano/node/election.cpp @@ -215,7 +215,10 @@ bool nano::election::transition_time (nano::confirmation_solicitor & solicitor_a result = true; state_change (state_m.load (), nano::election::state_t::expired_unconfirmed); status.type = nano::election_status_type::stopped; - log_votes (tally ()); + if (node.config.logging.election_expiration_tally_logging ()) + { + log_votes (tally (), "Election expired: "); + } } return result; } @@ -276,7 +279,7 @@ void nano::election::confirm_if_quorum () } if (have_quorum (tally_l, sum)) { - if (node.config.logging.vote_logging () || blocks.size () > 1) + if (node.config.logging.vote_logging () || (node.config.logging.election_fork_tally_logging () && blocks.size () > 1)) { log_votes (tally_l); } @@ -284,11 +287,11 @@ void nano::election::confirm_if_quorum () } } -void nano::election::log_votes (nano::tally_t const & tally_a) const +void nano::election::log_votes (nano::tally_t const & tally_a, std::string const & prefix_a) const { std::stringstream tally; std::string line_end (node.config.logging.single_line_record () ? "\t" : "\n"); - tally << boost::str (boost::format ("%1%Vote tally for root %2%") % line_end % root.to_string ()); + tally << boost::str (boost::format ("%1%%2%Vote tally for root %3%") % prefix_a % line_end % root.to_string ()); for (auto i (tally_a.begin ()), n (tally_a.end ()); i != n; ++i) { tally << boost::str (boost::format ("%1%Block %2% weight %3%") % line_end % i->second->hash ().to_string () % i->first.convert_to ()); diff --git a/nano/node/election.hpp b/nano/node/election.hpp index 1882bef1..03937fcb 100644 --- a/nano/node/election.hpp +++ b/nano/node/election.hpp @@ -75,7 +75,7 @@ public: void confirm_once (nano::election_status_type = nano::election_status_type::active_confirmed_quorum); // Confirm this block if quorum is met void confirm_if_quorum (); - void log_votes (nano::tally_t const &) const; + void log_votes (nano::tally_t const &, std::string const & = "") const; bool publish (std::shared_ptr block_a); size_t last_votes_size (); size_t insert_inactive_votes_cache (nano::block_hash const &); diff --git a/nano/node/logging.cpp b/nano/node/logging.cpp index 6115d0b2..1644cf5e 100644 --- a/nano/node/logging.cpp +++ b/nano/node/logging.cpp @@ -149,6 +149,8 @@ nano::error nano::logging::serialize_toml (nano::tomlconfig & toml) const toml.put ("ledger", ledger_logging_value, "Log ledger related messages.\ntype:bool"); toml.put ("ledger_duplicate", ledger_duplicate_logging_value, "Log when a duplicate block is attempted inserted into the ledger.\ntype:bool"); toml.put ("vote", vote_logging_value, "Vote logging. Enabling this option leads to a high volume.\nof log messages which may affect node performance.\ntype:bool"); + toml.put ("election_expiration", election_expiration_tally_logging_value, "Log election tally on expiration.\ntype:bool"); + toml.put ("election_fork", election_fork_tally_logging_value, "Log election tally when more than one block is seen.\ntype:bool"); toml.put ("network", network_logging_value, "Log network related messages.\ntype:bool"); toml.put ("network_timeout", network_timeout_logging_value, "Log TCP timeouts.\ntype:bool"); toml.put ("network_message", network_message_logging_value, "Log network errors and message details.\ntype:bool"); @@ -182,6 +184,8 @@ nano::error nano::logging::deserialize_toml (nano::tomlconfig & toml) toml.get ("ledger", ledger_logging_value); toml.get ("ledger_duplicate", ledger_duplicate_logging_value); toml.get ("vote", vote_logging_value); + toml.get ("election_expiration", election_expiration_tally_logging_value); + toml.get ("election_fork", election_fork_tally_logging_value); toml.get ("network", network_logging_value); toml.get ("network_timeout", network_timeout_logging_value); toml.get ("network_message", network_message_logging_value); @@ -314,6 +318,16 @@ bool nano::logging::vote_logging () const return vote_logging_value; } +bool nano::logging::election_expiration_tally_logging () const +{ + return election_expiration_tally_logging_value; +} + +bool nano::logging::election_fork_tally_logging () const +{ + return election_fork_tally_logging_value; +} + bool nano::logging::network_logging () const { return network_logging_value; diff --git a/nano/node/logging.hpp b/nano/node/logging.hpp index c52290b0..074a13ee 100644 --- a/nano/node/logging.hpp +++ b/nano/node/logging.hpp @@ -45,6 +45,8 @@ public: bool ledger_logging () const; bool ledger_duplicate_logging () const; bool vote_logging () const; + bool election_fork_tally_logging () const; + bool election_expiration_tally_logging () const; bool network_logging () const; bool network_timeout_logging () const; bool network_message_logging () const; @@ -70,6 +72,8 @@ public: bool ledger_logging_value{ false }; bool ledger_duplicate_logging_value{ false }; bool vote_logging_value{ false }; + bool election_fork_tally_logging_value{ false }; + bool election_expiration_tally_logging_value{ false }; bool network_logging_value{ true }; bool network_timeout_logging_value{ false }; bool network_message_logging_value{ false };