From 16e69092d98ff90aa360cac66515d8cfd548c114 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 29 Oct 2018 21:17:09 +0800 Subject: [PATCH] first try --- src/main.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 11df78609..676c77cdc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -92,6 +92,7 @@ unsigned int expiryDelta = DEFAULT_TX_EXPIRY_DELTA; CFeeRate minRelayTxFee = CFeeRate(DEFAULT_MIN_RELAY_TX_FEE); CTxMemPool mempool(::minRelayTxFee); +CTxMemPool tmpmempool(::minRelayTxFee); struct COrphanTx { CTransaction tx; @@ -1697,7 +1698,7 @@ bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlo } } //fprintf(stderr,"check disk\n"); - + if (fTxIndex) { CDiskTxPos postx; //fprintf(stderr,"ReadTxIndex\n"); @@ -4247,6 +4248,17 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C { CValidationState stateDummy; int32_t i,j,rejects=0,lastrejects=0; //fprintf(stderr,"put block's tx into mempool\n"); + // Copy the mempool to temporary mempool because there can be tx in local mempool that make the block invalid. + LOCK(mempool.cs); + BOOST_FOREACH(const CTxMemPoolEntry& e, mempool.mapTx) { + const CTransaction &tx = e.GetTx(); + const uint256 &hash = tx.GetHash(); + tmpmempool.addUnchecked(hash,e,!IsInitialBlockDownload()); + fprintf(stderr, "added mempool tx to temp mempool\n"); + } + // clear the mempool before importing all block txs to mempool. + mempool.clear(); + // add all the txs in the block to the empty mempool. while ( 1 ) { for (i=0; i