From 89a19deb164b6dc9481f9f7c7ad91be96ba1aef1 Mon Sep 17 00:00:00 2001 From: Guilherme Lawless Date: Mon, 27 Jan 2020 18:56:36 +0000 Subject: [PATCH] Additional ledger stats (#2515) --- nano/lib/stats.cpp | 9 +++++++++ nano/lib/stats.hpp | 3 +++ nano/node/blockprocessor.cpp | 5 ++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/nano/lib/stats.cpp b/nano/lib/stats.cpp index 281c63f223..32953fcbfc 100644 --- a/nano/lib/stats.cpp +++ b/nano/lib/stats.cpp @@ -511,6 +511,15 @@ std::string nano::stat::detail_to_string (uint32_t key) case nano::stat::detail::fork: res = "fork"; break; + case nano::stat::detail::old: + res = "old"; + break; + case nano::stat::detail::gap_previous: + res = "gap_previous"; + break; + case nano::stat::detail::gap_source: + res = "gap_source"; + break; case nano::stat::detail::frontier_confirmation_failed: res = "frontier_confirmation_failed"; break; diff --git a/nano/lib/stats.hpp b/nano/lib/stats.hpp index 076f27c83b..86836b4cf4 100644 --- a/nano/lib/stats.hpp +++ b/nano/lib/stats.hpp @@ -226,6 +226,9 @@ class stat final state_block, epoch_block, fork, + old, + gap_previous, + gap_source, // message specific keepalive, diff --git a/nano/node/blockprocessor.cpp b/nano/node/blockprocessor.cpp index 2b9db6eac8..fa08451fc3 100644 --- a/nano/node/blockprocessor.cpp +++ b/nano/node/blockprocessor.cpp @@ -420,6 +420,7 @@ nano::process_return nano::block_processor::process_one (nano::write_transaction } node.gap_cache.add (hash); + node.stats.inc (nano::stat::type::ledger, nano::stat::detail::gap_previous); break; } case nano::process_result::gap_source: @@ -443,6 +444,7 @@ nano::process_return nano::block_processor::process_one (nano::write_transaction } node.gap_cache.add (hash); + node.stats.inc (nano::stat::type::ledger, nano::stat::detail::gap_source); break; } case nano::process_result::old: @@ -456,6 +458,7 @@ nano::process_return nano::block_processor::process_one (nano::write_transaction queue_unchecked (transaction_a, hash); } node.active.update_difficulty (info_a.block, transaction_a); + node.stats.inc (nano::stat::type::ledger, nano::stat::detail::old); break; } case nano::process_result::bad_signature: @@ -486,7 +489,7 @@ nano::process_return nano::block_processor::process_one (nano::write_transaction case nano::process_result::fork: { node.process_fork (transaction_a, info_a.block); - node.stats.inc (nano::stat::type::ledger, nano::stat::detail::fork, nano::stat::dir::in); + node.stats.inc (nano::stat::type::ledger, nano::stat::detail::fork); if (node.config.logging.ledger_logging ()) { node.logger.try_log (boost::str (boost::format ("Fork for: %1% root: %2%") % hash.to_string () % info_a.block->root ().to_string ()));