@@ -352,7 +352,7 @@ bool BlockManager::LoadBlockIndexDB(const Consensus::Params& consensus_params)
352
352
}
353
353
for (std::set<int >::iterator it = setBlkDataFiles.begin (); it != setBlkDataFiles.end (); it++) {
354
354
FlatFilePos pos (*it, 0 );
355
- if (CAutoFile ( OpenBlockFile (pos, true ), SER_DISK, CLIENT_VERSION) .IsNull ()) {
355
+ if (AutoFile{ OpenBlockFile (pos, true )} .IsNull ()) {
356
356
return false ;
357
357
}
358
358
}
@@ -454,13 +454,13 @@ CBlockFileInfo* BlockManager::GetBlockFileInfo(size_t n)
454
454
static bool UndoWriteToDisk (const CBlockUndo& blockundo, FlatFilePos& pos, const uint256& hashBlock, const CMessageHeader::MessageStartChars& messageStart)
455
455
{
456
456
// Open history file to append
457
- CAutoFile fileout ( OpenUndoFile (pos), SER_DISK, CLIENT_VERSION) ;
457
+ AutoFile fileout{ OpenUndoFile (pos)} ;
458
458
if (fileout.IsNull ()) {
459
459
return error (" %s: OpenUndoFile failed" , __func__);
460
460
}
461
461
462
462
// Write index header
463
- unsigned int nSize = GetSerializeSize (blockundo, fileout. GetVersion () );
463
+ unsigned int nSize = GetSerializeSize (blockundo, CLIENT_VERSION );
464
464
fileout << messageStart << nSize;
465
465
466
466
// Write undo data
@@ -489,14 +489,14 @@ bool UndoReadFromDisk(CBlockUndo& blockundo, const CBlockIndex* pindex)
489
489
}
490
490
491
491
// Open history file to read
492
- CAutoFile filein ( OpenUndoFile (pos, true ), SER_DISK, CLIENT_VERSION) ;
492
+ AutoFile filein{ OpenUndoFile (pos, true )} ;
493
493
if (filein.IsNull ()) {
494
494
return error (" %s: OpenUndoFile failed" , __func__);
495
495
}
496
496
497
497
// Read block
498
498
uint256 hashChecksum;
499
- CHashVerifier<CAutoFile> verifier (& filein) ; // We need a CHashVerifier as reserializing may lose data
499
+ HashVerifier verifier{ filein} ; // Use HashVerifier as reserializing may lose data, c.f. commit d342424301013ec47dc146a4beb49d5c9319d80a
500
500
try {
501
501
verifier << pindex->pprev ->GetBlockHash ();
502
502
verifier >> blockundo;
@@ -768,7 +768,7 @@ bool ReadRawBlockFromDisk(std::vector<uint8_t>& block, const FlatFilePos& pos, c
768
768
{
769
769
FlatFilePos hpos = pos;
770
770
hpos.nPos -= 8 ; // Seek back 8 bytes for meta header
771
- CAutoFile filein ( OpenBlockFile (hpos, true ), SER_DISK, CLIENT_VERSION) ;
771
+ AutoFile filein{ OpenBlockFile (hpos, true )} ;
772
772
if (filein.IsNull ()) {
773
773
return error (" %s: OpenBlockFile failed for %s" , __func__, pos.ToString ());
774
774
}
0 commit comments