indexes, refactor: Remove remaining CBlockIndex* uses in index Rewind methods

Move ReadBlock code from CoinStatsIndex::CustomRewind to BaseIndex::Rewind

Move ReadUndo code from CoinStatsIndex::ReverseBlock to BaseIndex::Rewind

This commit does change behavior slightly. Since the new CustomRemove
methods only take a single block at a time instead of a range of
disconnected blocks, when they call CopyHeightIndexToHashIndex they will
now do an index seek for each removed block instead of only seeking once
to the height of the earliest removed block. Seeking instead of scanning
is a little worse for performance if there is a >1 block reorg, but
probably not noticeable unless the reorg is very deep.
This commit is contained in:
Ryan Ofsky
2022-01-23 23:20:41 -05:00
committed by furszy
parent 0a248708dc
commit 6f1392cc42
7 changed files with 71 additions and 50 deletions

View File

@@ -327,6 +327,15 @@ public:
virtual void chainStateFlushed(ChainstateRole role, const CBlockLocator& locator) {}
};
//! Options specifying which chain notifications are required.
struct NotifyOptions
{
//! Include block data with block disconnected notifications.
bool disconnect_data = false;
//! Include undo data with block disconnected notifications.
bool disconnect_undo_data = false;
};
//! Register handler for notifications.
virtual std::unique_ptr<Handler> handleNotifications(std::shared_ptr<Notifications> notifications) = 0;