Skip to content

Commit 258d33b

Browse files
committed
[mempool] Mark unaccepted txs present in mempool as 'already there'.
On startup, the wallets will start pumping wallet transactions into the mempool in a different thread while LoadMempool() is running. This will sometimes result in transactions "failing" to be accepted into mempool, but only for the reason that they were already put there by a wallet. The log message for mempool load would note this as a 'failure' to import, which was misleading; it should instead mark it as the transaction already being in the mempool.
1 parent ce66586 commit 258d33b

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
@@ -4278,8 +4278,9 @@ bool LoadMempool(void)
42784278
}
42794279

42804280
int64_t count = 0;
4281-
int64_t skipped = 0;
4281+
int64_t expired = 0;
42824282
int64_t failed = 0;
4283+
int64_t already_there = 0;
42834284
int64_t nNow = GetTime();
42844285

42854286
try {
@@ -4309,10 +4310,18 @@ bool LoadMempool(void)
43094310
if (state.IsValid()) {
43104311
++count;
43114312
} else {
4312-
++failed;
4313+
// mempool may contain the transaction already, e.g. from
4314+
// wallet(s) having loaded it while we were processing
4315+
// mempool transactions; consider these as valid, instead of
4316+
// failed, but mark them as 'already there'
4317+
if (mempool.exists(tx->GetHash())) {
4318+
++already_there;
4319+
} else {
4320+
++failed;
4321+
}
43134322
}
43144323
} else {
4315-
++skipped;
4324+
++expired;
43164325
}
43174326
if (ShutdownRequested())
43184327
return false;
@@ -4328,7 +4337,7 @@ bool LoadMempool(void)
43284337
return false;
43294338
}
43304339

4331-
LogPrintf("Imported mempool transactions from disk: %i successes, %i failed, %i expired\n", count, failed, skipped);
4340+
LogPrintf("Imported mempool transactions from disk: %i succeeded, %i failed, %i expired, %i already there\n", count, failed, expired, already_there);
43324341
return true;
43334342
}
43344343

0 commit comments

Comments
 (0)