File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed
Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -163,7 +163,7 @@ class CBlockIndex
163163 int nHeight{0 };
164164
165165 // ! Which # file this block is stored in (blk?????.dat)
166- int nFile GUARDED_BY (::cs_main){0 };
166+ int nFile GUARDED_BY (::cs_main){- 1 };
167167
168168 // ! Byte offset within blk?????.dat where this block's data is stored
169169 unsigned int nDataPos GUARDED_BY (::cs_main){0 };
Original file line number Diff line number Diff line change @@ -127,7 +127,7 @@ void BlockManager::PruneOneBlockFile(const int fileNumber)
127127 if (pindex->nFile == fileNumber) {
128128 pindex->nStatus &= ~BLOCK_HAVE_DATA;
129129 pindex->nStatus &= ~BLOCK_HAVE_UNDO;
130- pindex->nFile = 0 ;
130+ pindex->nFile = - 1 ;
131131 pindex->nDataPos = 0 ;
132132 pindex->nUndoPos = 0 ;
133133 m_dirty_blockindex.insert (pindex);
@@ -345,9 +345,15 @@ bool BlockManager::LoadBlockIndexDB(const Consensus::Params& consensus_params)
345345 // Check presence of blk files
346346 LogPrintf (" Checking all blk files are present...\n " );
347347 std::set<int > setBlkDataFiles;
348- for (const auto & [_, block_index] : m_block_index) {
348+ for (auto & [_, block_index] : m_block_index) {
349349 if (block_index.nStatus & BLOCK_HAVE_DATA) {
350350 setBlkDataFiles.insert (block_index.nFile );
351+ } else {
352+ // In case we don't have the block, the position must be -1.
353+ // (applies to older clients that set 'nFile=0' during pruning)
354+ if (block_index.nFile == 0 ) {
355+ block_index.nFile = -1 ;
356+ }
351357 }
352358 }
353359 for (std::set<int >::iterator it = setBlkDataFiles.begin (); it != setBlkDataFiles.end (); it++) {
You can’t perform that action at this time.
0 commit comments