@@ -69,7 +69,7 @@ CBlockIndex* BlockManager::AddToBlockIndex(const CBlockHeader& block)
69
69
if (pindexBestHeader == nullptr || pindexBestHeader->nChainWork < pindexNew->nChainWork )
70
70
pindexBestHeader = pindexNew;
71
71
72
- setDirtyBlockIndex .insert (pindexNew);
72
+ m_dirty_blockindex .insert (pindexNew);
73
73
74
74
return pindexNew;
75
75
}
@@ -87,7 +87,7 @@ void BlockManager::PruneOneBlockFile(const int fileNumber)
87
87
pindex->nFile = 0 ;
88
88
pindex->nDataPos = 0 ;
89
89
pindex->nUndoPos = 0 ;
90
- setDirtyBlockIndex .insert (pindex);
90
+ m_dirty_blockindex .insert (pindex);
91
91
92
92
// Prune from m_blocks_unlinked -- any block we prune would have
93
93
// to be downloaded again in order to consider its chain, at which
@@ -104,8 +104,8 @@ void BlockManager::PruneOneBlockFile(const int fileNumber)
104
104
}
105
105
}
106
106
107
- vinfoBlockFile [fileNumber].SetNull ();
108
- setDirtyFileInfo .insert (fileNumber);
107
+ m_blockfile_info [fileNumber].SetNull ();
108
+ m_dirty_fileinfo .insert (fileNumber);
109
109
}
110
110
111
111
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
120
120
// last block to prune is the lesser of (user-specified height, MIN_BLOCKS_TO_KEEP from the tip)
121
121
unsigned int nLastBlockWeCanPrune = std::min ((unsigned )nManualPruneHeight, chain_tip_height - MIN_BLOCKS_TO_KEEP);
122
122
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) {
125
125
continue ;
126
126
}
127
127
PruneOneBlockFile (fileNumber);
@@ -160,10 +160,10 @@ void BlockManager::FindFilesToPrune(std::set<int>& setFilesToPrune, uint64_t nPr
160
160
nBuffer += nPruneTarget / 10 ;
161
161
}
162
162
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 ;
165
165
166
- if (vinfoBlockFile [fileNumber].nSize == 0 ) {
166
+ if (m_blockfile_info [fileNumber].nSize == 0 ) {
167
167
continue ;
168
168
}
169
169
@@ -172,7 +172,7 @@ void BlockManager::FindFilesToPrune(std::set<int>& setFilesToPrune, uint64_t nPr
172
172
}
173
173
174
174
// 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) {
176
176
continue ;
177
177
}
178
178
@@ -273,7 +273,7 @@ bool BlockManager::LoadBlockIndex(
273
273
}
274
274
if (!(pindex->nStatus & BLOCK_FAILED_MASK) && pindex->pprev && (pindex->pprev ->nStatus & BLOCK_FAILED_MASK)) {
275
275
pindex->nStatus |= BLOCK_FAILED_CHILD;
276
- setDirtyBlockIndex .insert (pindex);
276
+ m_dirty_blockindex .insert (pindex);
277
277
}
278
278
if (pindex->IsAssumedValid () ||
279
279
(pindex->IsValid (BLOCK_VALID_TRANSACTIONS) &&
@@ -332,27 +332,27 @@ void BlockManager::Unload()
332
332
333
333
m_block_index.clear ();
334
334
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 ();
339
339
}
340
340
341
341
bool BlockManager::WriteBlockIndexDB ()
342
342
{
343
343
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++);
348
348
}
349
349
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 ();) {
352
352
vBlocks.push_back (*it);
353
- setDirtyBlockIndex .erase (it++);
353
+ m_dirty_blockindex .erase (it++);
354
354
}
355
- if (!m_block_tree_db->WriteBatchSync (vFiles, nLastBlockFile , vBlocks)) {
355
+ if (!m_block_tree_db->WriteBatchSync (vFiles, m_last_blockfile , vBlocks)) {
356
356
return false ;
357
357
}
358
358
return true ;
@@ -365,17 +365,17 @@ bool BlockManager::LoadBlockIndexDB(ChainstateManager& chainman)
365
365
}
366
366
367
367
// 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++) {
376
376
CBlockFileInfo info;
377
377
if (m_block_tree_db->ReadBlockFileInfo (nFile, info)) {
378
- vinfoBlockFile .push_back (info);
378
+ m_blockfile_info .push_back (info);
379
379
} else {
380
380
break ;
381
381
}
@@ -433,7 +433,7 @@ bool IsBlockPruned(const CBlockIndex* pblockindex)
433
433
// If we're using -prune with -reindex, then delete block files that will be ignored by the
434
434
// reindex. Since reindexing works by starting at block file 0 and looping until a blockfile
435
435
// 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
437
437
// is in sync with what's actually on disk by the time we start downloading, so that pruning
438
438
// works correctly.
439
439
void CleanupBlockRevFiles ()
@@ -482,7 +482,7 @@ CBlockFileInfo* BlockManager::GetBlockFileInfo(size_t n)
482
482
{
483
483
LOCK (cs_LastBlockFile);
484
484
485
- return &vinfoBlockFile .at (n);
485
+ return &m_blockfile_info .at (n);
486
486
}
487
487
488
488
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)
548
548
549
549
void BlockManager::FlushUndoFile (int block_file, bool finalize)
550
550
{
551
- FlatFilePos undo_pos_old (block_file, vinfoBlockFile [block_file].nUndoSize );
551
+ FlatFilePos undo_pos_old (block_file, m_blockfile_info [block_file].nUndoSize );
552
552
if (!UndoFileSeq ().Flush (undo_pos_old, finalize)) {
553
553
AbortNode (" Flushing undo file to disk failed. This is likely the result of an I/O error." );
554
554
}
@@ -557,21 +557,21 @@ void BlockManager::FlushUndoFile(int block_file, bool finalize)
557
557
void BlockManager::FlushBlockFile (bool fFinalize , bool finalize_undo)
558
558
{
559
559
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 );
561
561
if (!BlockFileSeq ().Flush (block_pos_old, fFinalize )) {
562
562
AbortNode (" Flushing block file to disk failed. This is likely the result of an I/O error." );
563
563
}
564
564
// we do not always flush the undo file, as the chain tip may be lagging behind the incoming blocks,
565
565
// 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);
567
567
}
568
568
569
569
uint64_t BlockManager::CalculateCurrentUsage ()
570
570
{
571
571
LOCK (cs_LastBlockFile);
572
572
573
573
uint64_t retval = 0 ;
574
- for (const CBlockFileInfo& file : vinfoBlockFile ) {
574
+ for (const CBlockFileInfo& file : m_blockfile_info ) {
575
575
retval += file.nSize + file.nUndoSize ;
576
576
}
577
577
return retval;
@@ -617,40 +617,40 @@ bool BlockManager::FindBlockPos(FlatFilePos& pos, unsigned int nAddSize, unsigne
617
617
{
618
618
LOCK (cs_LastBlockFile);
619
619
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 );
623
623
}
624
624
625
625
bool finalize_undo = false ;
626
626
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)) {
628
628
// when the undo file is keeping up with the block file, we want to flush it explicitly
629
629
// when it is lagging behind (more blocks arrive than are being connected), we let the
630
630
// 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 );
632
632
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 );
635
635
}
636
636
}
637
637
pos.nFile = nFile;
638
- pos.nPos = vinfoBlockFile [nFile].nSize ;
638
+ pos.nPos = m_blockfile_info [nFile].nSize ;
639
639
}
640
640
641
- if ((int )nFile != nLastBlockFile ) {
641
+ if ((int )nFile != m_last_blockfile ) {
642
642
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 ());
644
644
}
645
645
FlushBlockFile (!fKnown , finalize_undo);
646
- nLastBlockFile = nFile;
646
+ m_last_blockfile = nFile;
647
647
}
648
648
649
- vinfoBlockFile [nFile].AddBlock (nHeight, nTime);
649
+ m_blockfile_info [nFile].AddBlock (nHeight, nTime);
650
650
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 );
652
652
} else {
653
- vinfoBlockFile [nFile].nSize += nAddSize;
653
+ m_blockfile_info [nFile].nSize += nAddSize;
654
654
}
655
655
656
656
if (!fKnown ) {
@@ -660,11 +660,11 @@ bool BlockManager::FindBlockPos(FlatFilePos& pos, unsigned int nAddSize, unsigne
660
660
return AbortNode (" Disk space is too low!" , _ (" Disk space is too low!" ));
661
661
}
662
662
if (bytes_allocated != 0 && fPruneMode ) {
663
- fCheckForPruning = true ;
663
+ m_check_for_pruning = true ;
664
664
}
665
665
}
666
666
667
- setDirtyFileInfo .insert (nFile);
667
+ m_dirty_fileinfo .insert (nFile);
668
668
return true ;
669
669
}
670
670
@@ -674,17 +674,17 @@ bool BlockManager::FindUndoPos(BlockValidationState& state, int nFile, FlatFileP
674
674
675
675
LOCK (cs_LastBlockFile);
676
676
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);
680
680
681
681
bool out_of_space;
682
682
size_t bytes_allocated = UndoFileSeq ().Allocate (pos, nAddSize, out_of_space);
683
683
if (out_of_space) {
684
684
return AbortNode (state, " Disk space is too low!" , _ (" Disk space is too low!" ));
685
685
}
686
686
if (bytes_allocated != 0 && fPruneMode ) {
687
- fCheckForPruning = true ;
687
+ m_check_for_pruning = true ;
688
688
}
689
689
690
690
return true ;
@@ -729,14 +729,14 @@ bool BlockManager::WriteUndoDataForBlock(const CBlockUndo& blockundo, BlockValid
729
729
// in the block file info as below; note that this does not catch the case where the undo writes are keeping up
730
730
// with the block writes (usually when a synced up node is getting newly mined blocks) -- this case is caught in
731
731
// 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 ) {
733
733
FlushUndoFile (_pos.nFile , true );
734
734
}
735
735
736
736
// update nUndoPos in block index
737
737
pindex->nUndoPos = _pos.nPos ;
738
738
pindex->nStatus |= BLOCK_HAVE_UNDO;
739
- setDirtyBlockIndex .insert (pindex);
739
+ m_dirty_blockindex .insert (pindex);
740
740
}
741
741
742
742
return true ;
0 commit comments