0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-03-05 14:06:27 -05:00

Move FopenFn to fsbridge namespace

[META] In a future commit in this patchset, it will be used by more than
       just validation, and it needs to align with fopen anyway.
This commit is contained in:
Carl Dong 2022-07-13 12:32:43 -04:00
parent ae1e8e3756
commit b3267258b0
3 changed files with 6 additions and 4 deletions

View file

@ -9,6 +9,7 @@
#include <cstdio> #include <cstdio>
#include <filesystem> #include <filesystem>
#include <functional>
#include <iomanip> #include <iomanip>
#include <ios> #include <ios>
#include <ostream> #include <ostream>
@ -199,6 +200,7 @@ bool create_directories(const std::filesystem::path& p, std::error_code& ec) = d
/** Bridge operations to C stdio */ /** Bridge operations to C stdio */
namespace fsbridge { namespace fsbridge {
using FopenFn = std::function<FILE*(const fs::path&, const char*)>;
FILE *fopen(const fs::path& p, const char *mode); FILE *fopen(const fs::path& p, const char *mode);
/** /**

View file

@ -17,6 +17,7 @@
#include <consensus/validation.h> #include <consensus/validation.h>
#include <cuckoocache.h> #include <cuckoocache.h>
#include <flatfile.h> #include <flatfile.h>
#include <fs.h>
#include <hash.h> #include <hash.h>
#include <kernel/coinstats.h> #include <kernel/coinstats.h>
#include <logging.h> #include <logging.h>
@ -64,6 +65,7 @@ using kernel::CCoinsStats;
using kernel::CoinStatsHashType; using kernel::CoinStatsHashType;
using kernel::ComputeUTXOStats; using kernel::ComputeUTXOStats;
using fsbridge::FopenFn;
using node::BLOCKFILE_CHUNK_SIZE; using node::BLOCKFILE_CHUNK_SIZE;
using node::BlockManager; using node::BlockManager;
using node::BlockMap; using node::BlockMap;

View file

@ -1014,13 +1014,11 @@ bool DeploymentEnabled(const ChainstateManager& chainman, DEP dep)
return DeploymentEnabled(chainman.GetConsensus(), dep); return DeploymentEnabled(chainman.GetConsensus(), dep);
} }
using FopenFn = std::function<FILE*(const fs::path&, const char*)>;
/** Dump the mempool to disk. */ /** Dump the mempool to disk. */
bool DumpMempool(const CTxMemPool& pool, const fs::path& dump_path, FopenFn mockable_fopen_function = fsbridge::fopen, bool skip_file_commit = false); bool DumpMempool(const CTxMemPool& pool, const fs::path& dump_path, fsbridge::FopenFn mockable_fopen_function = fsbridge::fopen, bool skip_file_commit = false);
/** Load the mempool from disk. */ /** Load the mempool from disk. */
bool LoadMempool(CTxMemPool& pool, CChainState& active_chainstate, FopenFn mockable_fopen_function = fsbridge::fopen); bool LoadMempool(CTxMemPool& pool, CChainState& active_chainstate, fsbridge::FopenFn mockable_fopen_function = fsbridge::fopen);
/** /**
* Return the expected assumeutxo value for a given height, if one exists. * Return the expected assumeutxo value for a given height, if one exists.