Browse Source

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
0.16
Pieter Wuille 7 years ago
parent
commit
26fee4f6bd
No known key found for this signature in database
GPG Key ID: A636E97631F767E0
  1. 17
      src/validation.cpp

17
src/validation.cpp

@ -4287,8 +4287,9 @@ bool LoadMempool(void)
} }
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 {
@ -4319,10 +4320,18 @@ bool LoadMempool(void)
if (state.IsValid()) { if (state.IsValid()) {
++count; ++count;
} else { } 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 { } else {
++skipped; ++expired;
} }
if (ShutdownRequested()) if (ShutdownRequested())
return false; return false;
@ -4338,7 +4347,7 @@ bool LoadMempool(void)
return false; 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; return true;
} }

Loading…
Cancel
Save