diff options
author | MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> | 2023-04-13 10:52:40 +0200 |
---|---|---|
committer | MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> | 2023-08-07 11:32:34 +0200 |
commit | fa20d734a29ba50cd19b78cb4fe39a2d826131b7 (patch) | |
tree | d326beceeeee9488e3f53de8cf8224003a877e89 /src/kernel | |
parent | fa8866990dba7817427977bfe834efdb17114d37 (diff) | |
download | bitcoin-fa20d734a29ba50cd19b78cb4fe39a2d826131b7.tar.xz |
refactor: Add and use kernel::ImportMempoolOptions
This allows optional named arguments with default values.
Diffstat (limited to 'src/kernel')
-rw-r--r-- | src/kernel/mempool_persist.cpp | 4 | ||||
-rw-r--r-- | src/kernel/mempool_persist.h | 5 |
2 files changed, 6 insertions, 3 deletions
diff --git a/src/kernel/mempool_persist.cpp b/src/kernel/mempool_persist.cpp index 030c0a2710..8c3d3d9c1f 100644 --- a/src/kernel/mempool_persist.cpp +++ b/src/kernel/mempool_persist.cpp @@ -36,11 +36,11 @@ namespace kernel { static const uint64_t MEMPOOL_DUMP_VERSION = 1; -bool LoadMempool(CTxMemPool& pool, const fs::path& load_path, Chainstate& active_chainstate, FopenFn mockable_fopen_function) +bool LoadMempool(CTxMemPool& pool, const fs::path& load_path, Chainstate& active_chainstate, ImportMempoolOptions&& opts) { if (load_path.empty()) return false; - FILE* filestr{mockable_fopen_function(load_path, "rb")}; + FILE* filestr{opts.mockable_fopen_function(load_path, "rb")}; CAutoFile file(filestr, SER_DISK, CLIENT_VERSION); if (file.IsNull()) { LogPrintf("Failed to open mempool file from disk. Continuing anyway.\n"); diff --git a/src/kernel/mempool_persist.h b/src/kernel/mempool_persist.h index 23c396c0f0..ac558353b7 100644 --- a/src/kernel/mempool_persist.h +++ b/src/kernel/mempool_persist.h @@ -17,10 +17,13 @@ bool DumpMempool(const CTxMemPool& pool, const fs::path& dump_path, fsbridge::FopenFn mockable_fopen_function = fsbridge::fopen, bool skip_file_commit = false); +struct ImportMempoolOptions { + fsbridge::FopenFn mockable_fopen_function{fsbridge::fopen}; +}; /** Import the file and attempt to add its contents to the mempool. */ bool LoadMempool(CTxMemPool& pool, const fs::path& load_path, Chainstate& active_chainstate, - fsbridge::FopenFn mockable_fopen_function = fsbridge::fopen); + ImportMempoolOptions&& opts); } // namespace kernel |