Skip to content

Commit 26fee4f

Browse files
committed
Merge #11062: [mempool] Mark mempool import fails that were found in mempool as 'already there'
258d33b [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
2 parents 808c84f + 258d33b commit 26fee4f

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/validation.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4287,8 +4287,9 @@ bool LoadMempool(void)
42874287
}
42884288

42894289
int64_t count = 0;
4290-
int64_t skipped = 0;
4290+
int64_t expired = 0;
42914291
int64_t failed = 0;
4292+
int64_t already_there = 0;
42924293
int64_t nNow = GetTime();
42934294

42944295
try {
@@ -4319,10 +4320,18 @@ bool LoadMempool(void)
43194320
if (state.IsValid()) {
43204321
++count;
43214322
} else {
4322-
++failed;
4323+
// mempool may contain the transaction already, e.g. from
4324+
// wallet(s) having loaded it while we were processing
4325+
// mempool transactions; consider these as valid, instead of
4326+
// failed, but mark them as 'already there'
4327+
if (mempool.exists(tx->GetHash())) {
4328+
++already_there;
4329+
} else {
4330+
++failed;
4331+
}
43234332
}
43244333
} else {
4325-
++skipped;
4334+
++expired;
43264335
}
43274336
if (ShutdownRequested())
43284337
return false;
@@ -4338,7 +4347,7 @@ bool LoadMempool(void)
43384347
return false;
43394348
}
43404349

4341-
LogPrintf("Imported mempool transactions from disk: %i successes, %i failed, %i expired\n", count, failed, skipped);
4350+
LogPrintf("Imported mempool transactions from disk: %i succeeded, %i failed, %i expired, %i already there\n", count, failed, expired, already_there);
43424351
return true;
43434352
}
43444353

0 commit comments

Comments
 (0)