@@ -352,7 +352,7 @@ bool BlockManager::LoadBlockIndexDB(const Consensus::Params& consensus_params)
352352 }
353353 for (std::set<int >::iterator it = setBlkDataFiles.begin (); it != setBlkDataFiles.end (); it++) {
354354 FlatFilePos pos (*it, 0 );
355- if (CAutoFile ( OpenBlockFile (pos, true ), SER_DISK, CLIENT_VERSION) .IsNull ()) {
355+ if (AutoFile{ OpenBlockFile (pos, true )} .IsNull ()) {
356356 return false ;
357357 }
358358 }
@@ -454,13 +454,13 @@ CBlockFileInfo* BlockManager::GetBlockFileInfo(size_t n)
454454static bool UndoWriteToDisk (const CBlockUndo& blockundo, FlatFilePos& pos, const uint256& hashBlock, const CMessageHeader::MessageStartChars& messageStart)
455455{
456456 // Open history file to append
457- CAutoFile fileout ( OpenUndoFile (pos), SER_DISK, CLIENT_VERSION) ;
457+ AutoFile fileout{ OpenUndoFile (pos)} ;
458458 if (fileout.IsNull ()) {
459459 return error (" %s: OpenUndoFile failed" , __func__);
460460 }
461461
462462 // Write index header
463- unsigned int nSize = GetSerializeSize (blockundo, fileout. GetVersion () );
463+ unsigned int nSize = GetSerializeSize (blockundo, CLIENT_VERSION );
464464 fileout << messageStart << nSize;
465465
466466 // Write undo data
@@ -489,14 +489,14 @@ bool UndoReadFromDisk(CBlockUndo& blockundo, const CBlockIndex* pindex)
489489 }
490490
491491 // Open history file to read
492- CAutoFile filein ( OpenUndoFile (pos, true ), SER_DISK, CLIENT_VERSION) ;
492+ AutoFile filein{ OpenUndoFile (pos, true )} ;
493493 if (filein.IsNull ()) {
494494 return error (" %s: OpenUndoFile failed" , __func__);
495495 }
496496
497497 // Read block
498498 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
500500 try {
501501 verifier << pindex->pprev ->GetBlockHash ();
502502 verifier >> blockundo;
@@ -768,7 +768,7 @@ bool ReadRawBlockFromDisk(std::vector<uint8_t>& block, const FlatFilePos& pos, c
768768{
769769 FlatFilePos hpos = pos;
770770 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 )} ;
772772 if (filein.IsNull ()) {
773773 return error (" %s: OpenBlockFile failed for %s" , __func__, pos.ToString ());
774774 }
0 commit comments