 |
Bitcoin Core
22.99.0
P2P Digital Currency
|
Go to the documentation of this file.
5 #ifndef BITCOIN_NODE_BLOCKSTORAGE_H
6 #define BITCOIN_NODE_BLOCKSTORAGE_H
55 typedef std::unordered_map<uint256, CBlockIndex*, BlockHasher>
BlockMap;
74 void FlushBlockFile(
bool fFinalize =
false,
bool finalize_undo =
false);
97 void FindFilesToPrune(std::set<int>& setFilesToPrune, uint64_t nPruneAfterHeight,
int chain_tip_height,
int prune_height,
bool is_ibd);
194 #endif // BITCOIN_NODE_BLOCKSTORAGE_H
bool m_check_for_pruning
Global flag to indicate we should check to see if there are block/undo files that should be deleted.
std::vector< CBlockFileInfo > m_blockfile_info
bool fPruneMode
True if we're running in -prune mode.
bool IsBlockPruned(const CBlockIndex *pblockindex) EXCLUSIVE_LOCKS_REQUIRED(voi CleanupBlockRevFiles)()
Check whether the block associated with this index entry is pruned or not.
static const unsigned int UNDOFILE_CHUNK_SIZE
The pre-allocation chunk size for rev?????.dat files (since 0.8)
CBlockIndex * LookupBlockIndex(const uint256 &hash) const EXCLUSIVE_LOCKS_REQUIRED(cs_main)
void FlushUndoFile(int block_file, bool finalize=false)
BlockMap m_block_index GUARDED_BY(cs_main)
bool operator()(const CBlockIndex *pa, const CBlockIndex *pb) const
bool FindBlockPos(FlatFilePos &pos, unsigned int nAddSize, unsigned int nHeight, CChain &active_chain, uint64_t nTime, bool fKnown)
uint64_t CalculateCurrentUsage()
Calculate the amount of disk space the block & undo files currently use.
uint64_t nPruneTarget
Number of MiB of block files that we're trying to stay below.
void PruneOneBlockFile(const int fileNumber) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Mark one block file as pruned (modify associated database entries)
bool ReadRawBlockFromDisk(std::vector< uint8_t > &block, const FlatFilePos &pos, const CMessageHeader::MessageStartChars &message_start)
bool fHavePruned
Pruning-related variables and constants.
std::set< int > m_dirty_fileinfo
Dirty block file entries.
void FindFilesToPrune(std::set< int > &setFilesToPrune, uint64_t nPruneAfterHeight, int chain_tip_height, int prune_height, bool is_ibd)
Prune block and undo files (blk???.dat and rev???.dat) so that the disk space used is less than a use...
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system.
std::atomic_bool fImporting
void ThreadImport(ChainstateManager &chainman, std::vector< fs::path > vImportFiles, const ArgsManager &args)
static const unsigned int BLOCKFILE_CHUNK_SIZE
The pre-allocation chunk size for blk?????.dat files (since 0.8)
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
bool ReadBlockFromDisk(CBlock &block, const FlatFilePos &pos, const Consensus::Params &consensusParams)
Functions for disk access for blocks.
bool IsBlockPruned(const CBlockIndex *pblockindex)
void FindFilesToPruneManual(std::set< int > &setFilesToPrune, int nManualPruneHeight, int chain_tip_height)
bool UndoReadFromDisk(CBlockUndo &blockundo, const CBlockIndex *pindex)
Parameters that influence chain consensus.
bool WriteUndoDataForBlock(const CBlockUndo &blockundo, BlockValidationState &state, CBlockIndex *pindex, const CChainParams &chainparams) EXCLUSIVE_LOCKS_REQUIRED(FlatFilePo SaveBlockToDisk)(const CBlock &block, int nHeight, CChain &active_chain, const CChainParams &chainparams, const FlatFilePos *dbp)
Store block on disk.
Maintains a tree of blocks (stored in m_block_index) which is consulted to determine where the most-w...
std::atomic_bool fReindex
Transaction validation functions.
fs::path GetBlockPosFilename(const FlatFilePos &pos)
Translation to a filesystem path.
std::unordered_map< uint256, CBlockIndex *, BlockHasher > BlockMap
CBlockIndex * AddToBlockIndex(const CBlockHeader &block) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
bool FindUndoPos(BlockValidationState &state, int nFile, FlatFilePos &pos, unsigned int nAddSize)
FILE * OpenBlockFile(const FlatFilePos &pos, bool fReadOnly)
Open a block file (blk?????.dat)
void Unload() EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Clear all data members.
bool WriteBlockIndexDB() EXCLUSIVE_LOCKS_REQUIRED(bool LoadBlockIndexDB(ChainstateManager &chainman) EXCLUSIVE_LOCKS_REQUIRED(bool LoadBlockIndex(const Consensus::Params &consensus_params, ChainstateManager &chainman) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Load the blocktree off disk and into memory.
CChainState stores and provides an API to update our local knowledge of the current best chain.
static const unsigned int MAX_BLOCKFILE_SIZE
The maximum size of a blk?????.dat file (since 0.8)
Provides an interface for creating and interacting with one or two chainstates: an IBD chainstate gen...
void FlushBlockFile(bool fFinalize=false, bool finalize_undo=false)
CBlockIndex * InsertBlockIndex(const uint256 &hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Create a new block index entry for a given block hash.
static constexpr bool DEFAULT_STOPAFTERBLOCKIMPORT
An in-memory indexed chain of blocks.
#define EXCLUSIVE_LOCKS_REQUIRED(...)
const CChainParams & Params()
Return the currently selected parameters.
CBlockFileInfo * GetBlockFileInfo(size_t n)
Get block file info entry for one block file.
RecursiveMutex cs_LastBlockFile
The block chain is a tree shaped structure starting with the genesis block at the root,...
std::set< CBlockIndex * > m_dirty_blockindex
Dirty block index entries.
CBlockIndex * GetLastCheckpoint(const CCheckpointData &data) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Returns last CBlockIndex* that is a checkpoint.
std::multimap< CBlockIndex *, CBlockIndex * > m_blocks_unlinked
All pairs A->B, where A (or one of its ancestors) misses transactions, but B has transactions.
Undo information for a CBlock.
void UnlinkPrunedFiles(const std::set< int > &setFilesToPrune)
Actually unlink the specified files.