Skip to content

Commit fa68a6c

Browse files
author
MarcoFalke
committed
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-
1 parent facd3df commit fa68a6c

File tree

3 files changed

+81
-81
lines changed

3 files changed

+81
-81
lines changed

src/node/blockstorage.cpp

+60-60
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ CBlockIndex* BlockManager::AddToBlockIndex(const CBlockHeader& block)
6969
if (pindexBestHeader == nullptr || pindexBestHeader->nChainWork < pindexNew->nChainWork)
7070
pindexBestHeader = pindexNew;
7171

72-
setDirtyBlockIndex.insert(pindexNew);
72+
m_dirty_blockindex.insert(pindexNew);
7373

7474
return pindexNew;
7575
}
@@ -87,7 +87,7 @@ void BlockManager::PruneOneBlockFile(const int fileNumber)
8787
pindex->nFile = 0;
8888
pindex->nDataPos = 0;
8989
pindex->nUndoPos = 0;
90-
setDirtyBlockIndex.insert(pindex);
90+
m_dirty_blockindex.insert(pindex);
9191

9292
// Prune from m_blocks_unlinked -- any block we prune would have
9393
// to be downloaded again in order to consider its chain, at which
@@ -104,8 +104,8 @@ void BlockManager::PruneOneBlockFile(const int fileNumber)
104104
}
105105
}
106106

107-
vinfoBlockFile[fileNumber].SetNull();
108-
setDirtyFileInfo.insert(fileNumber);
107+
m_blockfile_info[fileNumber].SetNull();
108+
m_dirty_fileinfo.insert(fileNumber);
109109
}
110110

