refactor: Avoid double to int cast for nCheckFrequency

Use a ratio instead of a frequency that requires a double to int cast
for determining how often a mempool sanity check should run.
This commit is contained in:
Elle Mouton
2020-10-20 20:09:55 +02:00
parent 88271184e8
commit 9d4b4b2c2c
3 changed files with 8 additions and 12 deletions

View File

@@ -1394,10 +1394,8 @@ bool AppInitMain(const util::Ref& context, NodeContext& node, interfaces::BlockA
assert(!node.mempool);
node.mempool = MakeUnique<CTxMemPool>(&::feeEstimator);
if (node.mempool) {
int ratio = std::min<int>(std::max<int>(args.GetArg("-checkmempool", chainparams.DefaultConsistencyChecks() ? 1 : 0), 0), 1000000);
if (ratio != 0) {
node.mempool->setSanityCheck(1.0 / ratio);
}
int check_ratio = std::min<int>(std::max<int>(args.GetArg("-checkmempool", chainparams.DefaultConsistencyChecks() ? 1 : 0), 0), 1000000);
node.mempool->setSanityCheck(check_ratio);
}
assert(!node.chainman);