diff options
author | Suhas Daftuar <sdaftuar@gmail.com> | 2015-10-29 14:06:13 -0400 |
---|---|---|
committer | Suhas Daftuar <sdaftuar@gmail.com> | 2015-11-30 13:12:53 -0500 |
commit | 7e49f5f8b4e237d7212d027a7bea4bbd52c9e7b6 (patch) | |
tree | 43ad2997b024e53c22b81c7d585e0a752c134167 /src/main.cpp | |
parent | bb8ea1f6304d7ed3f5fe0a01c060ac9f94629349 (diff) |
Track coinbase spends in CTxMemPoolEntry
This allows us to optimize CTxMemPool::removeForReorg.
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp index 8f67c03510..ad8819eb3d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -953,7 +953,18 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa CAmount inChainInputValue; double dPriority = view.GetPriority(tx, chainActive.Height(), inChainInputValue); - CTxMemPoolEntry entry(tx, nFees, GetTime(), dPriority, chainActive.Height(), pool.HasNoInputsOf(tx), inChainInputValue); + // Keep track of transactions that spend a coinbase, which we re-scan + // during reorgs to ensure COINBASE_MATURITY is still met. + bool fSpendsCoinbase = false; + BOOST_FOREACH(const CTxIn &txin, tx.vin) { + const CCoins *coins = view.AccessCoins(txin.prevout.hash); + if (coins->IsCoinBase()) { + fSpendsCoinbase = true; + break; + } + } + + CTxMemPoolEntry entry(tx, nFees, GetTime(), dPriority, chainActive.Height(), pool.HasNoInputsOf(tx), inChainInputValue, fSpendsCoinbase); unsigned int nSize = entry.GetTxSize(); // Don't accept it if it can't get into a block |