Skip to content

Commit

Permalink
Additional ledger stats (#2515)
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhermelawless authored Jan 27, 2020
1 parent f8888f6 commit 89a19de
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
9 changes: 9 additions & 0 deletions nano/lib/stats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions nano/lib/stats.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,9 @@ class stat final
state_block,
epoch_block,
fork,
old,
gap_previous,
gap_source,

// message specific
keepalive,
Expand Down
5 changes: 4 additions & 1 deletion nano/node/blockprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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 ()));
Expand Down

0 comments on commit 89a19de

Please sign in to comment.