aboutsummaryrefslogtreecommitdiff
path: root/src/txmempool.cpp
diff options
context:
space:
mode:
authorMatt Corallo <git@bluematt.me>2015-08-26 18:58:17 -0700
committerSuhas Daftuar <sdaftuar@gmail.com>2015-11-30 13:02:04 -0500
commit9b060e5cfb0d185b553b21ae19d390f81e83bd4d (patch)
tree102cf99621b43a118cc0239990bf5a25614f43d6 /src/txmempool.cpp
parent0c9959a3081328f1a8f4d9a5d27d1559b6ede561 (diff)
Fix removal of time-locked transactions during reorg
Diffstat (limited to 'src/txmempool.cpp')
-rw-r--r--src/txmempool.cpp25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/txmempool.cpp b/src/txmempool.cpp
index 6d1df0b3d1..1c38e32601 100644
--- a/src/txmempool.cpp
+++ b/src/txmempool.cpp
@@ -11,6 +11,7 @@
#include "main.h"
#include "policy/fees.h"
#include "streams.h"
+#include "timedata.h"
#include "util.h"
#include "utilmoneystr.h"
#include "utiltime.h"
@@ -478,22 +479,26 @@ void CTxMemPool::remove(const CTransaction &origTx, std::list<CTransaction>& rem
}
}
-void CTxMemPool::removeCoinbaseSpends(const CCoinsViewCache *pcoins, unsigned int nMemPoolHeight)
+void CTxMemPool::removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMemPoolHeight)
{
// Remove transactions spending a coinbase which are now immature
LOCK(cs);
list<CTransaction> transactionsToRemove;
for (indexed_transaction_set::const_iterator it = mapTx.begin(); it != mapTx.end(); it++) {
const CTransaction& tx = it->GetTx();
- BOOST_FOREACH(const CTxIn& txin, tx.vin) {
- indexed_transaction_set::const_iterator it2 = mapTx.find(txin.prevout.hash);
- if (it2 != mapTx.end())
- continue;
- const CCoins *coins = pcoins->AccessCoins(txin.prevout.hash);
- if (nCheckFrequency != 0) assert(coins);
- if (!coins || (coins->IsCoinBase() && ((signed long)nMemPoolHeight) - coins->nHeight < COINBASE_MATURITY)) {
- transactionsToRemove.push_back(tx);
- break;
+ if (!IsFinalTx(tx, nMemPoolHeight, GetAdjustedTime())) {
+ transactionsToRemove.push_back(tx);
+ } else {
+ BOOST_FOREACH(const CTxIn& txin, tx.vin) {
+ indexed_transaction_set::const_iterator it2 = mapTx.find(txin.prevout.hash);
+ if (it2 != mapTx.end())
+ continue;
+ const CCoins *coins = pcoins->AccessCoins(txin.prevout.hash);
+ if (nCheckFrequency != 0) assert(coins);
+ if (!coins || (coins->IsCoinBase() && ((signed long)nMemPoolHeight) - coins->nHeight < COINBASE_MATURITY)) {
+ transactionsToRemove.push_back(tx);
+ break;
+ }
}
}
}