Skip to content

Commit 93cf692

Browse files
TheBlueMattstr4d
authored andcommitted
mempool.check() calls once-per-(dis)connect-> once-per-reorg
Zcash: Extracted from upstream commit bb8ea1f from bitcoin/bitcoin#6915.
1 parent 164b8f8 commit 93cf692

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

src/main.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2515,7 +2515,6 @@ void static UpdateTip(CBlockIndex *pindexNew) {
25152515
bool static DisconnectTip(CValidationState &state, bool fBare = false) {
25162516
CBlockIndex *pindexDelete = chainActive.Tip();
25172517
assert(pindexDelete);
2518-
mempool.check(pcoinsTip);
25192518
// Read block from disk.
25202519
CBlock block;
25212520
if (!ReadBlockFromDisk(block, pindexDelete))
@@ -2550,7 +2549,6 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) {
25502549
mempool.removeWithAnchor(anchorBeforeDisconnect);
25512550
}
25522551
mempool.removeCoinbaseSpends(pcoinsTip, pindexDelete->nHeight);
2553-
mempool.check(pcoinsTip);
25542552
}
25552553

25562554
// Update chainActive and related variables.
@@ -2580,7 +2578,6 @@ static int64_t nTimePostConnect = 0;
25802578
*/
25812579
bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock *pblock) {
25822580
assert(pindexNew->pprev == chainActive.Tip());
2583-
mempool.check(pcoinsTip);
25842581
// Read block from disk.
25852582
int64_t nTime1 = GetTimeMicros();
25862583
CBlock block;
@@ -2620,7 +2617,6 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock *
26202617
// Remove conflicting transactions from the mempool.
26212618
list<CTransaction> txConflicted;
26222619
mempool.removeForBlock(pblock->vtx, pindexNew->nHeight, txConflicted, !IsInitialBlockDownload());
2623-
mempool.check(pcoinsTip);
26242620
// Update chainActive & related variables.
26252621
UpdateTip(pindexNew);
26262622
// Tell wallet about transactions that went from mempool
@@ -2771,6 +2767,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo
27712767
}
27722768
}
27732769
}
2770+
mempool.check(pcoinsTip);
27742771

27752772
// Callbacks/notifications for a new best chain.
27762773
if (fInvalidFound)

src/main.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ bool InvalidateBlock(CValidationState& state, CBlockIndex *pindex);
520520
/** Remove invalidity status from a block and its descendants. */
521521
bool ReconsiderBlock(CValidationState& state, CBlockIndex *pindex);
522522

523-
/** The currently-connected chain of blocks. */
523+
/** The currently-connected chain of blocks (protected by cs_main). */
524524
extern CChain chainActive;
525525

526526
/** Global variable that points to the active CCoinsView (protected by cs_main) */

0 commit comments

Comments
 (0)