[#CoinStatsIndex] = CoinStatsIndex :mrdocs: CoinStatsIndex maintains statistics on the UTXO set. == Synopsis Declared in `<index/coinstatsindex.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- class CoinStatsIndex final : public xref:BaseIndex.adoc[BaseIndex] ---- == Base Classes [cols="1,4"] |=== | Name| Description | `xref:BaseIndex.adoc[BaseIndex]` | Base class for the node's optional block‐chain indexes. |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:CoinStatsIndex/2constructor.adoc[`CoinStatsIndex`] [.small]#[constructor]# | Constructs the index, which becomes available to be queried. | xref:BaseIndex/BlockUntilSyncedToCurrentChain.adoc[`BlockUntilSyncedToCurrentChain`] | 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. | xref:CoinStatsIndex/CustomOptions.adoc[`CustomOptions`] [.small]#[virtual]# | Request notifications needed to keep UTXO statistics current. | xref:BaseIndex/GetName.adoc[`GetName`] | Get the name of the index for display in logs. | xref:BaseIndex/GetSummary.adoc[`GetSummary`] | Get a summary of the index and its state. | xref:BaseIndex/Init.adoc[`Init`] | Initializes the sync state and registers the instance to the validation interface so that it stays in sync with blockchain updates. | xref:BaseIndex/Interrupt.adoc[`Interrupt`] | Signal the background sync thread to stop as soon as possible. | xref:CoinStatsIndex/LookUpStats.adoc[`LookUpStats`] | Look up UTXO set statistics for a specific block. | xref:BaseIndex/StartBackgroundSync.adoc[`StartBackgroundSync`] | Starts the initial sync process on a background thread. | xref:BaseIndex/Stop.adoc[`Stop`] | Stops the instance from staying in sync with blockchain updates. | xref:BaseIndex/Sync.adoc[`Sync`] | 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 [cols="1,4"] |=== | Name| Description | xref:BaseIndex/DB.adoc[`DB`] | 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 [cols="1,4"] |=== | Name| Description | xref:CValidationInterface/ActiveTipChange.adoc[`ActiveTipChange`] [.small]#[virtual]# | Notifies listeners any time the block chain tip changes, synchronously. | xref:CValidationInterface/BlockChecked.adoc[`BlockChecked`] [.small]#[virtual]# | 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). | xref:BaseIndex/BlockConnected.adoc[`BlockConnected`] [.small]#[virtual]# | Handle a newly connected block by appending it to the index. | xref:CValidationInterface/BlockDisconnected.adoc[`BlockDisconnected`] [.small]#[virtual]# | Notifies listeners of a block being disconnected Provides the block that was disconnected. | xref:BaseIndex/ChainStateFlushed.adoc[`ChainStateFlushed`] [.small]#[virtual]# | Handle a chainstate flush by committing the index up to the flushed point. | xref:CoinStatsIndex/CustomAppend.adoc[`CustomAppend`] [.small]#[virtual]# | Update the statistics for a newly connected block. | xref:CoinStatsIndex/CustomCommit.adoc[`CustomCommit`] [.small]#[virtual]# | Persist the current UTXO statistics alongside the index commit. | xref:CoinStatsIndex/CustomInit.adoc[`CustomInit`] [.small]#[virtual]# | Restore the running UTXO statistics from the database on startup. | xref:CoinStatsIndex/CustomRemove.adoc[`CustomRemove`] [.small]#[virtual]# | Roll back the statistics for a block being disconnected. | xref:CoinStatsIndex/GetDB.adoc[`GetDB`] [.small]#[virtual]# | Access the database backing this index. | xref:CValidationInterface/MempoolTransactionsRemovedForBlock.adoc[`MempoolTransactionsRemovedForBlock`] [.small]#[virtual]# | Notifies listeners of transactions removed from the mempool as as a result of new block being connected. MempoolTransactionsRemovedForBlock will be fired before BlockConnected. | xref:CValidationInterface/NewPoWValidBlock.adoc[`NewPoWValidBlock`] [.small]#[virtual]# | 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. | xref:BaseIndex/SetBestBlockIndex.adoc[`SetBestBlockIndex`] | Update the internal best block index as well as the prune lock. | xref:CValidationInterface/TransactionAddedToMempool.adoc[`TransactionAddedToMempool`] [.small]#[virtual]# | Notifies listeners of a transaction having been added to mempool. | xref:CValidationInterface/TransactionRemovedFromMempool.adoc[`TransactionRemovedFromMempool`] [.small]#[virtual]# | Notifies listeners of a transaction leaving mempool. | xref:CValidationInterface/UpdatedBlockTip.adoc[`UpdatedBlockTip`] [.small]#[virtual]# | Notifies listeners when the block chain tip advances. |=== == Protected Data Members [cols="1,4"] |=== | Name| Description | xref:BaseIndex/m_chain.adoc[`m_chain`] | Interface used to query the blockchain the index tracks. | xref:BaseIndex/m_chainstate.adoc[`m_chainstate`] | Chainstate the index reads blocks from (not owned). | xref:BaseIndex/m_name.adoc[`m_name`] | Human‐readable name of the index. | xref:BaseIndex/m_thread_name.adoc[`m_thread_name`] | Name given to the background sync thread. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#