Skip to content

Commit

Permalink
mempool: Loading progress added for dumping mempool transactions to disk
Browse files Browse the repository at this point in the history
  • Loading branch information
kevkevinpal committed Feb 7, 2024
1 parent 11b436a commit 7b2092f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/kernel/mempool_persist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,19 @@ bool DumpMempool(const CTxMemPool& pool, const fs::path& dump_path, FopenFn mock
}
file.SetXor(xor_key);

file << (uint64_t)vinfo.size();
int mempool_transactions_to_write = (uint64_t)vinfo.size();
file << mempool_transactions_to_write;
LogInfo("Dumping %u mempool transactions to disk...\n", mempool_transactions_to_write);
int next_tenth_to_report = 0;
uint64_t mempool_transactions_tried = 0;
for (const auto& i : vinfo) {
const int percentage_done(100.0 * mempool_transactions_tried / mempool_transactions_to_write);
if (next_tenth_to_report < percentage_done / 10) {
LogInfo("Progress dumping mempool transactions to disk: %d%% (tried %u, %u remaining)\n",
percentage_done, mempool_transactions_tried, mempool_transactions_to_write - mempool_transactions_tried);
next_tenth_to_report = percentage_done / 10;
}
++mempool_transactions_tried;
file << TX_WITH_WITNESS(*(i.tx));
file << int64_t{count_seconds(i.m_time)};
file << int64_t{i.nFeeDelta};
Expand Down

0 comments on commit 7b2092f

Please sign in to comment.