File tree Expand file tree Collapse file tree 4 files changed +9
-4
lines changed Expand file tree Collapse file tree 4 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -116,7 +116,6 @@ static const char* FEE_ESTIMATES_FILENAME="fee_estimates.dat";
116
116
//
117
117
118
118
std::atomic<bool > fRequestShutdown (false );
119
- std::atomic<bool > fDumpMempoolLater (false );
120
119
121
120
void StartShutdown ()
122
121
{
@@ -208,7 +207,7 @@ void Shutdown()
208
207
threadGroup.interrupt_all ();
209
208
threadGroup.join_all ();
210
209
211
- if (fDumpMempoolLater && gArgs .GetArg (" -persistmempool" , DEFAULT_PERSIST_MEMPOOL)) {
210
+ if (g_is_mempool_loaded && gArgs .GetArg (" -persistmempool" , DEFAULT_PERSIST_MEMPOOL)) {
212
211
DumpMempool ();
213
212
}
214
213
@@ -692,8 +691,8 @@ void ThreadImport(std::vector<fs::path> vImportFiles)
692
691
} // End scope of CImportingNow
693
692
if (gArgs .GetArg (" -persistmempool" , DEFAULT_PERSIST_MEMPOOL)) {
694
693
LoadMempool ();
695
- fDumpMempoolLater = !fRequestShutdown ;
696
694
}
695
+ g_is_mempool_loaded = !fRequestShutdown ;
697
696
}
698
697
699
698
/* * Sanity checks
Original file line number Diff line number Diff line change @@ -1607,13 +1607,17 @@ UniValue savemempool(const JSONRPCRequest& request)
1607
1607
if (request.fHelp || request.params .size () != 0 ) {
1608
1608
throw std::runtime_error (
1609
1609
" savemempool\n "
1610
- " \n Dumps the mempool to disk.\n "
1610
+ " \n Dumps the mempool to disk. It will fail until the previous dump is fully loaded. \n "
1611
1611
" \n Examples:\n "
1612
1612
+ HelpExampleCli (" savemempool" , " " )
1613
1613
+ HelpExampleRpc (" savemempool" , " " )
1614
1614
);
1615
1615
}
1616
1616
1617
+ if (!g_is_mempool_loaded) {
1618
+ throw JSONRPCError (RPC_MISC_ERROR, " The mempool was not loaded yet" );
1619
+ }
1620
+
1617
1621
if (!DumpMempool ()) {
1618
1622
throw JSONRPCError (RPC_MISC_ERROR, " Unable to dump mempool to disk" );
1619
1623
}
Original file line number Diff line number Diff line change @@ -227,6 +227,7 @@ CAmount maxTxFee = DEFAULT_TRANSACTION_MAXFEE;
227
227
228
228
CBlockPolicyEstimator feeEstimator;
229
229
CTxMemPool mempool (&feeEstimator);
230
+ std::atomic_bool g_is_mempool_loaded{false };
230
231
231
232
/* * Constant stuff for coinbase transactions we create: */
232
233
CScript COINBASE_FLAGS;
Original file line number Diff line number Diff line change @@ -158,6 +158,7 @@ extern CScript COINBASE_FLAGS;
158
158
extern CCriticalSection cs_main;
159
159
extern CBlockPolicyEstimator feeEstimator;
160
160
extern CTxMemPool mempool;
161
+ extern std::atomic_bool g_is_mempool_loaded;
161
162
typedef std::unordered_map<uint256, CBlockIndex*, BlockHasher> BlockMap;
162
163
extern BlockMap& mapBlockIndex;
163
164
extern uint64_t nLastBlockTx;
You can’t perform that action at this time.
0 commit comments