mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-06 05:37:50 +02:00
Merge #11099: [RPC][mempool]: Add savemempool RPC
1aa97ee08Add savemempool RPC (Lawrence Nahum)467cbbcbfAdd return value to DumpMempool (Lawrence Nahum) Pull request description: Adds a simple parameterless rpc command to dump the mempool. Rationale: Sometimes there can be a crash for whatever reason (bug, power loss, etc) causing the mempool.dat file to not be saved. This change allows to script/cron the rpc call to have more regular saves to the file as well as cli/ad-hoc. This should solve issue https://github.com/bitcoin/bitcoin/issues/11086 Tree-SHA512: e856ae9777425a4521279c9b58e69285d8e374790bebefd3284cf91931eac0e456f86224f427a087a01bf70440bf6e439fa02c8a34940eb1046ae473e98b6aaa
This commit is contained in:
@@ -4331,7 +4331,7 @@ bool LoadMempool(void)
|
||||
return true;
|
||||
}
|
||||
|
||||
void DumpMempool(void)
|
||||
bool DumpMempool(void)
|
||||
{
|
||||
int64_t start = GetTimeMicros();
|
||||
|
||||
@@ -4351,7 +4351,7 @@ void DumpMempool(void)
|
||||
try {
|
||||
FILE* filestr = fsbridge::fopen(GetDataDir() / "mempool.dat.new", "wb");
|
||||
if (!filestr) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
CAutoFile file(filestr, SER_DISK, CLIENT_VERSION);
|
||||
@@ -4375,7 +4375,9 @@ void DumpMempool(void)
|
||||
LogPrintf("Dumped mempool: %gs to copy, %gs to dump\n", (mid-start)*MICRO, (last-mid)*MICRO);
|
||||
} catch (const std::exception& e) {
|
||||
LogPrintf("Failed to dump mempool: %s. Continuing anyway.\n", e.what());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//! Guess how far we are in the verification process at the given block index
|
||||
|
||||
Reference in New Issue
Block a user