Skip to content

Commit

Permalink
Handle rename failure in DumpMempool(...) by using RenameOver(...) re…
Browse files Browse the repository at this point in the history
…turn value
  • Loading branch information
practicalswift authored and furszy committed Feb 24, 2021
1 parent 1423dba commit 756d0fa
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4185,7 +4185,9 @@ void DumpMempool(void)
file << mapDeltas;
FileCommit(file.Get());
file.fclose();
RenameOver(GetDataDir() / "mempool.dat.new", GetDataDir() / "mempool.dat");
if (!RenameOver(GetDataDir() / "mempool.dat.new", GetDataDir() / "mempool.dat")) {
throw std::runtime_error("Rename failed");
}
int64_t last = GetTimeMicros();
LogPrintf("Dumped mempool: %gs to copy, %gs to dump\n", (mid-start)*0.000001, (last-mid)*0.000001);
} catch (const std::exception& e) {
Expand Down

0 comments on commit 756d0fa

Please sign in to comment.