Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 5,633 Lines • ▼ Show 20 Lines | bool LoadMempool(const Config &config) { | ||||
} | } | ||||
LogPrintf("Imported mempool transactions from disk: %i successes, %i " | LogPrintf("Imported mempool transactions from disk: %i successes, %i " | ||||
"failed, %i expired\n", | "failed, %i expired\n", | ||||
count, failed, skipped); | count, failed, skipped); | ||||
return true; | return true; | ||||
} | } | ||||
void DumpMempool(void) { | bool DumpMempool(void) { | ||||
int64_t start = GetTimeMicros(); | int64_t start = GetTimeMicros(); | ||||
std::map<uint256, Amount> mapDeltas; | std::map<uint256, Amount> mapDeltas; | ||||
std::vector<TxMempoolInfo> vinfo; | std::vector<TxMempoolInfo> vinfo; | ||||
{ | { | ||||
LOCK(g_mempool.cs); | LOCK(g_mempool.cs); | ||||
for (const auto &i : g_mempool.mapDeltas) { | for (const auto &i : g_mempool.mapDeltas) { | ||||
mapDeltas[i.first] = i.second.second; | mapDeltas[i.first] = i.second.second; | ||||
} | } | ||||
vinfo = g_mempool.infoAll(); | vinfo = g_mempool.infoAll(); | ||||
} | } | ||||
int64_t mid = GetTimeMicros(); | int64_t mid = GetTimeMicros(); | ||||
try { | try { | ||||
FILE *filestr = fsbridge::fopen(GetDataDir() / "mempool.dat.new", "wb"); | FILE *filestr = fsbridge::fopen(GetDataDir() / "mempool.dat.new", "wb"); | ||||
if (!filestr) { | if (!filestr) { | ||||
return; | return false; | ||||
} | } | ||||
CAutoFile file(filestr, SER_DISK, CLIENT_VERSION); | CAutoFile file(filestr, SER_DISK, CLIENT_VERSION); | ||||
uint64_t version = MEMPOOL_DUMP_VERSION; | uint64_t version = MEMPOOL_DUMP_VERSION; | ||||
file << version; | file << version; | ||||
file << uint64_t(vinfo.size()); | file << uint64_t(vinfo.size()); | ||||
Show All 9 Lines | try { | ||||
file.fclose(); | file.fclose(); | ||||
RenameOver(GetDataDir() / "mempool.dat.new", | RenameOver(GetDataDir() / "mempool.dat.new", | ||||
GetDataDir() / "mempool.dat"); | GetDataDir() / "mempool.dat"); | ||||
int64_t last = GetTimeMicros(); | int64_t last = GetTimeMicros(); | ||||
LogPrintf("Dumped mempool: %gs to copy, %gs to dump\n", | LogPrintf("Dumped mempool: %gs to copy, %gs to dump\n", | ||||
(mid - start) * MICRO, (last - mid) * MICRO); | (mid - start) * MICRO, (last - mid) * MICRO); | ||||
} catch (const std::exception &e) { | } catch (const std::exception &e) { | ||||
LogPrintf("Failed to dump mempool: %s. Continuing anyway.\n", e.what()); | 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 | //! Guess how far we are in the verification process at the given block index | ||||
double GuessVerificationProgress(const ChainTxData &data, | double GuessVerificationProgress(const ChainTxData &data, | ||||
const CBlockIndex *pindex) { | const CBlockIndex *pindex) { | ||||
if (pindex == nullptr) { | if (pindex == nullptr) { | ||||
return 0.0; | return 0.0; | ||||
} | } | ||||
Show All 26 Lines |