mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 06:43:45 +01:00
blockstorage: switch from CAutoFile to AutoFile
Also bump includes per suggestions from iwyu.
This commit is contained in:
@@ -4,23 +4,32 @@
|
||||
|
||||
#include <node/blockstorage.h>
|
||||
|
||||
#include <arith_uint256.h>
|
||||
#include <chain.h>
|
||||
#include <clientversion.h>
|
||||
#include <consensus/params.h>
|
||||
#include <consensus/validation.h>
|
||||
#include <dbwrapper.h>
|
||||
#include <flatfile.h>
|
||||
#include <hash.h>
|
||||
#include <kernel/chain.h>
|
||||
#include <kernel/blockmanager_opts.h>
|
||||
#include <kernel/chainparams.h>
|
||||
#include <kernel/messagestartchars.h>
|
||||
#include <kernel/notifications_interface.h>
|
||||
#include <logging.h>
|
||||
#include <pow.h>
|
||||
#include <primitives/block.h>
|
||||
#include <primitives/transaction.h>
|
||||
#include <reverse_iterator.h>
|
||||
#include <serialize.h>
|
||||
#include <signet.h>
|
||||
#include <span.h>
|
||||
#include <streams.h>
|
||||
#include <sync.h>
|
||||
#include <tinyformat.h>
|
||||
#include <uint256.h>
|
||||
#include <undo.h>
|
||||
#include <util/batchpriority.h>
|
||||
#include <util/check.h>
|
||||
#include <util/fs.h>
|
||||
#include <util/signalinterrupt.h>
|
||||
#include <util/strencodings.h>
|
||||
@@ -656,7 +665,7 @@ CBlockFileInfo* BlockManager::GetBlockFileInfo(size_t n)
|
||||
bool BlockManager::UndoWriteToDisk(const CBlockUndo& blockundo, FlatFilePos& pos, const uint256& hashBlock) const
|
||||
{
|
||||
// Open history file to append
|
||||
CAutoFile fileout{OpenUndoFile(pos)};
|
||||
AutoFile fileout{OpenUndoFile(pos)};
|
||||
if (fileout.IsNull()) {
|
||||
return error("%s: OpenUndoFile failed", __func__);
|
||||
}
|
||||
@@ -691,7 +700,7 @@ bool BlockManager::UndoReadFromDisk(CBlockUndo& blockundo, const CBlockIndex& in
|
||||
}
|
||||
|
||||
// Open history file to read
|
||||
CAutoFile filein{OpenUndoFile(pos, true)};
|
||||
AutoFile filein{OpenUndoFile(pos, true)};
|
||||
if (filein.IsNull()) {
|
||||
return error("%s: OpenUndoFile failed", __func__);
|
||||
}
|
||||
@@ -810,15 +819,15 @@ FlatFileSeq BlockManager::UndoFileSeq() const
|
||||
return FlatFileSeq(m_opts.blocks_dir, "rev", UNDOFILE_CHUNK_SIZE);
|
||||
}
|
||||
|
||||
CAutoFile BlockManager::OpenBlockFile(const FlatFilePos& pos, bool fReadOnly) const
|
||||
AutoFile BlockManager::OpenBlockFile(const FlatFilePos& pos, bool fReadOnly) const
|
||||
{
|
||||
return CAutoFile{BlockFileSeq().Open(pos, fReadOnly), CLIENT_VERSION};
|
||||
return AutoFile{BlockFileSeq().Open(pos, fReadOnly)};
|
||||
}
|
||||
|
||||
/** Open an undo file (rev?????.dat) */
|
||||
CAutoFile BlockManager::OpenUndoFile(const FlatFilePos& pos, bool fReadOnly) const
|
||||
AutoFile BlockManager::OpenUndoFile(const FlatFilePos& pos, bool fReadOnly) const
|
||||
{
|
||||
return CAutoFile{UndoFileSeq().Open(pos, fReadOnly), CLIENT_VERSION};
|
||||
return AutoFile{UndoFileSeq().Open(pos, fReadOnly)};
|
||||
}
|
||||
|
||||
fs::path BlockManager::GetBlockPosFilename(const FlatFilePos& pos) const
|
||||
@@ -950,7 +959,7 @@ bool BlockManager::FindUndoPos(BlockValidationState& state, int nFile, FlatFileP
|
||||
bool BlockManager::WriteBlockToDisk(const CBlock& block, FlatFilePos& pos) const
|
||||
{
|
||||
// Open history file to append
|
||||
CAutoFile fileout{OpenBlockFile(pos)};
|
||||
AutoFile fileout{OpenBlockFile(pos)};
|
||||
if (fileout.IsNull()) {
|
||||
return error("WriteBlockToDisk: OpenBlockFile failed");
|
||||
}
|
||||
@@ -1016,7 +1025,7 @@ bool BlockManager::ReadBlockFromDisk(CBlock& block, const FlatFilePos& pos) cons
|
||||
block.SetNull();
|
||||
|
||||
// Open history file to read
|
||||
CAutoFile filein{OpenBlockFile(pos, true)};
|
||||
AutoFile filein{OpenBlockFile(pos, true)};
|
||||
if (filein.IsNull()) {
|
||||
return error("ReadBlockFromDisk: OpenBlockFile failed for %s", pos.ToString());
|
||||
}
|
||||
@@ -1059,7 +1068,7 @@ bool BlockManager::ReadRawBlockFromDisk(std::vector<uint8_t>& block, const FlatF
|
||||
{
|
||||
FlatFilePos hpos = pos;
|
||||
hpos.nPos -= 8; // Seek back 8 bytes for meta header
|
||||
CAutoFile filein{OpenBlockFile(hpos, true)};
|
||||
AutoFile filein{OpenBlockFile(hpos, true)};
|
||||
if (filein.IsNull()) {
|
||||
return error("%s: OpenBlockFile failed for %s", __func__, pos.ToString());
|
||||
}
|
||||
@@ -1151,7 +1160,7 @@ void ImportBlocks(ChainstateManager& chainman, std::vector<fs::path> vImportFile
|
||||
if (!fs::exists(chainman.m_blockman.GetBlockPosFilename(pos))) {
|
||||
break; // No block files left to reindex
|
||||
}
|
||||
CAutoFile file{chainman.m_blockman.OpenBlockFile(pos, true)};
|
||||
AutoFile file{chainman.m_blockman.OpenBlockFile(pos, true)};
|
||||
if (file.IsNull()) {
|
||||
break; // This error is logged in OpenBlockFile
|
||||
}
|
||||
@@ -1172,7 +1181,7 @@ void ImportBlocks(ChainstateManager& chainman, std::vector<fs::path> vImportFile
|
||||
|
||||
// -loadblock=
|
||||
for (const fs::path& path : vImportFiles) {
|
||||
CAutoFile file{fsbridge::fopen(path, "rb"), CLIENT_VERSION};
|
||||
AutoFile file{fsbridge::fopen(path, "rb")};
|
||||
if (!file.IsNull()) {
|
||||
LogPrintf("Importing blocks file %s...\n", fs::PathToString(path));
|
||||
chainman.LoadExternalBlockFile(file);
|
||||
|
||||
@@ -8,21 +8,26 @@
|
||||
#include <attributes.h>
|
||||
#include <chain.h>
|
||||
#include <dbwrapper.h>
|
||||
#include <flatfile.h>
|
||||
#include <kernel/blockmanager_opts.h>
|
||||
#include <kernel/chain.h>
|
||||
#include <kernel/chainparams.h>
|
||||
#include <kernel/cs_main.h>
|
||||
#include <kernel/messagestartchars.h>
|
||||
#include <primitives/block.h>
|
||||
#include <streams.h>
|
||||
#include <sync.h>
|
||||
#include <uint256.h>
|
||||
#include <util/fs.h>
|
||||
#include <util/hasher.h>
|
||||
|
||||
#include <array>
|
||||
#include <atomic>
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <limits>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
@@ -30,14 +35,9 @@
|
||||
#include <vector>
|
||||
|
||||
class BlockValidationState;
|
||||
class CAutoFile;
|
||||
class CBlock;
|
||||
class CBlockUndo;
|
||||
class CChainParams;
|
||||
class Chainstate;
|
||||
class ChainstateManager;
|
||||
struct CCheckpointData;
|
||||
struct FlatFilePos;
|
||||
namespace Consensus {
|
||||
struct Params;
|
||||
}
|
||||
@@ -162,7 +162,7 @@ private:
|
||||
FlatFileSeq BlockFileSeq() const;
|
||||
FlatFileSeq UndoFileSeq() const;
|
||||
|
||||
CAutoFile OpenUndoFile(const FlatFilePos& pos, bool fReadOnly = false) const;
|
||||
AutoFile OpenUndoFile(const FlatFilePos& pos, bool fReadOnly = false) const;
|
||||
|
||||
bool WriteBlockToDisk(const CBlock& block, FlatFilePos& pos) const;
|
||||
bool UndoWriteToDisk(const CBlockUndo& blockundo, FlatFilePos& pos, const uint256& hashBlock) const;
|
||||
@@ -350,7 +350,7 @@ public:
|
||||
void UpdatePruneLock(const std::string& name, const PruneLockInfo& lock_info) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
|
||||
|
||||
/** Open a block file (blk?????.dat) */
|
||||
CAutoFile OpenBlockFile(const FlatFilePos& pos, bool fReadOnly = false) const;
|
||||
AutoFile OpenBlockFile(const FlatFilePos& pos, bool fReadOnly = false) const;
|
||||
|
||||
/** Translation to a filesystem path */
|
||||
fs::path GetBlockPosFilename(const FlatFilePos& pos) const;
|
||||
|
||||
Reference in New Issue
Block a user