[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.
This commit is contained in:
parent
ce665863b1
commit
258d33b41a
1 changed files with 13 additions and 4 deletions
|
@ -4278,8 +4278,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 {
|
||||||
|
@ -4308,11 +4309,19 @@ bool LoadMempool(void)
|
||||||
AcceptToMemoryPoolWithTime(chainparams, mempool, state, tx, true, nullptr, nTime, nullptr, false, 0);
|
AcceptToMemoryPoolWithTime(chainparams, mempool, state, tx, true, nullptr, nTime, nullptr, false, 0);
|
||||||
if (state.IsValid()) {
|
if (state.IsValid()) {
|
||||||
++count;
|
++count;
|
||||||
|
} else {
|
||||||
|
// 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 {
|
} else {
|
||||||
++failed;
|
++failed;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
++skipped;
|
++expired;
|
||||||
}
|
}
|
||||||
if (ShutdownRequested())
|
if (ShutdownRequested())
|
||||||
return false;
|
return false;
|
||||||
|
@ -4328,7 +4337,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…
Reference in a new issue