Base class for the node's optional block‐chain indexes.
Synopsis
Declared in <index/base.h>
class BaseIndex
: public CValidationInterface
Base Classes
Name |
Description |
Implement this to subscribe to events generated in validation and mempool |
Member Functions
Name |
Description |
|
Construct the index over a given chain interface. |
|
Destructor interrupts sync thread if running and blocks until it exits. |
Blocks the current thread until the index is caught up to the current state of the block chain. This only blocks if the index has gotten in sync once and only needs to process blocks in the ValidationInterface queue. If the index is catching up from far behind, this method does not block and immediately returns false. |
|
|
Return custom notification options for index. |
Get the name of the index for display in logs. |
|
Get a summary of the index and its state. |
|
Initializes the sync state and registers the instance to the validation interface so that it stays in sync with blockchain updates. |
|
Signal the background sync thread to stop as soon as possible. |
|
Starts the initial sync process on a background thread. |
|
Stops the instance from staying in sync with blockchain updates. |
|
index_sync Sync the index with the block index starting from the current best block. Intended to be run in its own thread, m_thread_sync, and can be interrupted with m_interrupt. Once the index gets in sync, the m_synced flag is set and the BlockConnected ValidationInterface callback takes over and the sync thread exits. |
Protected Types
Name |
Description |
The database stores a block locator of the chain the database is synced to so that the index can efficiently determine the point it last stopped at. A locator is used instead of a simple hash of the chain tip because blocks and block index entries may not be flushed to disk until after this database is updated. |
Protected Member Functions
Name |
Description |
|
Notifies listeners any time the block chain tip changes, synchronously. |
|
Notifies listeners of a block validation result. If the provided BlockValidationState IsValid, the provided block is guaranteed to be the current best block at the time the callback was generated (not necessarily now). |
|
Handle a newly connected block by appending it to the index. |
|
Notifies listeners of a block being disconnected Provides the block that was disconnected. |
|
Handle a chainstate flush by committing the index up to the flushed point. |
|
Write update index entries for a newly connected block. |
|
Virtual method called internally by Commit that can be overridden to atomically commit more index state. |
|
Initialize internal state from the database and block index. |
|
Rewind index by one block during a chain reorg. |
|
Access the database backing this index. |
|
Notifies listeners of transactions removed from the mempool as as a result of new block being connected. MempoolTransactionsRemovedForBlock will be fired before BlockConnected. |
|
Notifies listeners that a block which builds directly on our current tip has been received and connected to the headers tree, though not validated yet. |
Update the internal best block index as well as the prune lock. |
|
|
Notifies listeners of a transaction having been added to mempool. |
|
Notifies listeners of a transaction leaving mempool. |
|
Notifies listeners when the block chain tip advances. |
Protected Data Members
Name |
Description |
Interface used to query the blockchain the index tracks. |
|
Chainstate the index reads blocks from (not owned). |
|
Human‐readable name of the index. |
|
Name given to the background sync thread. |
Derived Classes
Name |
Description |
BlockFilterIndex is used to store and retrieve block filters, hashes, and headers for a range of blocks by height. An index is constructed for each supported filter type with its own database (ie. filter data for different types are stored in separate databases). |
|
CoinStatsIndex maintains statistics on the UTXO set. |
|
TxIndex is used to look up transactions included in the blockchain by hash. The index is written to a LevelDB database and records the block sequence number and serialized block offset of each transaction by transaction hash. |
|
TxoSpenderIndex is used to look up which transaction spent a given output. The index is written to a LevelDB database and, for each input of each transaction in a block, records the outpoint that is spent and the hash of the spending transaction. |
Created with MrDocs