mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
merge bitcoin#23398: add return message to savemempool RPC
This commit is contained in:
parent
22e59fb464
commit
d57c96ea37
@ -2643,7 +2643,11 @@ static RPCHelpMan savemempool()
|
|||||||
return RPCHelpMan{"savemempool",
|
return RPCHelpMan{"savemempool",
|
||||||
"\nDumps the mempool to disk. It will fail until the previous dump is fully loaded.\n",
|
"\nDumps the mempool to disk. It will fail until the previous dump is fully loaded.\n",
|
||||||
{},
|
{},
|
||||||
RPCResult{RPCResult::Type::NONE, "", ""},
|
RPCResult{
|
||||||
|
RPCResult::Type::OBJ, "", "",
|
||||||
|
{
|
||||||
|
{RPCResult::Type::STR, "filename", "the directory and file where the mempool was saved"},
|
||||||
|
}},
|
||||||
RPCExamples{
|
RPCExamples{
|
||||||
HelpExampleCli("savemempool", "")
|
HelpExampleCli("savemempool", "")
|
||||||
+ HelpExampleRpc("savemempool", "")
|
+ HelpExampleRpc("savemempool", "")
|
||||||
@ -2652,6 +2656,8 @@ static RPCHelpMan savemempool()
|
|||||||
{
|
{
|
||||||
const CTxMemPool& mempool = EnsureAnyMemPool(request.context);
|
const CTxMemPool& mempool = EnsureAnyMemPool(request.context);
|
||||||
|
|
||||||
|
const NodeContext& node = EnsureAnyNodeContext(request.context);
|
||||||
|
|
||||||
if (!mempool.IsLoaded()) {
|
if (!mempool.IsLoaded()) {
|
||||||
throw JSONRPCError(RPC_MISC_ERROR, "The mempool was not loaded yet");
|
throw JSONRPCError(RPC_MISC_ERROR, "The mempool was not loaded yet");
|
||||||
}
|
}
|
||||||
@ -2660,7 +2666,10 @@ static RPCHelpMan savemempool()
|
|||||||
throw JSONRPCError(RPC_MISC_ERROR, "Unable to dump mempool to disk");
|
throw JSONRPCError(RPC_MISC_ERROR, "Unable to dump mempool to disk");
|
||||||
}
|
}
|
||||||
|
|
||||||
return NullUniValue;
|
UniValue ret(UniValue::VOBJ);
|
||||||
|
ret.pushKV("filename", fs::path((node.args->GetDataDirNet() / "mempool.dat")).u8string());
|
||||||
|
|
||||||
|
return ret;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -133,8 +133,9 @@ class MempoolPersistTest(BitcoinTestFramework):
|
|||||||
mempooldat1 = os.path.join(self.nodes[1].datadir, self.chain, 'mempool.dat')
|
mempooldat1 = os.path.join(self.nodes[1].datadir, self.chain, 'mempool.dat')
|
||||||
self.log.debug("Remove the mempool.dat file. Verify that savemempool to disk via RPC re-creates it")
|
self.log.debug("Remove the mempool.dat file. Verify that savemempool to disk via RPC re-creates it")
|
||||||
os.remove(mempooldat0)
|
os.remove(mempooldat0)
|
||||||
self.nodes[0].savemempool()
|
result0 = self.nodes[0].savemempool()
|
||||||
assert os.path.isfile(mempooldat0)
|
assert os.path.isfile(mempooldat0)
|
||||||
|
assert_equal(result0['filename'], mempooldat0)
|
||||||
|
|
||||||
self.log.debug("Stop nodes, make node1 use mempool.dat from node0. Verify it has 6 transactions")
|
self.log.debug("Stop nodes, make node1 use mempool.dat from node0. Verify it has 6 transactions")
|
||||||
os.rename(mempooldat0, mempooldat1)
|
os.rename(mempooldat0, mempooldat1)
|
||||||
|
Loading…
Reference in New Issue
Block a user