scripted-diff: Rename touched member variables

-BEGIN VERIFY SCRIPT-

 ren() { sed -i "s/\<$1\>/$2/g" $( git grep -l "$1" ./src/ ) ; }

 ren vinfoBlockFile     m_blockfile_info
 ren nLastBlockFile     m_last_blockfile
 ren fCheckForPruning   m_check_for_pruning
 ren setDirtyBlockIndex m_dirty_blockindex
 ren setDirtyFileInfo   m_dirty_fileinfo

-END VERIFY SCRIPT-
This commit is contained in:
MarcoFalke
2022-01-05 15:44:16 +01:00
parent facd3df21f
commit fa68a6c2fc
3 changed files with 80 additions and 80 deletions

View File

@@ -69,7 +69,7 @@ CBlockIndex* BlockManager::AddToBlockIndex(const CBlockHeader& block)
if (pindexBestHeader == nullptr || pindexBestHeader->nChainWork < pindexNew->nChainWork) if (pindexBestHeader == nullptr || pindexBestHeader->nChainWork < pindexNew->nChainWork)
pindexBestHeader = pindexNew; pindexBestHeader = pindexNew;
setDirtyBlockIndex.insert(pindexNew); m_dirty_blockindex.insert(pindexNew);
return pindexNew; return pindexNew;
} }
@@ -87,7 +87,7 @@ void BlockManager::PruneOneBlockFile(const int fileNumber)
pindex->nFile = 0; pindex->nFile = 0;
pindex->nDataPos = 0; pindex->nDataPos = 0;
pindex->nUndoPos = 0; pindex->nUndoPos = 0;
setDirtyBlockIndex.insert(pindex); m_dirty_blockindex.insert(pindex);
// Prune from m_blocks_unlinked -- any block we prune would have // Prune from m_blocks_unlinked -- any block we prune would have
// to be downloaded again in order to consider its chain, at which // to be downloaded again in order to consider its chain, at which
@@ -104,8 +104,8 @@ void BlockManager::PruneOneBlockFile(const int fileNumber)
} }
} }
vinfoBlockFile[fileNumber].SetNull(); m_blockfile_info[fileNumber].SetNull();
setDirtyFileInfo.insert(fileNumber); m_dirty_fileinfo.insert(fileNumber);
} }
void BlockManager::FindFilesToPruneManual(std::set<int>& setFilesToPrune, int nManualPruneHeight, int chain_tip_height) void BlockManager::FindFilesToPruneManual(std::set<int>& setFilesToPrune, int nManualPruneHeight, int chain_tip_height)
@@ -120,8 +120,8 @@ void BlockManager::FindFilesToPruneManual(std::set<int>& setFilesToPrune, int nM
// last block to prune is the lesser of (user-specified height, MIN_BLOCKS_TO_KEEP from the tip) // last block to prune is the lesser of (user-specified height, MIN_BLOCKS_TO_KEEP from the tip)
unsigned int nLastBlockWeCanPrune = std::min((unsigned)nManualPruneHeight, chain_tip_height - MIN_BLOCKS_TO_KEEP); unsigned int nLastBlockWeCanPrune = std::min((unsigned)nManualPruneHeight, chain_tip_height - MIN_BLOCKS_TO_KEEP);
int count = 0; int count = 0;
for (int fileNumber = 0; fileNumber < nLastBlockFile; fileNumber++) { for (int fileNumber = 0; fileNumber < m_last_blockfile; fileNumber++) {
if (vinfoBlockFile[fileNumber].nSize == 0 || vinfoBlockFile[fileNumber].nHeightLast > nLastBlockWeCanPrune) { if (m_blockfile_info[fileNumber].nSize == 0 || m_blockfile_info[fileNumber].nHeightLast > nLastBlockWeCanPrune) {
continue; continue;
} }
PruneOneBlockFile(fileNumber); PruneOneBlockFile(fileNumber);
@@ -160,10 +160,10 @@ void BlockManager::FindFilesToPrune(std::set<int>& setFilesToPrune, uint64_t nPr
nBuffer += nPruneTarget / 10; nBuffer += nPruneTarget / 10;
} }
for (int fileNumber = 0; fileNumber < nLastBlockFile; fileNumber++) { for (int fileNumber = 0; fileNumber < m_last_blockfile; fileNumber++) {
nBytesToPrune = vinfoBlockFile[fileNumber].nSize + vinfoBlockFile[fileNumber].nUndoSize; nBytesToPrune = m_blockfile_info[fileNumber].nSize + m_blockfile_info[fileNumber].nUndoSize;
if (vinfoBlockFile[fileNumber].nSize == 0) { if (m_blockfile_info[fileNumber].nSize == 0) {
continue; continue;
} }
@@ -172,7 +172,7 @@ void BlockManager::FindFilesToPrune(std::set<int>& setFilesToPrune, uint64_t nPr
} }
// don't prune files that could have a block within MIN_BLOCKS_TO_KEEP of the main chain's tip but keep scanning // don't prune files that could have a block within MIN_BLOCKS_TO_KEEP of the main chain's tip but keep scanning
if (vinfoBlockFile[fileNumber].nHeightLast > nLastBlockWeCanPrune) { if (m_blockfile_info[fileNumber].nHeightLast > nLastBlockWeCanPrune) {
continue; continue;
} }
@@ -273,7 +273,7 @@ bool BlockManager::LoadBlockIndex(
} }
if (!(pindex->nStatus & BLOCK_FAILED_MASK) && pindex->pprev && (pindex->pprev->nStatus & BLOCK_FAILED_MASK)) { if (!(pindex->nStatus & BLOCK_FAILED_MASK) && pindex->pprev && (pindex->pprev->nStatus & BLOCK_FAILED_MASK)) {
pindex->nStatus |= BLOCK_FAILED_CHILD; pindex->nStatus |= BLOCK_FAILED_CHILD;
setDirtyBlockIndex.insert(pindex); m_dirty_blockindex.insert(pindex);
} }
if (pindex->IsAssumedValid() || if (pindex->IsAssumedValid() ||
(pindex->IsValid(BLOCK_VALID_TRANSACTIONS) && (pindex->IsValid(BLOCK_VALID_TRANSACTIONS) &&
@@ -332,27 +332,27 @@ void BlockManager::Unload()
m_block_index.clear(); m_block_index.clear();
vinfoBlockFile.clear(); m_blockfile_info.clear();
nLastBlockFile = 0; m_last_blockfile = 0;
setDirtyBlockIndex.clear(); m_dirty_blockindex.clear();
setDirtyFileInfo.clear(); m_dirty_fileinfo.clear();
} }
bool BlockManager::WriteBlockIndexDB() bool BlockManager::WriteBlockIndexDB()
{ {
std::vector<std::pair<int, const CBlockFileInfo*>> vFiles; std::vector<std::pair<int, const CBlockFileInfo*>> vFiles;
vFiles.reserve(setDirtyFileInfo.size()); vFiles.reserve(m_dirty_fileinfo.size());
for (std::set<int>::iterator it = setDirtyFileInfo.begin(); it != setDirtyFileInfo.end();) { for (std::set<int>::iterator it = m_dirty_fileinfo.begin(); it != m_dirty_fileinfo.end();) {
vFiles.push_back(std::make_pair(*it, &vinfoBlockFile[*it])); vFiles.push_back(std::make_pair(*it, &m_blockfile_info[*it]));
setDirtyFileInfo.erase(it++); m_dirty_fileinfo.erase(it++);
} }
std::vector<const CBlockIndex*> vBlocks; std::vector<const CBlockIndex*> vBlocks;
vBlocks.reserve(setDirtyBlockIndex.size()); vBlocks.reserve(m_dirty_blockindex.size());
for (std::set<CBlockIndex*>::iterator it = setDirtyBlockIndex.begin(); it != setDirtyBlockIndex.end();) { for (std::set<CBlockIndex*>::iterator it = m_dirty_blockindex.begin(); it != m_dirty_blockindex.end();) {
vBlocks.push_back(*it); vBlocks.push_back(*it);
setDirtyBlockIndex.erase(it++); m_dirty_blockindex.erase(it++);
} }
if (!m_block_tree_db->WriteBatchSync(vFiles, nLastBlockFile, vBlocks)) { if (!m_block_tree_db->WriteBatchSync(vFiles, m_last_blockfile, vBlocks)) {
return false; return false;
} }
return true; return true;
@@ -365,17 +365,17 @@ bool BlockManager::LoadBlockIndexDB(ChainstateManager& chainman)
} }
// Load block file info // Load block file info
m_block_tree_db->ReadLastBlockFile(nLastBlockFile); m_block_tree_db->ReadLastBlockFile(m_last_blockfile);
vinfoBlockFile.resize(nLastBlockFile + 1); m_blockfile_info.resize(m_last_blockfile + 1);
LogPrintf("%s: last block file = %i\n", __func__, nLastBlockFile); LogPrintf("%s: last block file = %i\n", __func__, m_last_blockfile);
for (int nFile = 0; nFile <= nLastBlockFile; nFile++) { for (int nFile = 0; nFile <= m_last_blockfile; nFile++) {
m_block_tree_db->ReadBlockFileInfo(nFile, vinfoBlockFile[nFile]); m_block_tree_db->ReadBlockFileInfo(nFile, m_blockfile_info[nFile]);
} }
LogPrintf("%s: last block file info: %s\n", __func__, vinfoBlockFile[nLastBlockFile].ToString()); LogPrintf("%s: last block file info: %s\n", __func__, m_blockfile_info[m_last_blockfile].ToString());
for (int nFile = nLastBlockFile + 1; true; nFile++) { for (int nFile = m_last_blockfile + 1; true; nFile++) {
CBlockFileInfo info; CBlockFileInfo info;
if (m_block_tree_db->ReadBlockFileInfo(nFile, info)) { if (m_block_tree_db->ReadBlockFileInfo(nFile, info)) {
vinfoBlockFile.push_back(info); m_blockfile_info.push_back(info);
} else { } else {
break; break;
} }
@@ -433,7 +433,7 @@ bool IsBlockPruned(const CBlockIndex* pblockindex)
// If we're using -prune with -reindex, then delete block files that will be ignored by the // If we're using -prune with -reindex, then delete block files that will be ignored by the
// reindex. Since reindexing works by starting at block file 0 and looping until a blockfile // reindex. Since reindexing works by starting at block file 0 and looping until a blockfile
// is missing, do the same here to delete any later block files after a gap. Also delete all // is missing, do the same here to delete any later block files after a gap. Also delete all
// rev files since they'll be rewritten by the reindex anyway. This ensures that vinfoBlockFile // rev files since they'll be rewritten by the reindex anyway. This ensures that m_blockfile_info
// is in sync with what's actually on disk by the time we start downloading, so that pruning // is in sync with what's actually on disk by the time we start downloading, so that pruning
// works correctly. // works correctly.
void CleanupBlockRevFiles() void CleanupBlockRevFiles()
@@ -482,7 +482,7 @@ CBlockFileInfo* BlockManager::GetBlockFileInfo(size_t n)
{ {
LOCK(cs_LastBlockFile); LOCK(cs_LastBlockFile);
return &vinfoBlockFile.at(n); return &m_blockfile_info.at(n);
} }
static bool UndoWriteToDisk(const CBlockUndo& blockundo, FlatFilePos& pos, const uint256& hashBlock, const CMessageHeader::MessageStartChars& messageStart) static bool UndoWriteToDisk(const CBlockUndo& blockundo, FlatFilePos& pos, const uint256& hashBlock, const CMessageHeader::MessageStartChars& messageStart)
@@ -548,7 +548,7 @@ bool UndoReadFromDisk(CBlockUndo& blockundo, const CBlockIndex* pindex)
void BlockManager::FlushUndoFile(int block_file, bool finalize) void BlockManager::FlushUndoFile(int block_file, bool finalize)
{ {
FlatFilePos undo_pos_old(block_file, vinfoBlockFile[block_file].nUndoSize); FlatFilePos undo_pos_old(block_file, m_blockfile_info[block_file].nUndoSize);
if (!UndoFileSeq().Flush(undo_pos_old, finalize)) { if (!UndoFileSeq().Flush(undo_pos_old, finalize)) {
AbortNode("Flushing undo file to disk failed. This is likely the result of an I/O error."); AbortNode("Flushing undo file to disk failed. This is likely the result of an I/O error.");
} }
@@ -557,13 +557,13 @@ void BlockManager::FlushUndoFile(int block_file, bool finalize)
void BlockManager::FlushBlockFile(bool fFinalize, bool finalize_undo) void BlockManager::FlushBlockFile(bool fFinalize, bool finalize_undo)
{ {
LOCK(cs_LastBlockFile); LOCK(cs_LastBlockFile);
FlatFilePos block_pos_old(nLastBlockFile, vinfoBlockFile[nLastBlockFile].nSize); FlatFilePos block_pos_old(m_last_blockfile, m_blockfile_info[m_last_blockfile].nSize);
if (!BlockFileSeq().Flush(block_pos_old, fFinalize)) { if (!BlockFileSeq().Flush(block_pos_old, fFinalize)) {
AbortNode("Flushing block file to disk failed. This is likely the result of an I/O error."); AbortNode("Flushing block file to disk failed. This is likely the result of an I/O error.");
} }
// we do not always flush the undo file, as the chain tip may be lagging behind the incoming blocks, // we do not always flush the undo file, as the chain tip may be lagging behind the incoming blocks,
// e.g. during IBD or a sync after a node going offline // e.g. during IBD or a sync after a node going offline
if (!fFinalize || finalize_undo) FlushUndoFile(nLastBlockFile, finalize_undo); if (!fFinalize || finalize_undo) FlushUndoFile(m_last_blockfile, finalize_undo);
} }
uint64_t BlockManager::CalculateCurrentUsage() uint64_t BlockManager::CalculateCurrentUsage()
@@ -571,7 +571,7 @@ uint64_t BlockManager::CalculateCurrentUsage()
LOCK(cs_LastBlockFile); LOCK(cs_LastBlockFile);
uint64_t retval = 0; uint64_t retval = 0;
for (const CBlockFileInfo& file : vinfoBlockFile) { for (const CBlockFileInfo& file : m_blockfile_info) {
retval += file.nSize + file.nUndoSize; retval += file.nSize + file.nUndoSize;
} }
return retval; return retval;
@@ -617,40 +617,40 @@ bool BlockManager::FindBlockPos(FlatFilePos& pos, unsigned int nAddSize, unsigne
{ {
LOCK(cs_LastBlockFile); LOCK(cs_LastBlockFile);
unsigned int nFile = fKnown ? pos.nFile : nLastBlockFile; unsigned int nFile = fKnown ? pos.nFile : m_last_blockfile;
if (vinfoBlockFile.size() <= nFile) { if (m_blockfile_info.size() <= nFile) {
vinfoBlockFile.resize(nFile + 1); m_blockfile_info.resize(nFile + 1);
} }
bool finalize_undo = false; bool finalize_undo = false;
if (!fKnown) { if (!fKnown) {
while (vinfoBlockFile[nFile].nSize + nAddSize >= (gArgs.GetBoolArg("-fastprune", false) ? 0x10000 /* 64kb */ : MAX_BLOCKFILE_SIZE)) { while (m_blockfile_info[nFile].nSize + nAddSize >= (gArgs.GetBoolArg("-fastprune", false) ? 0x10000 /* 64kb */ : MAX_BLOCKFILE_SIZE)) {
// when the undo file is keeping up with the block file, we want to flush it explicitly // when the undo file is keeping up with the block file, we want to flush it explicitly
// when it is lagging behind (more blocks arrive than are being connected), we let the // when it is lagging behind (more blocks arrive than are being connected), we let the
// undo block write case handle it // undo block write case handle it
finalize_undo = (vinfoBlockFile[nFile].nHeightLast == (unsigned int)active_chain.Tip()->nHeight); finalize_undo = (m_blockfile_info[nFile].nHeightLast == (unsigned int)active_chain.Tip()->nHeight);
nFile++; nFile++;
if (vinfoBlockFile.size() <= nFile) { if (m_blockfile_info.size() <= nFile) {
vinfoBlockFile.resize(nFile + 1); m_blockfile_info.resize(nFile + 1);
} }
} }
pos.nFile = nFile; pos.nFile = nFile;
pos.nPos = vinfoBlockFile[nFile].nSize; pos.nPos = m_blockfile_info[nFile].nSize;
} }
if ((int)nFile != nLastBlockFile) { if ((int)nFile != m_last_blockfile) {
if (!fKnown) { if (!fKnown) {
LogPrint(BCLog::BLOCKSTORE, "Leaving block file %i: %s\n", nLastBlockFile, vinfoBlockFile[nLastBlockFile].ToString()); LogPrint(BCLog::BLOCKSTORE, "Leaving block file %i: %s\n", m_last_blockfile, m_blockfile_info[m_last_blockfile].ToString());
} }
FlushBlockFile(!fKnown, finalize_undo); FlushBlockFile(!fKnown, finalize_undo);
nLastBlockFile = nFile; m_last_blockfile = nFile;
} }
vinfoBlockFile[nFile].AddBlock(nHeight, nTime); m_blockfile_info[nFile].AddBlock(nHeight, nTime);
if (fKnown) { if (fKnown) {
vinfoBlockFile[nFile].nSize = std::max(pos.nPos + nAddSize, vinfoBlockFile[nFile].nSize); m_blockfile_info[nFile].nSize = std::max(pos.nPos + nAddSize, m_blockfile_info[nFile].nSize);
} else { } else {
vinfoBlockFile[nFile].nSize += nAddSize; m_blockfile_info[nFile].nSize += nAddSize;
} }
if (!fKnown) { if (!fKnown) {
@@ -660,11 +660,11 @@ bool BlockManager::FindBlockPos(FlatFilePos& pos, unsigned int nAddSize, unsigne
return AbortNode("Disk space is too low!", _("Disk space is too low!")); return AbortNode("Disk space is too low!", _("Disk space is too low!"));
} }
if (bytes_allocated != 0 && fPruneMode) { if (bytes_allocated != 0 && fPruneMode) {
fCheckForPruning = true; m_check_for_pruning = true;
} }
} }
setDirtyFileInfo.insert(nFile); m_dirty_fileinfo.insert(nFile);
return true; return true;
} }
@@ -674,9 +674,9 @@ bool BlockManager::FindUndoPos(BlockValidationState& state, int nFile, FlatFileP
LOCK(cs_LastBlockFile); LOCK(cs_LastBlockFile);
pos.nPos = vinfoBlockFile[nFile].nUndoSize; pos.nPos = m_blockfile_info[nFile].nUndoSize;
vinfoBlockFile[nFile].nUndoSize += nAddSize; m_blockfile_info[nFile].nUndoSize += nAddSize;
setDirtyFileInfo.insert(nFile); m_dirty_fileinfo.insert(nFile);
bool out_of_space; bool out_of_space;
size_t bytes_allocated = UndoFileSeq().Allocate(pos, nAddSize, out_of_space); size_t bytes_allocated = UndoFileSeq().Allocate(pos, nAddSize, out_of_space);
@@ -684,7 +684,7 @@ bool BlockManager::FindUndoPos(BlockValidationState& state, int nFile, FlatFileP
return AbortNode(state, "Disk space is too low!", _("Disk space is too low!")); return AbortNode(state, "Disk space is too low!", _("Disk space is too low!"));
} }
if (bytes_allocated != 0 && fPruneMode) { if (bytes_allocated != 0 && fPruneMode) {
fCheckForPruning = true; m_check_for_pruning = true;
} }
return true; return true;
@@ -729,14 +729,14 @@ bool BlockManager::WriteUndoDataForBlock(const CBlockUndo& blockundo, BlockValid
// in the block file info as below; note that this does not catch the case where the undo writes are keeping up // in the block file info as below; note that this does not catch the case where the undo writes are keeping up
// with the block writes (usually when a synced up node is getting newly mined blocks) -- this case is caught in // with the block writes (usually when a synced up node is getting newly mined blocks) -- this case is caught in
// the FindBlockPos function // the FindBlockPos function
if (_pos.nFile < nLastBlockFile && static_cast<uint32_t>(pindex->nHeight) == vinfoBlockFile[_pos.nFile].nHeightLast) { if (_pos.nFile < m_last_blockfile && static_cast<uint32_t>(pindex->nHeight) == m_blockfile_info[_pos.nFile].nHeightLast) {
FlushUndoFile(_pos.nFile, true); FlushUndoFile(_pos.nFile, true);
} }
// update nUndoPos in block index // update nUndoPos in block index
pindex->nUndoPos = _pos.nPos; pindex->nUndoPos = _pos.nPos;
pindex->nStatus |= BLOCK_HAVE_UNDO; pindex->nStatus |= BLOCK_HAVE_UNDO;
setDirtyBlockIndex.insert(pindex); m_dirty_blockindex.insert(pindex);
} }
return true; return true;

View File

@@ -81,7 +81,7 @@ private:
* space is allocated in a block or undo file, staying below the target. Changing back to unpruned requires a reindex * space is allocated in a block or undo file, staying below the target. Changing back to unpruned requires a reindex
* (which in this case means the blockchain must be re-downloaded.) * (which in this case means the blockchain must be re-downloaded.)
* *
* Pruning functions are called from FlushStateToDisk when the fCheckForPruning flag has been set. * Pruning functions are called from FlushStateToDisk when the m_check_for_pruning flag has been set.
* Block and undo files are deleted in lock-step (when blk00003.dat is deleted, so is rev00003.dat.) * Block and undo files are deleted in lock-step (when blk00003.dat is deleted, so is rev00003.dat.)
* Pruning cannot take place until the longest chain is at least a certain length (CChainParams::nPruneAfterHeight). * Pruning cannot take place until the longest chain is at least a certain length (CChainParams::nPruneAfterHeight).
* Pruning will never delete a block within a defined distance (currently 288) from the active chain's tip. * Pruning will never delete a block within a defined distance (currently 288) from the active chain's tip.
@@ -93,19 +93,19 @@ private:
void FindFilesToPrune(std::set<int>& setFilesToPrune, uint64_t nPruneAfterHeight, int chain_tip_height, int prune_height, bool is_ibd); void FindFilesToPrune(std::set<int>& setFilesToPrune, uint64_t nPruneAfterHeight, int chain_tip_height, int prune_height, bool is_ibd);
RecursiveMutex cs_LastBlockFile; RecursiveMutex cs_LastBlockFile;
std::vector<CBlockFileInfo> vinfoBlockFile; std::vector<CBlockFileInfo> m_blockfile_info;
int nLastBlockFile = 0; int m_last_blockfile = 0;
/** Global flag to indicate we should check to see if there are /** Global flag to indicate we should check to see if there are
* block/undo files that should be deleted. Set on startup * block/undo files that should be deleted. Set on startup
* or if we allocate more file space when we're in prune mode * or if we allocate more file space when we're in prune mode
*/ */
bool fCheckForPruning = false; bool m_check_for_pruning = false;
/** Dirty block index entries. */ /** Dirty block index entries. */
std::set<CBlockIndex*> setDirtyBlockIndex; std::set<CBlockIndex*> m_dirty_blockindex;
/** Dirty block file entries. */ /** Dirty block file entries. */
std::set<int> setDirtyFileInfo; std::set<int> m_dirty_fileinfo;
public: public:
BlockMap m_block_index GUARDED_BY(cs_main); BlockMap m_block_index GUARDED_BY(cs_main);
@@ -124,7 +124,7 @@ public:
/** /**
* Load the blocktree off disk and into memory. Populate certain metadata * Load the blocktree off disk and into memory. Populate certain metadata
* per index entry (nStatus, nChainWork, nTimeMax, etc.) as well as peripheral * per index entry (nStatus, nChainWork, nTimeMax, etc.) as well as peripheral
* collections like setDirtyBlockIndex. * collections like m_dirty_blockindex.
*/ */
bool LoadBlockIndex( bool LoadBlockIndex(
const Consensus::Params& consensus_params, const Consensus::Params& consensus_params,

View File

@@ -1495,7 +1495,7 @@ void CChainState::InvalidBlockFound(CBlockIndex* pindex, const BlockValidationSt
if (state.GetResult() != BlockValidationResult::BLOCK_MUTATED) { if (state.GetResult() != BlockValidationResult::BLOCK_MUTATED) {
pindex->nStatus |= BLOCK_FAILED_VALID; pindex->nStatus |= BLOCK_FAILED_VALID;
m_chainman.m_failed_blocks.insert(pindex); m_chainman.m_failed_blocks.insert(pindex);
m_blockman.setDirtyBlockIndex.insert(pindex); m_blockman.m_dirty_blockindex.insert(pindex);
setBlockIndexCandidates.erase(pindex); setBlockIndexCandidates.erase(pindex);
InvalidChainFound(pindex); InvalidChainFound(pindex);
} }
@@ -2131,7 +2131,7 @@ bool CChainState::ConnectBlock(const CBlock& block, BlockValidationState& state,
if (!pindex->IsValid(BLOCK_VALID_SCRIPTS)) { if (!pindex->IsValid(BLOCK_VALID_SCRIPTS)) {
pindex->RaiseValidity(BLOCK_VALID_SCRIPTS); pindex->RaiseValidity(BLOCK_VALID_SCRIPTS);
m_blockman.setDirtyBlockIndex.insert(pindex); m_blockman.m_dirty_blockindex.insert(pindex);
} }
assert(pindex->phashBlock); assert(pindex->phashBlock);
@@ -2205,7 +2205,7 @@ bool CChainState::FlushStateToDisk(
CoinsCacheSizeState cache_state = GetCoinsCacheSizeState(); CoinsCacheSizeState cache_state = GetCoinsCacheSizeState();
LOCK(m_blockman.cs_LastBlockFile); LOCK(m_blockman.cs_LastBlockFile);
if (fPruneMode && (m_blockman.fCheckForPruning || nManualPruneHeight > 0) && !fReindex) { if (fPruneMode && (m_blockman.m_check_for_pruning || nManualPruneHeight > 0) && !fReindex) {
// make sure we don't prune above the blockfilterindexes bestblocks // make sure we don't prune above the blockfilterindexes bestblocks
// pruning is height-based // pruning is height-based
int last_prune = m_chain.Height(); // last height we can prune int last_prune = m_chain.Height(); // last height we can prune
@@ -2221,7 +2221,7 @@ bool CChainState::FlushStateToDisk(
LOG_TIME_MILLIS_WITH_CATEGORY("find files to prune", BCLog::BENCH); LOG_TIME_MILLIS_WITH_CATEGORY("find files to prune", BCLog::BENCH);
m_blockman.FindFilesToPrune(setFilesToPrune, m_params.PruneAfterHeight(), m_chain.Height(), last_prune, IsInitialBlockDownload()); m_blockman.FindFilesToPrune(setFilesToPrune, m_params.PruneAfterHeight(), m_chain.Height(), last_prune, IsInitialBlockDownload());
m_blockman.fCheckForPruning = false; m_blockman.m_check_for_pruning = false;
} }
if (!setFilesToPrune.empty()) { if (!setFilesToPrune.empty()) {
fFlushForPrune = true; fFlushForPrune = true;
@@ -2326,7 +2326,7 @@ void CChainState::ForceFlushStateToDisk()
void CChainState::PruneAndFlush() void CChainState::PruneAndFlush()
{ {
BlockValidationState state; BlockValidationState state;
m_blockman.fCheckForPruning = true; m_blockman.m_check_for_pruning = true;
if (!this->FlushStateToDisk(state, FlushStateMode::NONE)) { if (!this->FlushStateToDisk(state, FlushStateMode::NONE)) {
LogPrintf("%s: failed to flush state (%s)\n", __func__, state.ToString()); LogPrintf("%s: failed to flush state (%s)\n", __func__, state.ToString());
} }
@@ -2996,14 +2996,14 @@ bool CChainState::InvalidateBlock(BlockValidationState& state, CBlockIndex* pind
// are no blocks that meet the "have data and are not invalid per // are no blocks that meet the "have data and are not invalid per
// nStatus" criteria for inclusion in setBlockIndexCandidates). // nStatus" criteria for inclusion in setBlockIndexCandidates).
invalid_walk_tip->nStatus |= BLOCK_FAILED_VALID; invalid_walk_tip->nStatus |= BLOCK_FAILED_VALID;
m_blockman.setDirtyBlockIndex.insert(invalid_walk_tip); m_blockman.m_dirty_blockindex.insert(invalid_walk_tip);
setBlockIndexCandidates.erase(invalid_walk_tip); setBlockIndexCandidates.erase(invalid_walk_tip);
setBlockIndexCandidates.insert(invalid_walk_tip->pprev); setBlockIndexCandidates.insert(invalid_walk_tip->pprev);
if (invalid_walk_tip->pprev == to_mark_failed && (to_mark_failed->nStatus & BLOCK_FAILED_VALID)) { if (invalid_walk_tip->pprev == to_mark_failed && (to_mark_failed->nStatus & BLOCK_FAILED_VALID)) {
// We only want to mark the last disconnected block as BLOCK_FAILED_VALID; its children // We only want to mark the last disconnected block as BLOCK_FAILED_VALID; its children
// need to be BLOCK_FAILED_CHILD instead. // need to be BLOCK_FAILED_CHILD instead.
to_mark_failed->nStatus = (to_mark_failed->nStatus ^ BLOCK_FAILED_VALID) | BLOCK_FAILED_CHILD; to_mark_failed->nStatus = (to_mark_failed->nStatus ^ BLOCK_FAILED_VALID) | BLOCK_FAILED_CHILD;
m_blockman.setDirtyBlockIndex.insert(to_mark_failed); m_blockman.m_dirty_blockindex.insert(to_mark_failed);
} }
// Add any equal or more work headers to setBlockIndexCandidates // Add any equal or more work headers to setBlockIndexCandidates
@@ -3033,7 +3033,7 @@ bool CChainState::InvalidateBlock(BlockValidationState& state, CBlockIndex* pind
// Mark pindex (or the last disconnected block) as invalid, even when it never was in the main chain // Mark pindex (or the last disconnected block) as invalid, even when it never was in the main chain
to_mark_failed->nStatus |= BLOCK_FAILED_VALID; to_mark_failed->nStatus |= BLOCK_FAILED_VALID;
m_blockman.setDirtyBlockIndex.insert(to_mark_failed); m_blockman.m_dirty_blockindex.insert(to_mark_failed);
setBlockIndexCandidates.erase(to_mark_failed); setBlockIndexCandidates.erase(to_mark_failed);
m_chainman.m_failed_blocks.insert(to_mark_failed); m_chainman.m_failed_blocks.insert(to_mark_failed);
@@ -3072,7 +3072,7 @@ void CChainState::ResetBlockFailureFlags(CBlockIndex *pindex) {
while (it != m_blockman.m_block_index.end()) { while (it != m_blockman.m_block_index.end()) {
if (!it->second->IsValid() && it->second->GetAncestor(nHeight) == pindex) { if (!it->second->IsValid() && it->second->GetAncestor(nHeight) == pindex) {
it->second->nStatus &= ~BLOCK_FAILED_MASK; it->second->nStatus &= ~BLOCK_FAILED_MASK;
m_blockman.setDirtyBlockIndex.insert(it->second); m_blockman.m_dirty_blockindex.insert(it->second);
if (it->second->IsValid(BLOCK_VALID_TRANSACTIONS) && it->second->HaveTxsDownloaded() && setBlockIndexCandidates.value_comp()(m_chain.Tip(), it->second)) { if (it->second->IsValid(BLOCK_VALID_TRANSACTIONS) && it->second->HaveTxsDownloaded() && setBlockIndexCandidates.value_comp()(m_chain.Tip(), it->second)) {
setBlockIndexCandidates.insert(it->second); setBlockIndexCandidates.insert(it->second);
} }
@@ -3089,7 +3089,7 @@ void CChainState::ResetBlockFailureFlags(CBlockIndex *pindex) {
while (pindex != nullptr) { while (pindex != nullptr) {
if (pindex->nStatus & BLOCK_FAILED_MASK) { if (pindex->nStatus & BLOCK_FAILED_MASK) {
pindex->nStatus &= ~BLOCK_FAILED_MASK; pindex->nStatus &= ~BLOCK_FAILED_MASK;
m_blockman.setDirtyBlockIndex.insert(pindex); m_blockman.m_dirty_blockindex.insert(pindex);
m_chainman.m_failed_blocks.erase(pindex); m_chainman.m_failed_blocks.erase(pindex);
} }
pindex = pindex->pprev; pindex = pindex->pprev;
@@ -3109,7 +3109,7 @@ void CChainState::ReceivedBlockTransactions(const CBlock& block, CBlockIndex* pi
pindexNew->nStatus |= BLOCK_OPT_WITNESS; pindexNew->nStatus |= BLOCK_OPT_WITNESS;
} }
pindexNew->RaiseValidity(BLOCK_VALID_TRANSACTIONS); pindexNew->RaiseValidity(BLOCK_VALID_TRANSACTIONS);
m_blockman.setDirtyBlockIndex.insert(pindexNew); m_blockman.m_dirty_blockindex.insert(pindexNew);
if (pindexNew->pprev == nullptr || pindexNew->pprev->HaveTxsDownloaded()) { if (pindexNew->pprev == nullptr || pindexNew->pprev->HaveTxsDownloaded()) {
// If pindexNew is the genesis block or all parents are BLOCK_VALID_TRANSACTIONS. // If pindexNew is the genesis block or all parents are BLOCK_VALID_TRANSACTIONS.
@@ -3471,7 +3471,7 @@ bool ChainstateManager::AcceptBlockHeader(const CBlockHeader& block, BlockValida
CBlockIndex* invalid_walk = pindexPrev; CBlockIndex* invalid_walk = pindexPrev;
while (invalid_walk != failedit) { while (invalid_walk != failedit) {
invalid_walk->nStatus |= BLOCK_FAILED_CHILD; invalid_walk->nStatus |= BLOCK_FAILED_CHILD;
m_blockman.setDirtyBlockIndex.insert(invalid_walk); m_blockman.m_dirty_blockindex.insert(invalid_walk);
invalid_walk = invalid_walk->pprev; invalid_walk = invalid_walk->pprev;
} }
LogPrint(BCLog::VALIDATION, "%s: %s prev block invalid\n", __func__, hash.ToString()); LogPrint(BCLog::VALIDATION, "%s: %s prev block invalid\n", __func__, hash.ToString());
@@ -3569,7 +3569,7 @@ bool CChainState::AcceptBlock(const std::shared_ptr<const CBlock>& pblock, Block
!ContextualCheckBlock(block, state, m_params.GetConsensus(), pindex->pprev)) { !ContextualCheckBlock(block, state, m_params.GetConsensus(), pindex->pprev)) {
if (state.IsInvalid() && state.GetResult() != BlockValidationResult::BLOCK_MUTATED) { if (state.IsInvalid() && state.GetResult() != BlockValidationResult::BLOCK_MUTATED) {
pindex->nStatus |= BLOCK_FAILED_VALID; pindex->nStatus |= BLOCK_FAILED_VALID;
m_blockman.setDirtyBlockIndex.insert(pindex); m_blockman.m_dirty_blockindex.insert(pindex);
} }
return error("%s: %s", __func__, state.ToString()); return error("%s: %s", __func__, state.ToString());
} }
@@ -4904,7 +4904,7 @@ bool ChainstateManager::PopulateAndValidateSnapshot(
index->nStatus |= BLOCK_OPT_WITNESS; index->nStatus |= BLOCK_OPT_WITNESS;
} }
m_blockman.setDirtyBlockIndex.insert(index); m_blockman.m_dirty_blockindex.insert(index);
// Changes to the block index will be flushed to disk after this call // Changes to the block index will be flushed to disk after this call
// returns in `ActivateSnapshot()`, when `MaybeRebalanceCaches()` is // returns in `ActivateSnapshot()`, when `MaybeRebalanceCaches()` is
// called, since we've added a snapshot chainstate and therefore will // called, since we've added a snapshot chainstate and therefore will