Skip to content

Commit

Permalink
Merge #11062: [mempool] Mark mempool import fails that were found in …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
sipa committed Oct 18, 2017
2 parents 808c84f + 258d33b commit 26fee4f
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/validation.cpp
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down

0 comments on commit 26fee4f

Please sign in to comment.