Skip to content

Commit

Permalink
Add rolled back event
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev committed Feb 9, 2024
1 parent 124421b commit 162fee5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion nano/lib/stats_enums.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ enum class detail : uint8_t
old,
gap_previous,
gap_source,
rollback,
rollback_failed,
progress,
bad_signature,
Expand All @@ -112,7 +113,7 @@ enum class detail : uint8_t
representative_mismatch,
block_position,

// blockprocessor result
// block source
live,
bootstrap,
bootstrap_legacy,
Expand Down
4 changes: 4 additions & 0 deletions nano/node/blockprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,15 @@ void nano::block_processor::rollback_competitor (store::write_transaction const
}
else
{
node.stats.inc (nano::stat::type::ledger, nano::stat::detail::rollback);
node.logger.debug (nano::log::type::blockprocessor, "Blocks rolled back: {}", rollback_list.size ());
}

// Deleting from votes cache, stop active transaction
for (auto & i : rollback_list)
{
rolled_back.notify (i);

node.history.erase (i->root ());
// Stop all rolled back active transactions except initial
if (i->hash () != successor->hash ())
Expand Down
1 change: 1 addition & 0 deletions nano/node/blockprocessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class block_processor final
// The batch observer feeds the processed observer
nano::observer_set<nano::process_return const &, std::shared_ptr<nano::block> const &, context const &> block_processed;
nano::observer_set<processed_batch_t const &> batch_processed;
nano::observer_set<std::shared_ptr<nano::block> const &> rolled_back;

private:
// Roll back block in the ledger that conflicts with 'block'
Expand Down

0 comments on commit 162fee5

Please sign in to comment.