|
11 | 11 | #include "main.h"
|
12 | 12 | #include "policy/fees.h"
|
13 | 13 | #include "streams.h"
|
| 14 | +#include "timedata.h" |
14 | 15 | #include "util.h"
|
15 | 16 | #include "utilmoneystr.h"
|
16 | 17 | #include "utiltime.h"
|
@@ -478,22 +479,26 @@ void CTxMemPool::remove(const CTransaction &origTx, std::list<CTransaction>& rem
|
478 | 479 | }
|
479 | 480 | }
|
480 | 481 |
|
481 |
| -void CTxMemPool::removeCoinbaseSpends(const CCoinsViewCache *pcoins, unsigned int nMemPoolHeight) |
| 482 | +void CTxMemPool::removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMemPoolHeight) |
482 | 483 | {
|
483 | 484 | // Remove transactions spending a coinbase which are now immature
|
484 | 485 | LOCK(cs);
|
485 | 486 | list<CTransaction> transactionsToRemove;
|
486 | 487 | for (indexed_transaction_set::const_iterator it = mapTx.begin(); it != mapTx.end(); it++) {
|
487 | 488 | const CTransaction& tx = it->GetTx();
|
488 |
| - BOOST_FOREACH(const CTxIn& txin, tx.vin) { |
489 |
| - indexed_transaction_set::const_iterator it2 = mapTx.find(txin.prevout.hash); |
490 |
| - if (it2 != mapTx.end()) |
491 |
| - continue; |
492 |
| - const CCoins *coins = pcoins->AccessCoins(txin.prevout.hash); |
493 |
| - if (nCheckFrequency != 0) assert(coins); |
494 |
| - if (!coins || (coins->IsCoinBase() && ((signed long)nMemPoolHeight) - coins->nHeight < COINBASE_MATURITY)) { |
495 |
| - transactionsToRemove.push_back(tx); |
496 |
| - break; |
| 489 | + if (!IsFinalTx(tx, nMemPoolHeight, GetAdjustedTime())) { |
| 490 | + transactionsToRemove.push_back(tx); |
| 491 | + } else { |
| 492 | + BOOST_FOREACH(const CTxIn& txin, tx.vin) { |
| 493 | + indexed_transaction_set::const_iterator it2 = mapTx.find(txin.prevout.hash); |
| 494 | + if (it2 != mapTx.end()) |
| 495 | + continue; |
| 496 | + const CCoins *coins = pcoins->AccessCoins(txin.prevout.hash); |
| 497 | + if (nCheckFrequency != 0) assert(coins); |
| 498 | + if (!coins || (coins->IsCoinBase() && ((signed long)nMemPoolHeight) - coins->nHeight < COINBASE_MATURITY)) { |
| 499 | + transactionsToRemove.push_back(tx); |
| 500 | + break; |
| 501 | + } |
497 | 502 | }
|
498 | 503 | }
|
499 | 504 | }
|
|
0 commit comments