Skip to content

Commit

Permalink
mempool.check() calls once-per-(dis)connect-> once-per-reorg
Browse files Browse the repository at this point in the history
Zcash: Extracted from upstream commit bb8ea1f
from bitcoin/bitcoin#6915.
  • Loading branch information
TheBlueMatt authored and str4d committed Feb 8, 2018
1 parent e600586 commit e62cc5a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
5 changes: 1 addition & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2492,7 +2492,6 @@ void static UpdateTip(CBlockIndex *pindexNew) {
bool static DisconnectTip(CValidationState &state, bool fBare = false) {
CBlockIndex *pindexDelete = chainActive.Tip();
assert(pindexDelete);
mempool.check(pcoinsTip);
// Read block from disk.
CBlock block;
if (!ReadBlockFromDisk(block, pindexDelete))
Expand Down Expand Up @@ -2527,7 +2526,6 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) {
mempool.removeWithAnchor(anchorBeforeDisconnect);
}
mempool.removeCoinbaseSpends(pcoinsTip, pindexDelete->nHeight);
mempool.check(pcoinsTip);
}

// Update chainActive and related variables.
Expand Down Expand Up @@ -2557,7 +2555,6 @@ static int64_t nTimePostConnect = 0;
*/
bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock *pblock) {
assert(pindexNew->pprev == chainActive.Tip());
mempool.check(pcoinsTip);
// Read block from disk.
int64_t nTime1 = GetTimeMicros();
CBlock block;
Expand Down Expand Up @@ -2597,7 +2594,6 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock *
// Remove conflicting transactions from the mempool.
list<CTransaction> txConflicted;
mempool.removeForBlock(pblock->vtx, pindexNew->nHeight, txConflicted, !IsInitialBlockDownload());
mempool.check(pcoinsTip);
// Update chainActive & related variables.
UpdateTip(pindexNew);
// Tell wallet about transactions that went from mempool
Expand Down Expand Up @@ -2748,6 +2744,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo
}
}
}
mempool.check(pcoinsTip);

// Callbacks/notifications for a new best chain.
if (fInvalidFound)
Expand Down
2 changes: 1 addition & 1 deletion src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ bool InvalidateBlock(CValidationState& state, CBlockIndex *pindex);
/** Remove invalidity status from a block and its descendants. */
bool ReconsiderBlock(CValidationState& state, CBlockIndex *pindex);

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

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

0 comments on commit e62cc5a

Please sign in to comment.