Bugfix: RPC: savemempool: Don't save until LoadMempool() is finished
This commit is contained in:
parent
624bee9659
commit
cb1e319fe9
4 changed files with 9 additions and 4 deletions
|
@ -116,7 +116,6 @@ static const char* FEE_ESTIMATES_FILENAME="fee_estimates.dat";
|
||||||
//
|
//
|
||||||
|
|
||||||
std::atomic<bool> fRequestShutdown(false);
|
std::atomic<bool> fRequestShutdown(false);
|
||||||
std::atomic<bool> fDumpMempoolLater(false);
|
|
||||||
|
|
||||||
void StartShutdown()
|
void StartShutdown()
|
||||||
{
|
{
|
||||||
|
@ -208,7 +207,7 @@ void Shutdown()
|
||||||
threadGroup.interrupt_all();
|
threadGroup.interrupt_all();
|
||||||
threadGroup.join_all();
|
threadGroup.join_all();
|
||||||
|
|
||||||
if (fDumpMempoolLater && gArgs.GetArg("-persistmempool", DEFAULT_PERSIST_MEMPOOL)) {
|
if (g_is_mempool_loaded && gArgs.GetArg("-persistmempool", DEFAULT_PERSIST_MEMPOOL)) {
|
||||||
DumpMempool();
|
DumpMempool();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -692,8 +691,8 @@ void ThreadImport(std::vector<fs::path> vImportFiles)
|
||||||
} // End scope of CImportingNow
|
} // End scope of CImportingNow
|
||||||
if (gArgs.GetArg("-persistmempool", DEFAULT_PERSIST_MEMPOOL)) {
|
if (gArgs.GetArg("-persistmempool", DEFAULT_PERSIST_MEMPOOL)) {
|
||||||
LoadMempool();
|
LoadMempool();
|
||||||
fDumpMempoolLater = !fRequestShutdown;
|
|
||||||
}
|
}
|
||||||
|
g_is_mempool_loaded = !fRequestShutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Sanity checks
|
/** Sanity checks
|
||||||
|
|
|
@ -1607,13 +1607,17 @@ UniValue savemempool(const JSONRPCRequest& request)
|
||||||
if (request.fHelp || request.params.size() != 0) {
|
if (request.fHelp || request.params.size() != 0) {
|
||||||
throw std::runtime_error(
|
throw std::runtime_error(
|
||||||
"savemempool\n"
|
"savemempool\n"
|
||||||
"\nDumps the mempool to disk.\n"
|
"\nDumps the mempool to disk. It will fail until the previous dump is fully loaded.\n"
|
||||||
"\nExamples:\n"
|
"\nExamples:\n"
|
||||||
+ HelpExampleCli("savemempool", "")
|
+ HelpExampleCli("savemempool", "")
|
||||||
+ HelpExampleRpc("savemempool", "")
|
+ HelpExampleRpc("savemempool", "")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!g_is_mempool_loaded) {
|
||||||
|
throw JSONRPCError(RPC_MISC_ERROR, "The mempool was not loaded yet");
|
||||||
|
}
|
||||||
|
|
||||||
if (!DumpMempool()) {
|
if (!DumpMempool()) {
|
||||||
throw JSONRPCError(RPC_MISC_ERROR, "Unable to dump mempool to disk");
|
throw JSONRPCError(RPC_MISC_ERROR, "Unable to dump mempool to disk");
|
||||||
}
|
}
|
||||||
|
|
|
@ -227,6 +227,7 @@ CAmount maxTxFee = DEFAULT_TRANSACTION_MAXFEE;
|
||||||
|
|
||||||
CBlockPolicyEstimator feeEstimator;
|
CBlockPolicyEstimator feeEstimator;
|
||||||
CTxMemPool mempool(&feeEstimator);
|
CTxMemPool mempool(&feeEstimator);
|
||||||
|
std::atomic_bool g_is_mempool_loaded{false};
|
||||||
|
|
||||||
/** Constant stuff for coinbase transactions we create: */
|
/** Constant stuff for coinbase transactions we create: */
|
||||||
CScript COINBASE_FLAGS;
|
CScript COINBASE_FLAGS;
|
||||||
|
|
|
@ -158,6 +158,7 @@ extern CScript COINBASE_FLAGS;
|
||||||
extern CCriticalSection cs_main;
|
extern CCriticalSection cs_main;
|
||||||
extern CBlockPolicyEstimator feeEstimator;
|
extern CBlockPolicyEstimator feeEstimator;
|
||||||
extern CTxMemPool mempool;
|
extern CTxMemPool mempool;
|
||||||
|
extern std::atomic_bool g_is_mempool_loaded;
|
||||||
typedef std::unordered_map<uint256, CBlockIndex*, BlockHasher> BlockMap;
|
typedef std::unordered_map<uint256, CBlockIndex*, BlockHasher> BlockMap;
|
||||||
extern BlockMap& mapBlockIndex;
|
extern BlockMap& mapBlockIndex;
|
||||||
extern uint64_t nLastBlockTx;
|
extern uint64_t nLastBlockTx;
|
||||||
|
|
Loading…
Add table
Reference in a new issue