44
55#include < node/blockstorage.h>
66
7+ #include < arith_uint256.h>
78#include < chain.h>
8- #include < clientversion .h>
9+ #include < consensus/params .h>
910#include < consensus/validation.h>
1011#include < dbwrapper.h>
1112#include < flatfile.h>
1213#include < hash.h>
13- #include < kernel/chain .h>
14+ #include < kernel/blockmanager_opts .h>
1415#include < kernel/chainparams.h>
1516#include < kernel/messagestartchars.h>
17+ #include < kernel/notifications_interface.h>
1618#include < logging.h>
1719#include < pow.h>
20+ #include < primitives/block.h>
21+ #include < primitives/transaction.h>
1822#include < reverse_iterator.h>
23+ #include < serialize.h>
1924#include < signet.h>
25+ #include < span.h>
2026#include < streams.h>
2127#include < sync.h>
28+ #include < tinyformat.h>
29+ #include < uint256.h>
2230#include < undo.h>
2331#include < util/batchpriority.h>
32+ #include < util/check.h>
2433#include < util/fs.h>
2534#include < util/signalinterrupt.h>
2635#include < util/strencodings.h>
@@ -656,7 +665,7 @@ CBlockFileInfo* BlockManager::GetBlockFileInfo(size_t n)
656665bool BlockManager::UndoWriteToDisk (const CBlockUndo& blockundo, FlatFilePos& pos, const uint256& hashBlock) const
657666{
658667 // Open history file to append
659- CAutoFile fileout{OpenUndoFile (pos)};
668+ AutoFile fileout{OpenUndoFile (pos)};
660669 if (fileout.IsNull ()) {
661670 return error (" %s: OpenUndoFile failed" , __func__);
662671 }
@@ -691,7 +700,7 @@ bool BlockManager::UndoReadFromDisk(CBlockUndo& blockundo, const CBlockIndex& in
691700 }
692701
693702 // Open history file to read
694- CAutoFile filein{OpenUndoFile (pos, true )};
703+ AutoFile filein{OpenUndoFile (pos, true )};
695704 if (filein.IsNull ()) {
696705 return error (" %s: OpenUndoFile failed" , __func__);
697706 }
@@ -810,15 +819,15 @@ FlatFileSeq BlockManager::UndoFileSeq() const
810819 return FlatFileSeq (m_opts.blocks_dir , " rev" , UNDOFILE_CHUNK_SIZE);
811820}
812821
813- CAutoFile BlockManager::OpenBlockFile (const FlatFilePos& pos, bool fReadOnly ) const
822+ AutoFile BlockManager::OpenBlockFile (const FlatFilePos& pos, bool fReadOnly ) const
814823{
815- return CAutoFile {BlockFileSeq ().Open (pos, fReadOnly ), CLIENT_VERSION };
824+ return AutoFile {BlockFileSeq ().Open (pos, fReadOnly )};
816825}
817826
818827/* * Open an undo file (rev?????.dat) */
819- CAutoFile BlockManager::OpenUndoFile (const FlatFilePos& pos, bool fReadOnly ) const
828+ AutoFile BlockManager::OpenUndoFile (const FlatFilePos& pos, bool fReadOnly ) const
820829{
821- return CAutoFile {UndoFileSeq ().Open (pos, fReadOnly ), CLIENT_VERSION };
830+ return AutoFile {UndoFileSeq ().Open (pos, fReadOnly )};
822831}
823832
824833fs::path BlockManager::GetBlockPosFilename (const FlatFilePos& pos) const
@@ -950,7 +959,7 @@ bool BlockManager::FindUndoPos(BlockValidationState& state, int nFile, FlatFileP
950959bool BlockManager::WriteBlockToDisk (const CBlock& block, FlatFilePos& pos) const
951960{
952961 // Open history file to append
953- CAutoFile fileout{OpenBlockFile (pos)};
962+ AutoFile fileout{OpenBlockFile (pos)};
954963 if (fileout.IsNull ()) {
955964 return error (" WriteBlockToDisk: OpenBlockFile failed" );
956965 }
@@ -1016,7 +1025,7 @@ bool BlockManager::ReadBlockFromDisk(CBlock& block, const FlatFilePos& pos) cons
10161025 block.SetNull ();
10171026
10181027 // Open history file to read
1019- CAutoFile filein{OpenBlockFile (pos, true )};
1028+ AutoFile filein{OpenBlockFile (pos, true )};
10201029 if (filein.IsNull ()) {
10211030 return error (" ReadBlockFromDisk: OpenBlockFile failed for %s" , pos.ToString ());
10221031 }
@@ -1059,7 +1068,7 @@ bool BlockManager::ReadRawBlockFromDisk(std::vector<uint8_t>& block, const FlatF
10591068{
10601069 FlatFilePos hpos = pos;
10611070 hpos.nPos -= 8 ; // Seek back 8 bytes for meta header
1062- CAutoFile filein{OpenBlockFile (hpos, true )};
1071+ AutoFile filein{OpenBlockFile (hpos, true )};
10631072 if (filein.IsNull ()) {
10641073 return error (" %s: OpenBlockFile failed for %s" , __func__, pos.ToString ());
10651074 }
@@ -1151,7 +1160,7 @@ void ImportBlocks(ChainstateManager& chainman, std::vector<fs::path> vImportFile
11511160 if (!fs::exists (chainman.m_blockman .GetBlockPosFilename (pos))) {
11521161 break ; // No block files left to reindex
11531162 }
1154- CAutoFile file{chainman.m_blockman .OpenBlockFile (pos, true )};
1163+ AutoFile file{chainman.m_blockman .OpenBlockFile (pos, true )};
11551164 if (file.IsNull ()) {
11561165 break ; // This error is logged in OpenBlockFile
11571166 }
@@ -1172,7 +1181,7 @@ void ImportBlocks(ChainstateManager& chainman, std::vector<fs::path> vImportFile
11721181
11731182 // -loadblock=
11741183 for (const fs::path& path : vImportFiles) {
1175- CAutoFile file{fsbridge::fopen (path, " rb" ), CLIENT_VERSION };
1184+ AutoFile file{fsbridge::fopen (path, " rb" )};
11761185 if (!file.IsNull ()) {
11771186 LogPrintf (" Importing blocks file %s...\n " , fs::PathToString (path));
11781187 chainman.LoadExternalBlockFile (file);
0 commit comments