@@ -5010,11 +5010,11 @@ CBlockFileInfo* GetBlockFileInfo(size_t n)
5010
5010
5011
5011
static const uint64_t MEMPOOL_DUMP_VERSION = 1 ;
5012
5012
5013
- bool LoadMempool (CTxMemPool& pool, CChainState& active_chainstate)
5013
+ bool LoadMempool (CTxMemPool& pool, CChainState& active_chainstate, FopenFn mockable_fopen_function )
5014
5014
{
5015
5015
const CChainParams& chainparams = Params ();
5016
5016
int64_t nExpiryTimeout = gArgs .GetArg (" -mempoolexpiry" , DEFAULT_MEMPOOL_EXPIRY) * 60 * 60 ;
5017
- FILE* filestr = fsbridge::fopen (GetDataDir () / " mempool.dat" , " rb" );
5017
+ FILE* filestr{ mockable_fopen_function (GetDataDir () / " mempool.dat" , " rb" )} ;
5018
5018
CAutoFile file (filestr, SER_DISK, CLIENT_VERSION);
5019
5019
if (file.IsNull ()) {
5020
5020
LogPrintf (" Failed to open mempool file from disk. Continuing anyway.\n " );
@@ -5095,7 +5095,7 @@ bool LoadMempool(CTxMemPool& pool, CChainState& active_chainstate)
5095
5095
return true ;
5096
5096
}
5097
5097
5098
- bool DumpMempool (const CTxMemPool& pool)
5098
+ bool DumpMempool (const CTxMemPool& pool, FopenFn mockable_fopen_function, bool skip_file_commit )
5099
5099
{
5100
5100
int64_t start = GetTimeMicros ();
5101
5101
@@ -5118,7 +5118,7 @@ bool DumpMempool(const CTxMemPool& pool)
5118
5118
int64_t mid = GetTimeMicros ();
5119
5119
5120
5120
try {
5121
- FILE* filestr = fsbridge::fopen (GetDataDir () / " mempool.dat.new" , " wb" );
5121
+ FILE* filestr{ mockable_fopen_function (GetDataDir () / " mempool.dat.new" , " wb" )} ;
5122
5122
if (!filestr) {
5123
5123
return false ;
5124
5124
}
@@ -5141,7 +5141,7 @@ bool DumpMempool(const CTxMemPool& pool)
5141
5141
LogPrintf (" Writing %d unbroadcast transactions to disk.\n " , unbroadcast_txids.size ());
5142
5142
file << unbroadcast_txids;
5143
5143
5144
- if (!FileCommit (file.Get ()))
5144
+ if (!skip_file_commit && ! FileCommit (file.Get ()))
5145
5145
throw std::runtime_error (" FileCommit failed" );
5146
5146
file.fclose ();
5147
5147
if (!RenameOver (GetDataDir () / " mempool.dat.new" , GetDataDir () / " mempool.dat" )) {
0 commit comments