111111
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
120120
// last block to prune is the lesser of (user-specified height, MIN_BLOCKS_TO_KEEP from the tip)
121121
unsigned int nLastBlockWeCanPrune = std::min((unsigned)nManualPruneHeight, chain_tip_height - MIN_BLOCKS_TO_KEEP);
122122
int count = 0;
123-
for (int fileNumber = 0; fileNumber < nLastBlockFile; fileNumber++) {
124-
if (vinfoBlockFile[fileNumber].nSize == 0 || vinfoBlockFile[fileNumber].nHeightLast > nLastBlockWeCanPrune) {
123+
for (int fileNumber = 0; fileNumber < m_last_blockfile; fileNumber++) {
124+
if (m_blockfile_info[fileNumber].nSize == 0 || m_blockfile_info[fileNumber].nHeightLast > nLastBlockWeCanPrune) {
125125
continue;
126126
}
127127
PruneOneBlockFile(fileNumber);
@@ -160,10 +160,10 @@ void BlockManager::FindFilesToPrune(std::set<int>& setFilesToPrune, uint64_t nPr
160160
nBuffer += nPruneTarget / 10;
161161
}
162162

163-
for (int fileNumber = 0; fileNumber < nLastBlockFile; fileNumber++) {
164-
nBytesToPrune = vinfoBlockFile[fileNumber].nSize + vinfoBlockFile[fileNumber].nUndoSize;
163+
for (int fileNumber = 0; fileNumber < m_last_blockfile; fileNumber++) {
164+
nBytesToPrune = m_blockfile_info[fileNumber].nSize + m_blockfile_info[fileNumber].nUndoSize;
165165

166-
if (vinfoBlockFile[fileNumber].nSize == 0) {
166+
if (m_blockfile_info[fileNumber].nSize == 0) {
167167
continue;
168168
}
169169

@@ -172,7 +172,7 @@ void BlockManager::FindFilesToPrune(std::set<int>& setFilesToPrune, uint64_t nPr
172172
}
173173

174174
// don't prune files that could have a block within MIN_BLOCKS_TO_KEEP of the main chain's tip but keep scanning
175-
if (vinfoBlockFile[fileNumber].nHeightLast > nLastBlockWeCanPrune) {
175+
if (m_blockfile_info[fileNumber].nHeightLast > nLastBlockWeCanPrune) {
176176
continue;
177177
}
178178

@@ -273,7 +273,7 @@ bool BlockManager::LoadBlockIndex(
273273
}
274274
if (!(pindex->nStatus & BLOCK_FAILED_MASK) && pindex->pprev && (pindex->pprev->nStatus & BLOCK_FAILED_MASK)) {
275275
pindex->nStatus |= BLOCK_FAILED_CHILD;
276-
setDirtyBlockIndex.insert(pindex);
276+
m_dirty_blockindex.insert(pindex);
277277
}
278278
if (pindex->IsAssumedValid() ||
279279
(pindex->IsValid(BLOCK_VALID_TRANSACTIONS) &&
@@ -332,27 +332,27 @@ void BlockManager::Unload()
332332

333333
m_block_index.clear();
334334

335-
vinfoBlockFile.clear();
336-
nLastBlockFile = 0;
337-
setDirtyBlockIndex.clear();
338-
setDirtyFileInfo.clear();
335+
m_blockfile_info.clear();
336+
m_last_blockfile = 0;
337+
m_dirty_blockindex.clear();
338+
m_dirty_fileinfo.clear();
339339
}
340340

341341
bool BlockManager::WriteBlockIndexDB()
342342
{
343343
std::vector<std::pair<int, const CBlockFileInfo*>> vFiles;
344-
vFiles.reserve(setDirtyFileInfo.size());
345-
for (std::set<int>::iterator it = setDirtyFileInfo.begin(); it != setDirtyFileInfo.end();) {
346-
vFiles.push_back(std::make_pair(*it, &vinfoBlockFile[*it]));
347-
setDirtyFileInfo.erase(it++);
344+
vFiles.reserve(m_dirty_fileinfo.size());
345+
for (std::set<int>::iterator it = m_dirty_fileinfo.begin(); it != m_dirty_fileinfo.end();) {
346+
vFiles.push_back(std::make_pair(*it, &m_blockfile_info[*it]));
347+
m_dirty_fileinfo.erase(it++);
348348
}
349349
std::vector<const CBlockIndex*> vBlocks;
350-
vBlocks.reserve(setDirtyBlockIndex.size());
351-
for (std::set<CBlockIndex*>::iterator it = setDirtyBlockIndex.begin(); it != setDirtyBlockIndex.end();) {
350+
vBlocks.reserve(m_dirty_blockindex.size());
351+
for (std::set<CBlockIndex*>::iterator it = m_dirty_blockindex.begin(); it != m_dirty_blockindex.end();) {
352352
vBlocks.push_back(*it);
353-
setDirtyBlockIndex.erase(it++);
353+
m_dirty_blockindex.erase(it++);
354354
}
355-
if (!m_block_tree_db->WriteBatchSync(vFiles, nLastBlockFile, vBlocks)) {
355+
if (!m_block_tree_db->WriteBatchSync(vFiles, m_last_blockfile, vBlocks)) {
356356
return false;
357357
}
358358
return true;
@@ -365,17 +365,17 @@ bool BlockManager::LoadBlockIndexDB(ChainstateManager& chainman)
365365
}
366366

367367
// Load block file info
368-
m_block_tree_db->ReadLastBlockFile(nLastBlockFile);
369-
vinfoBlockFile.resize(nLastBlockFile + 1);
370-
LogPrintf("%s: last block file = %i\n", __func__, nLastBlockFile);
371-
for (int nFile = 0; nFile <= nLastBlockFile; nFile++) {
372-
m_block_tree_db->ReadBlockFileInfo(nFile, vinfoBlockFile[nFile]);
373-
}
374-
LogPrintf("%s: last block file info: %s\n", __func__, vinfoBlockFile[nLastBlockFile].ToString());
375-
for (int nFile = nLastBlockFile + 1; true; nFile++) {
368+
m_block_tree_db->ReadLastBlockFile(m_last_blockfile);
369+
m_blockfile_info.resize(m_last_blockfile + 1);
370+
LogPrintf("%s: last block file = %i\n", __func__, m_last_blockfile);
371+
for (int nFile = 0; nFile <= m_last_blockfile; nFile++) {
372+
m_block_tree_db->ReadBlockFileInfo(nFile, m_blockfile_info[nFile]);
373+
}
374+
LogPrintf("%s: last block file info: %s\n", __func__, m_blockfile_info[m_last_blockfile].ToString());
375+
for (int nFile = m_last_blockfile + 1; true; nFile++) {
376376
CBlockFileInfo info;
377377
if (m_block_tree_db->ReadBlockFileInfo(nFile, info)) {
378-
vinfoBlockFile.push_back(info);
378+
m_blockfile_info.push_back(info);
379379
} else {
380380
break;
381381
}
@@ -433,7 +433,7 @@ bool IsBlockPruned(const CBlockIndex* pblockindex)
433433
// If we're using -prune with -reindex, then delete block files that will be ignored by the
434434
// reindex. Since reindexing works by starting at block file 0 and looping until a blockfile
435435
// is missing, do the same here to delete any later block files after a gap. Also delete all
436-
// rev files since they'll be rewritten by the reindex anyway. This ensures that vinfoBlockFile
436+
// rev files since they'll be rewritten by the reindex anyway. This ensures that m_blockfile_info
437437
// is in sync with what's actually on disk by the time we start downloading, so that pruning
438438
// works correctly.
439439
void CleanupBlockRevFiles()
@@ -482,7 +482,7 @@ CBlockFileInfo* BlockManager::GetBlockFileInfo(size_t n)
482482
{
483483
LOCK(cs_LastBlockFile);
484484

485-
return &vinfoBlockFile.at(n);
485+
return &m_blockfile_info.at(n);
486486
}
487487

488488
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)
548548

549549
void BlockManager::FlushUndoFile(int block_file, bool finalize)
550550
{
551-
FlatFilePos undo_pos_old(block_file, vinfoBlockFile[block_file].nUndoSize);
551+
FlatFilePos undo_pos_old(block_file, m_blockfile_info[block_file].nUndoSize);
552552
if (!UndoFileSeq().Flush(undo_pos_old, finalize)) {
553553
AbortNode("Flushing undo file to disk failed. This is likely the result of an I/O error.");
554554
}
@@ -557,21 +557,21 @@ void BlockManager::FlushUndoFile(int block_file, bool finalize)
557557
void BlockManager::FlushBlockFile(bool fFinalize, bool finalize_undo)
558558
{
559559
LOCK(cs_LastBlockFile);
560-
FlatFilePos block_pos_old(nLastBlockFile, vinfoBlockFile[nLastBlockFile].nSize);
560+
FlatFilePos block_pos_old(m_last_blockfile, m_blockfile_info[m_last_blockfile].nSize);
561561
if (!BlockFileSeq().Flush(block_pos_old, fFinalize)) {
562562
AbortNode("Flushing block file to disk failed. This is likely the result of an I/O error.");
563563
}
564564
// we do not always flush the undo file, as the chain tip may be lagging behind the incoming blocks,
565565
// e.g. during IBD or a sync after a node going offline
566-
if (!fFinalize || finalize_undo) FlushUndoFile(nLastBlockFile, finalize_undo);
566+
if (!fFinalize || finalize_undo) FlushUndoFile(m_last_blockfile, finalize_undo);
567567
}
568568

569569
uint64_t BlockManager::CalculateCurrentUsage()
570570
{
571571
LOCK(cs_LastBlockFile);
572572

573573
uint64_t retval = 0;
574-
for (const CBlockFileInfo& file : vinfoBlockFile) {
574+
for (const CBlockFileInfo& file : m_blockfile_info) {
575575
retval += file.nSize + file.nUndoSize;
576576
}
577577
return retval;
@@ -617,40 +617,40 @@ bool BlockManager::FindBlockPos(FlatFilePos& pos, unsigned int nAddSize, unsigne
617617
{
618618
LOCK(cs_LastBlockFile);
619619

620-
unsigned int nFile = fKnown ? pos.nFile : nLastBlockFile;
621-
if (vinfoBlockFile.size() <= nFile) {
622-
vinfoBlockFile.resize(nFile + 1);
620+
unsigned int nFile = fKnown ? pos.nFile : m_last_blockfile;
621+
if (m_blockfile_info.size() <= nFile) {
622+
m_blockfile_info.resize(nFile + 1);
623623
}
624624

625625
bool finalize_undo = false;
626626
if (!fKnown) {
627-
while (vinfoBlockFile[nFile].nSize + nAddSize >= (gArgs.GetBoolArg("-fastprune", false) ? 0x10000 /* 64kb */ : MAX_BLOCKFILE_SIZE)) {
627+
while (m_blockfile_info[nFile].nSize + nAddSize >= (gArgs.GetBoolArg("-fastprune", false) ? 0x10000 /* 64kb */ : MAX_BLOCKFILE_SIZE)) {
628628
// when the undo file is keeping up with the block file, we want to flush it explicitly
629629
// when it is lagging behind (more blocks arrive than are being connected), we let the
630630
// undo block write case handle it
631-
finalize_undo = (vinfoBlockFile[nFile].nHeightLast == (unsigned int)active_chain.Tip()->nHeight);
631+
finalize_undo = (m_blockfile_info[nFile].nHeightLast == (unsigned int)active_chain.Tip()->nHeight);
632632
nFile++;
633-
if (vinfoBlockFile.size() <= nFile) {
634-
vinfoBlockFile.resize(nFile + 1);
633+
if (m_blockfile_info.size() <= nFile) {
634+
m_blockfile_info.resize(nFile + 1);
635635
}
636636
}
637637
pos.nFile = nFile;
638-
pos.nPos = vinfoBlockFile[nFile].nSize;
638+
pos.nPos = m_blockfile_info[nFile].nSize;
639639
}
640640

641-
if ((int)nFile != nLastBlockFile) {
641+
if ((int)nFile != m_last_blockfile) {
642642
if (!fKnown) {
643-
LogPrint(BCLog::BLOCKSTORE, "Leaving block file %i: %s\n", nLastBlockFile, vinfoBlockFile[nLastBlockFile].ToString());
643+
LogPrint(BCLog::BLOCKSTORE, "Leaving block file %i: %s\n", m_last_blockfile, m_blockfile_info[m_last_blockfile].ToString());
644644
}
645645
FlushBlockFile(!fKnown, finalize_undo);
646-
nLastBlockFile = nFile;
646+
m_last_blockfile = nFile;
647647
}
648648

649-
vinfoBlockFile[nFile].AddBlock(nHeight, nTime);
649+
m_blockfile_info[nFile].AddBlock(nHeight, nTime);
650650
if (fKnown) {
651-
vinfoBlockFile[nFile].nSize = std::max(pos.nPos + nAddSize, vinfoBlockFile[nFile].nSize);
651+
m_blockfile_info[nFile].nSize = std::max(pos.nPos + nAddSize, m_blockfile_info[nFile].nSize);
652652
} else {
653-
vinfoBlockFile[nFile].nSize += nAddSize;
653+
m_blockfile_info[nFile].nSize += nAddSize;
654654
}
655655

656656
if (!fKnown) {
@@ -660,11 +660,11 @@ bool BlockManager::FindBlockPos(FlatFilePos& pos, unsigned int nAddSize, unsigne
660660
return AbortNode("Disk space is too low!", _("Disk space is too low!"));
661661
}
662662
if (bytes_allocated != 0 && fPruneMode) {
663-
fCheckForPruning = true;
663+
m_check_for_pruning = true;
664664
}
665665
}
666666

667-
setDirtyFileInfo.insert(nFile);
667+
m_dirty_fileinfo.insert(nFile);
668668
return true;
669669
}
670670

@@ -674,17 +674,17 @@ bool BlockManager::FindUndoPos(BlockValidationState& state, int nFile, FlatFileP
674674

675675
LOCK(cs_LastBlockFile);
676676

677-
pos.nPos = vinfoBlockFile[nFile].nUndoSize;
678-
vinfoBlockFile[nFile].nUndoSize += nAddSize;
679-
setDirtyFileInfo.insert(nFile);
677+
pos.nPos = m_blockfile_info[nFile].nUndoSize;
678+
m_blockfile_info[nFile].nUndoSize += nAddSize;
679+
m_dirty_fileinfo.insert(nFile);
680680

681681
bool out_of_space;
682682
size_t bytes_allocated = UndoFileSeq().Allocate(pos, nAddSize, out_of_space);
683683
if (out_of_space) {
684684
return AbortNode(state, "Disk space is too low!", _("Disk space is too low!"));
685685
}
686686
if (bytes_allocated != 0 && fPruneMode) {
687-
fCheckForPruning = true;
687+
m_check_for_pruning = true;
688688
}
689689

690690
return true;
@@ -729,14 +729,14 @@ bool BlockManager::WriteUndoDataForBlock(const CBlockUndo& blockundo, BlockValid
729729
// in the block file info as below; note that this does not catch the case where the undo writes are keeping up
730730
// with the block writes (usually when a synced up node is getting newly mined blocks) -- this case is caught in
731731
// the FindBlockPos function
732-
if (_pos.nFile < nLastBlockFile && static_cast<uint32_t>(pindex->nHeight) == vinfoBlockFile[_pos.nFile].nHeightLast) {
732+
if (_pos.nFile < m_last_blockfile && static_cast<uint32_t>(pindex->nHeight) == m_blockfile_info[_pos.nFile].nHeightLast) {
733733
FlushUndoFile(_pos.nFile, true);
734734
}
735735

736736
// update nUndoPos in block index
737737
pindex->nUndoPos = _pos.nPos;
738738
pindex->nStatus |= BLOCK_HAVE_UNDO;
739-
setDirtyBlockIndex.insert(pindex);
739+
m_dirty_blockindex.insert(pindex);
740740
}
741741

742742
return true;

src/node/blockstorage.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class BlockManager
8181
* space is allocated in a block or undo file, staying below the target. Changing back to unpruned requires a reindex
8282
* (which in this case means the blockchain must be re-downloaded.)
8383
*
84-
* Pruning functions are called from FlushStateToDisk when the fCheckForPruning flag has been set.
84+
* Pruning functions are called from FlushStateToDisk when the m_check_for_pruning flag has been set.
8585
* Block and undo files are deleted in lock-step (when blk00003.dat is deleted, so is rev00003.dat.)
8686
* Pruning cannot take place until the longest chain is at least a certain length (CChainParams::nPruneAfterHeight).
8787
* Pruning will never delete a block within a defined distance (currently 288) from the active chain's tip.
@@ -93,19 +93,19 @@ class BlockManager
9393
void FindFilesToPrune(std::set<int>& setFilesToPrune, uint64_t nPruneAfterHeight, int chain_tip_height, int prune_height, bool is_ibd);
9494

9595
RecursiveMutex cs_LastBlockFile;
96-
std::vector<CBlockFileInfo> vinfoBlockFile;
97-
int nLastBlockFile = 0;
96+
std::vector<CBlockFileInfo> m_blockfile_info;
97+
int m_last_blockfile = 0;
9898
/** Global flag to indicate we should check to see if there are
9999
* block/undo files that should be deleted. Set on startup
100100
* or if we allocate more file space when we're in prune mode
101101
*/
102-
bool fCheckForPruning = false;
102+
bool m_check_for_pruning = false;
103103

104104
/** Dirty block index entries. */
105-
std::set<CBlockIndex*> setDirtyBlockIndex;
105+
std::set<CBlockIndex*> m_dirty_blockindex;
106106

107107
/** Dirty block file entries. */
108-
std::set<int> setDirtyFileInfo;
108+
std::set<int> m_dirty_fileinfo;
109109

110110
public:
111111
BlockMap m_block_index GUARDED_BY(cs_main);
@@ -124,7 +124,7 @@ class BlockManager
124124
/**
125125
* Load the blocktree off disk and into memory. Populate certain metadata
126126
* per index entry (nStatus, nChainWork, nTimeMax, etc.) as well as peripheral
127-
* collections like setDirtyBlockIndex.
127+
* collections like m_dirty_blockindex.
128128
*/
129129
bool LoadBlockIndex(
130130
const Consensus::Params& consensus_params,

0 commit comments

Comments
 (0)