Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 5,596 Lines • ▼ Show 20 Lines | bool LoadMempool(const Config &config) { | ||||
CAutoFile file(filestr, SER_DISK, CLIENT_VERSION); | CAutoFile file(filestr, SER_DISK, CLIENT_VERSION); | ||||
if (file.IsNull()) { | if (file.IsNull()) { | ||||
LogPrintf( | LogPrintf( | ||||
"Failed to open mempool file from disk. Continuing anyway.\n"); | "Failed to open mempool file from disk. Continuing anyway.\n"); | ||||
return false; | return false; | ||||
} | } | ||||
int64_t count = 0; | int64_t count = 0; | ||||
int64_t skipped = 0; | int64_t expired = 0; | ||||
int64_t failed = 0; | int64_t failed = 0; | ||||
int64_t already_there = 0; | |||||
int64_t nNow = GetTime(); | int64_t nNow = GetTime(); | ||||
try { | try { | ||||
uint64_t version; | uint64_t version; | ||||
file >> version; | file >> version; | ||||
if (version != MEMPOOL_DUMP_VERSION) { | if (version != MEMPOOL_DUMP_VERSION) { | ||||
return false; | return false; | ||||
} | } | ||||
Show All 20 Lines | try { | ||||
AcceptToMemoryPoolWithTime( | AcceptToMemoryPoolWithTime( | ||||
config, g_mempool, state, tx, true /* fLimitFree */, | config, g_mempool, state, tx, true /* fLimitFree */, | ||||
nullptr /* pfMissingInputs */, nTime, | nullptr /* pfMissingInputs */, nTime, | ||||
false /* fOverrideMempoolLimit */, | false /* fOverrideMempoolLimit */, | ||||
Amount::zero() /* nAbsurdFee */, false /* test_accept */); | Amount::zero() /* nAbsurdFee */, false /* test_accept */); | ||||
if (state.IsValid()) { | if (state.IsValid()) { | ||||
++count; | ++count; | ||||
} else { | } else { | ||||
// mempool may contain the transaction already, e.g. from | |||||
// wallet(s) having loaded it while we were processing | |||||
// mempool transactions; consider these as valid, instead of | |||||
// failed, but mark them as 'already there' | |||||
if (g_mempool.exists(tx->GetHash())) { | |||||
++already_there; | |||||
} else { | |||||
++failed; | ++failed; | ||||
} | } | ||||
} | |||||
} else { | } else { | ||||
++skipped; | ++expired; | ||||
} | } | ||||
if (ShutdownRequested()) { | if (ShutdownRequested()) { | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
std::map<uint256, Amount> mapDeltas; | std::map<uint256, Amount> mapDeltas; | ||||
file >> mapDeltas; | file >> mapDeltas; | ||||
for (const auto &i : mapDeltas) { | for (const auto &i : mapDeltas) { | ||||
g_mempool.PrioritiseTransaction(i.first, prioritydummy, i.second); | g_mempool.PrioritiseTransaction(i.first, prioritydummy, i.second); | ||||
} | } | ||||
} catch (const std::exception &e) { | } catch (const std::exception &e) { | ||||
LogPrintf("Failed to deserialize mempool data on disk: %s. Continuing " | LogPrintf("Failed to deserialize mempool data on disk: %s. Continuing " | ||||
"anyway.\n", | "anyway.\n", | ||||
e.what()); | e.what()); | ||||
return false; | return false; | ||||
} | } | ||||
LogPrintf("Imported mempool transactions from disk: %i successes, %i " | LogPrintf("Imported mempool transactions from disk: %i succeeded, %i " | ||||
"failed, %i expired\n", | "failed, %i expired, %i already there\n", | ||||
count, failed, skipped); | count, failed, expired, already_there); | ||||
return true; | return true; | ||||
} | } | ||||
bool DumpMempool() { | bool DumpMempool() { | ||||
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; | ||||
▲ Show 20 Lines • Show All 90 Lines • Show Last 20 Lines |