Log election activity
This commit is contained in:
parent
38edde0ffb
commit
24776147b2
4 changed files with 52 additions and 14 deletions
|
|
@ -284,6 +284,7 @@ enum class detail
|
||||||
broadcast_block_repeat,
|
broadcast_block_repeat,
|
||||||
confirm_once,
|
confirm_once,
|
||||||
confirm_once_failed,
|
confirm_once_failed,
|
||||||
|
confirmation_request,
|
||||||
|
|
||||||
// election types
|
// election types
|
||||||
manual,
|
manual,
|
||||||
|
|
|
||||||
|
|
@ -168,12 +168,24 @@ std::chrono::milliseconds nano::election::confirm_req_time () const
|
||||||
|
|
||||||
void nano::election::send_confirm_req (nano::confirmation_solicitor & solicitor_a)
|
void nano::election::send_confirm_req (nano::confirmation_solicitor & solicitor_a)
|
||||||
{
|
{
|
||||||
|
debug_assert (!mutex.try_lock ());
|
||||||
|
|
||||||
if (confirm_req_time () < (std::chrono::steady_clock::now () - last_req))
|
if (confirm_req_time () < (std::chrono::steady_clock::now () - last_req))
|
||||||
{
|
{
|
||||||
if (!solicitor_a.add (*this))
|
if (!solicitor_a.add (*this))
|
||||||
{
|
{
|
||||||
last_req = std::chrono::steady_clock::now ();
|
last_req = std::chrono::steady_clock::now ();
|
||||||
++confirmation_request_count;
|
++confirmation_request_count;
|
||||||
|
|
||||||
|
node.stats.inc (nano::stat::type::election, nano::stat::detail::confirmation_request);
|
||||||
|
node.logger.debug (nano::log::type::election, "Sent confirmation request for root: {} (behavior: {}, state: {}, voters: {}, blocks: {}, duration: {}ms, confirmation requests: {})",
|
||||||
|
qualified_root.to_string (),
|
||||||
|
to_string (behavior_m),
|
||||||
|
to_string (state_m),
|
||||||
|
status.voter_count,
|
||||||
|
status.block_count,
|
||||||
|
duration ().count (),
|
||||||
|
confirmation_request_count.load ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -196,9 +208,10 @@ bool nano::election::transition_priority ()
|
||||||
behavior_m = nano::election_behavior::priority;
|
behavior_m = nano::election_behavior::priority;
|
||||||
last_vote = std::chrono::steady_clock::time_point{}; // allow new outgoing votes immediately
|
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: {}",
|
node.logger.debug (nano::log::type::election, "Transitioned election behavior to priority from {} for root: {} (duration: {}ms)",
|
||||||
to_string (behavior_m),
|
to_string (behavior_m),
|
||||||
qualified_root.to_string ());
|
qualified_root.to_string (),
|
||||||
|
duration ().count ());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -252,10 +265,18 @@ void nano::election::broadcast_block (nano::confirmation_solicitor & solicitor_a
|
||||||
{
|
{
|
||||||
if (!solicitor_a.broadcast (*this))
|
if (!solicitor_a.broadcast (*this))
|
||||||
{
|
{
|
||||||
node.stats.inc (nano::stat::type::election, last_block_hash.is_zero () ? nano::stat::detail::broadcast_block_initial : nano::stat::detail::broadcast_block_repeat);
|
|
||||||
|
|
||||||
last_block = std::chrono::steady_clock::now ();
|
last_block = std::chrono::steady_clock::now ();
|
||||||
last_block_hash = status.winner->hash ();
|
last_block_hash = status.winner->hash ();
|
||||||
|
|
||||||
|
node.stats.inc (nano::stat::type::election, last_block_hash.is_zero () ? nano::stat::detail::broadcast_block_initial : nano::stat::detail::broadcast_block_repeat);
|
||||||
|
node.logger.debug (nano::log::type::election, "Broadcasting current winner: {} for root: {} (behavior: {}, state: {}, voters: {}, blocks: {}, duration: {}ms)",
|
||||||
|
status.winner->hash ().to_string (),
|
||||||
|
qualified_root.to_string (),
|
||||||
|
to_string (behavior_m),
|
||||||
|
to_string (state_m),
|
||||||
|
status.voter_count,
|
||||||
|
status.block_count,
|
||||||
|
duration ().count ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,16 +11,6 @@
|
||||||
|
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
nano::stat::detail nano::to_stat_detail (nano::vote_code code)
|
|
||||||
{
|
|
||||||
return nano::enum_util::cast<nano::stat::detail> (code);
|
|
||||||
}
|
|
||||||
|
|
||||||
nano::stat::detail nano::to_stat_detail (nano::vote_source source)
|
|
||||||
{
|
|
||||||
return nano::enum_util::cast<nano::stat::detail> (source);
|
|
||||||
}
|
|
||||||
|
|
||||||
nano::vote_router::vote_router (nano::vote_cache & vote_cache_a, nano::recently_confirmed_cache & recently_confirmed_a) :
|
nano::vote_router::vote_router (nano::vote_cache & vote_cache_a, nano::recently_confirmed_cache & recently_confirmed_a) :
|
||||||
vote_cache{ vote_cache_a },
|
vote_cache{ vote_cache_a },
|
||||||
recently_confirmed{ recently_confirmed_a }
|
recently_confirmed{ recently_confirmed_a }
|
||||||
|
|
@ -201,3 +191,27 @@ nano::container_info nano::vote_router::container_info () const
|
||||||
info.put ("elections", elections);
|
info.put ("elections", elections);
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
nano::stat::detail nano::to_stat_detail (nano::vote_code code)
|
||||||
|
{
|
||||||
|
return nano::enum_util::cast<nano::stat::detail> (code);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string_view nano::to_string (nano::vote_code code)
|
||||||
|
{
|
||||||
|
return nano::enum_util::name (code);
|
||||||
|
}
|
||||||
|
|
||||||
|
nano::stat::detail nano::to_stat_detail (nano::vote_source source)
|
||||||
|
{
|
||||||
|
return nano::enum_util::cast<nano::stat::detail> (source);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string_view nano::to_string (nano::vote_source source)
|
||||||
|
{
|
||||||
|
return nano::enum_util::name (source);
|
||||||
|
}
|
||||||
|
|
@ -21,6 +21,7 @@ enum class vote_code
|
||||||
};
|
};
|
||||||
|
|
||||||
nano::stat::detail to_stat_detail (vote_code);
|
nano::stat::detail to_stat_detail (vote_code);
|
||||||
|
std::string_view to_string (vote_code);
|
||||||
|
|
||||||
enum class vote_source
|
enum class vote_source
|
||||||
{
|
{
|
||||||
|
|
@ -30,6 +31,7 @@ enum class vote_source
|
||||||
};
|
};
|
||||||
|
|
||||||
nano::stat::detail to_stat_detail (vote_source);
|
nano::stat::detail to_stat_detail (vote_source);
|
||||||
|
std::string_view to_string (vote_source);
|
||||||
|
|
||||||
// This class routes votes to their associated election
|
// This class routes votes to their associated election
|
||||||
// This class holds a weak_ptr as this container does not own the elections
|
// This class holds a weak_ptr as this container does not own the elections
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue