![]() |
Bitcoin Core 22.99.0
P2P Digital Currency
|
#include <node/blockstorage.h>
#include <chain.h>
#include <chainparams.h>
#include <clientversion.h>
#include <consensus/validation.h>
#include <flatfile.h>
#include <fs.h>
#include <hash.h>
#include <pow.h>
#include <shutdown.h>
#include <signet.h>
#include <streams.h>
#include <undo.h>
#include <util/syscall_sandbox.h>
#include <util/system.h>
#include <validation.h>
Go to the source code of this file.
Classes | |
struct | CImportingNow |
Functions | |
std::atomic_bool | fImporting (false) |
std::atomic_bool | fReindex (false) |
static FILE * | OpenUndoFile (const FlatFilePos &pos, bool fReadOnly) |
Open an undo file (rev?????.dat) More... | |
static FlatFileSeq | BlockFileSeq () |
static FlatFileSeq | UndoFileSeq () |
bool | IsBlockPruned (const CBlockIndex *pblockindex) |
Check whether the block associated with this index entry is pruned or not. More... | |
void | CleanupBlockRevFiles () |
CBlockFileInfo * | GetBlockFileInfo (size_t n) |
Get block file info entry for one block file. More... | |
static bool | UndoWriteToDisk (const CBlockUndo &blockundo, FlatFilePos &pos, const uint256 &hashBlock, const CMessageHeader::MessageStartChars &messageStart) |
bool | UndoReadFromDisk (CBlockUndo &blockundo, const CBlockIndex *pindex) |
static void | FlushUndoFile (int block_file, bool finalize=false) |
void | FlushBlockFile (bool fFinalize=false, bool finalize_undo=false) |
uint64_t | CalculateCurrentUsage () |
Calculate the amount of disk space the block & undo files currently use. More... | |
void | UnlinkPrunedFiles (const std::set< int > &setFilesToPrune) |
Actually unlink the specified files. More... | |
FILE * | OpenBlockFile (const FlatFilePos &pos, bool fReadOnly) |
Open a block file (blk?????.dat) More... | |
fs::path | GetBlockPosFilename (const FlatFilePos &pos) |
Translation to a filesystem path. More... | |
bool | FindBlockPos (FlatFilePos &pos, unsigned int nAddSize, unsigned int nHeight, CChain &active_chain, uint64_t nTime, bool fKnown=false) |
static bool | FindUndoPos (BlockValidationState &state, int nFile, FlatFilePos &pos, unsigned int nAddSize) |
static bool | WriteBlockToDisk (const CBlock &block, FlatFilePos &pos, const CMessageHeader::MessageStartChars &messageStart) |
bool | WriteUndoDataForBlock (const CBlockUndo &blockundo, BlockValidationState &state, CBlockIndex *pindex, const CChainParams &chainparams) |
bool | ReadBlockFromDisk (CBlock &block, const FlatFilePos &pos, const Consensus::Params &consensusParams) |
Functions for disk access for blocks. More... | |
bool | ReadBlockFromDisk (CBlock &block, const CBlockIndex *pindex, const Consensus::Params &consensusParams) |
bool | ReadRawBlockFromDisk (std::vector< uint8_t > &block, const FlatFilePos &pos, const CMessageHeader::MessageStartChars &message_start) |
bool | ReadRawBlockFromDisk (std::vector< uint8_t > &block, const CBlockIndex *pindex, const CMessageHeader::MessageStartChars &message_start) |
FlatFilePos | SaveBlockToDisk (const CBlock &block, int nHeight, CChain &active_chain, const CChainParams &chainparams, const FlatFilePos *dbp) |
Store block on disk. More... | |
void | ThreadImport (ChainstateManager &chainman, std::vector< fs::path > vImportFiles, const ArgsManager &args) |
Variables | |
bool | fHavePruned = false |
Pruning-related variables and constants. More... | |
bool | fPruneMode = false |
True if we're running in -prune mode. More... | |
uint64_t | nPruneTarget = 0 |
Number of MiB of block files that we're trying to stay below. More... | |
RecursiveMutex | cs_LastBlockFile |
std::vector< CBlockFileInfo > | vinfoBlockFile |
int | nLastBlockFile = 0 |
bool | fCheckForPruning = false |
Global flag to indicate we should check to see if there are block/undo files that should be deleted. More... | |
std::set< CBlockIndex * > | setDirtyBlockIndex |
Dirty block index entries. More... | |
std::set< int > | setDirtyFileInfo |
Dirty block file entries. More... | |
|
static |
Definition at line 212 of file blockstorage.cpp.
uint64_t CalculateCurrentUsage | ( | ) |
Calculate the amount of disk space the block & undo files currently use.
Definition at line 191 of file blockstorage.cpp.
void CleanupBlockRevFiles | ( | ) |
Definition at line 61 of file blockstorage.cpp.
std::atomic_bool fImporting | ( | false | ) |
bool FindBlockPos | ( | FlatFilePos & | pos, |
unsigned int | nAddSize, | ||
unsigned int | nHeight, | ||
CChain & | active_chain, | ||
uint64_t | nTime, | ||
bool | fKnown = false |
||
) |
Definition at line 238 of file blockstorage.cpp.
|
static |
Definition at line 293 of file blockstorage.cpp.
void FlushBlockFile | ( | bool | fFinalize = false , |
bool | finalize_undo = false |
||
) |
Definition at line 179 of file blockstorage.cpp.
|
static |
Definition at line 171 of file blockstorage.cpp.
std::atomic_bool fReindex | ( | false | ) |
CBlockFileInfo * GetBlockFileInfo | ( | size_t | n | ) |
Get block file info entry for one block file.
Definition at line 103 of file blockstorage.cpp.
fs::path GetBlockPosFilename | ( | const FlatFilePos & | pos | ) |
Translation to a filesystem path.
Definition at line 233 of file blockstorage.cpp.
bool IsBlockPruned | ( | const CBlockIndex * | pblockindex | ) |
Check whether the block associated with this index entry is pruned or not.
Definition at line 50 of file blockstorage.cpp.
FILE * OpenBlockFile | ( | const FlatFilePos & | pos, |
bool | fReadOnly | ||
) |
Open a block file (blk?????.dat)
Definition at line 222 of file blockstorage.cpp.
|
static |
Open an undo file (rev?????.dat)
Definition at line 228 of file blockstorage.cpp.
bool ReadBlockFromDisk | ( | CBlock & | block, |
const CBlockIndex * | pindex, | ||
const Consensus::Params & | consensusParams | ||
) |
bool ReadBlockFromDisk | ( | CBlock & | block, |
const FlatFilePos & | pos, | ||
const Consensus::Params & | consensusParams | ||
) |
Functions for disk access for blocks.
Definition at line 367 of file blockstorage.cpp.
bool ReadRawBlockFromDisk | ( | std::vector< uint8_t > & | block, |
const CBlockIndex * | pindex, | ||
const CMessageHeader::MessageStartChars & | message_start | ||
) |
bool ReadRawBlockFromDisk | ( | std::vector< uint8_t > & | block, |
const FlatFilePos & | pos, | ||
const CMessageHeader::MessageStartChars & | message_start | ||
) |
Definition at line 411 of file blockstorage.cpp.
FlatFilePos SaveBlockToDisk | ( | const CBlock & | block, |
int | nHeight, | ||
CChain & | active_chain, | ||
const CChainParams & | chainparams, | ||
const FlatFilePos * | dbp | ||
) |
Store block on disk.
If dbp is non-nullptr, the file is known to already reside on disk
Definition at line 458 of file blockstorage.cpp.
void ThreadImport | ( | ChainstateManager & | chainman, |
std::vector< fs::path > | vImportFiles, | ||
const ArgsManager & | args | ||
) |
Definition at line 492 of file blockstorage.cpp.
|
static |
Definition at line 217 of file blockstorage.cpp.
bool UndoReadFromDisk | ( | CBlockUndo & | blockundo, |
const CBlockIndex * | pindex | ||
) |
Definition at line 139 of file blockstorage.cpp.
|
static |
Definition at line 110 of file blockstorage.cpp.
void UnlinkPrunedFiles | ( | const std::set< int > & | setFilesToPrune | ) |
Actually unlink the specified files.
Definition at line 202 of file blockstorage.cpp.
|
static |
Definition at line 315 of file blockstorage.cpp.
bool WriteUndoDataForBlock | ( | const CBlockUndo & | blockundo, |
BlockValidationState & | state, | ||
CBlockIndex * | pindex, | ||
const CChainParams & | chainparams | ||
) |
Definition at line 338 of file blockstorage.cpp.
RecursiveMutex cs_LastBlockFile |
Definition at line 30 of file blockstorage.cpp.
bool fCheckForPruning = false |
Global flag to indicate we should check to see if there are block/undo files that should be deleted.
Set on startup or if we allocate more file space when we're in prune mode
Definition at line 37 of file blockstorage.cpp.
bool fHavePruned = false |
Pruning-related variables and constants.
True if any block files have ever been pruned.
Definition at line 25 of file blockstorage.cpp.
bool fPruneMode = false |
True if we're running in -prune mode.
Definition at line 26 of file blockstorage.cpp.
int nLastBlockFile = 0 |
Definition at line 32 of file blockstorage.cpp.
uint64_t nPruneTarget = 0 |
Number of MiB of block files that we're trying to stay below.
Definition at line 27 of file blockstorage.cpp.
std::set<CBlockIndex*> setDirtyBlockIndex |
Dirty block index entries.
Definition at line 40 of file blockstorage.cpp.
std::set<int> setDirtyFileInfo |
Dirty block file entries.
Definition at line 43 of file blockstorage.cpp.
std::vector<CBlockFileInfo> vinfoBlockFile |
Definition at line 31 of file blockstorage.cpp.