Merge #11062: [mempool] Mark mempool import fails that were found in mempool as 'already there'

258d33b41 [mempool] Mark unaccepted txs present in mempool as 'already there'. (Karl-Johan Alm)

Pull request description:

  I was investigating the reasons for failed imports in mempool and noticed that `LoadMempool()` and `pwallet->postInitProcess()` (for all wallets) are executed concurrently. The wallet will end up importing transactions that `LoadMempool()` later tries to import; the latter will fail due to the tx already being in the mempool.

  This PR changes the log message, adding an additional "already there" entry. For transactions not accepted into mempool, a check if they are in the mempool is done first, and if found, they are counted as 'already there', otherwise counted as 'failed'.

  Also slight rewording for consistency (successes, failed, expired, ... -> succeeded, failed, expired).

Tree-SHA512: 1a6134a25260917f2768365e0dfd8b278fe3f8287cab38bb028b7de3d517718a2d37696186dc7a23ceab338cc755fbbe7d45358ee94e573610fddd2a0620d6e5
This commit is contained in:
Pieter Wuille 2017-10-18 02:32:16 -07:00
commit 26fee4f6bd
No known key found for this signature in database
GPG Key ID: A636E97631F767E0
1 changed files with 13 additions and 4 deletions

View File

@ -4287,8 +4287,9 @@ bool LoadMempool(void)
}
int64_t count = 0;
int64_t skipped = 0;
int64_t expired = 0;
int64_t failed = 0;
int64_t already_there = 0;
int64_t nNow = GetTime();
try {
@ -4319,10 +4320,18 @@ bool LoadMempool(void)
if (state.IsValid()) {
++count;
} else {
++failed;
// 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 (mempool.exists(tx->GetHash())) {
++already_there;
} else {
++failed;
}
}
} else {
++skipped;
++expired;
}
if (ShutdownRequested())
return false;
@ -4338,7 +4347,7 @@ bool LoadMempool(void)
return false;
}
LogPrintf("Imported mempool transactions from disk: %i successes, %i failed, %i expired\n", count, failed, skipped);
LogPrintf("Imported mempool transactions from disk: %i succeeded, %i failed, %i expired, %i already there\n", count, failed, expired, already_there);
return true;
}