Maintains a tree of blocks (stored in m_block_index) which is consulted to determine where the most‐work tip is.
Synopsis
Declared in <node/blockstorage.h>
class BlockManager;
Description
This data is used mostly in Chainstate ‐ information about, e.g., candidate tips is not maintained here.
Type Aliases
Name |
Description |
Options controlling block storage behavior. |
|
Result of a raw block read: the bytes on success, or a ReadRawError on failure. |
Member Functions
Name |
Description |
|
Construct a block manager. |
Add a block header to the in‐memory block index, updating the best header. |
|
Record a block whose ancestor is still missing transaction data. |
|
Calculate the amount of disk space the block & undo files currently use |
|
Check if all blocks in the [upper_block, lower_block]range have data available as defined by the status mask. The caller is responsible for ensuring that lower_block is an ancestor of upper_block (part of the same chain). |
|
Remove leftover block and undo files that no longer belong to the block tree. |
|
Delete a prune lock identified by its name. Returns true if the lock existed. |
|
Return pointers to every block index entry currently held in memory. |
|
Get block file info entry for one block file |
|
Translation to a filesystem path |
|
Returns the earliest block with specified |
|
Attempt to stay below this number of bytes of block files. |
|
Create a new block index entry for a given block hash |
|
Check whether the block associated with this index entry is pruned or not. |
|
Whether running in ‐prune mode. |
|
Load the block index from the database into memory. |
|
Report whether blocks are still being imported or indexed. |
|
Look up a block index entry by hash. |
|
Open a block file (blk?????.dat) |
|
Mark one block file as pruned (modify associated database entries) |
|
|
|
Read a block's undo data from disk using its block index entry. |
|
Read the raw, still‐serialized bytes of a block (or a sub‐range) from disk. |
|
Remove any pruned block & undo files that are still on disk. This could happen on some systems if the file was still being read while unlinked, or if we crash before unlinking. |
|
Actually unlink the specified files |
|
Update blockfile info while processing a block during reindex. The block must be available on disk. |
|
Create or update a prune lock identified by its name |
|
Store block on disk and update block file statistics. |
|
Write the dirty block index and block‐file entries to the database. |
|
Write a block's undo data to disk and record it in the block index. |
Data Members
Name |
Description |
The in‐memory block tree, mapping each block hash to its index entry. |
|
Handle to the on‐disk block index database (blocks/index/). |
|
Whether all blockfiles have been added to the block tree database. Normally true, but set to false when a reindex is requested and the database is wiped. The value is persisted in the database across restarts and will be false until reindexing completes. |
|
All pairs A‐>B, where A (or one of its ancestors) misses transactions, but B has transactions. |
|
True if any block files have ever been pruned. |
|
Whether blocks are currently being imported from disk. |
|
Interrupt used to abort long‐running block‐loading operations. |
|
The height of the base block of an assumeutxo snapshot, if one is in use. |
Static Data Members
Name |
Description |
Sentinel prune target meaning pruning is manual rather than size‐based. |
Protected Data Members
Name |
Description |
In‐memory statistics for each block file, indexed by file number. |
|
Dirty block index entries. |
|
Dirty block file entries. |
Friends
Name |
Description |
Interface for managing multiple Chainstate objects, where each chainstate is associated with chainstate* subdirectory in the data directory and contains a database of UTXOs existing at a different point in history. (See the Chainstate class for more information.) |
|
Chainstate stores and provides an API to update our local knowledge of the current best chain. |
Non-Member Functions
Name |
Description |
Check that a block's data (and optionally undo data) is available on disk. |
|
Return height of highest block that has been pruned, or std::nullopt if no blocks have been pruned |
|
Block description to JSON |
Created with MrDocs