Browse Source

Fix removeForReorg to use MedianTimePast

pull/4/head
Suhas Daftuar 9 years ago
committed by Jack Grigg
parent
commit
233c9eb635
No known key found for this signature in database GPG Key ID: 665DBCD284F7DAFF
  1. 6
      src/main.cpp
  2. 4
      src/txmempool.cpp
  3. 2
      src/txmempool.h

6
src/main.cpp

@ -2689,7 +2689,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo
}
if (fBlocksDisconnected) {
mempool.removeForReorg(pcoinsTip, chainActive.Tip()->nHeight + 1);
mempool.removeForReorg(pcoinsTip, chainActive.Tip()->nHeight + 1, STANDARD_LOCKTIME_VERIFY_FLAGS);
}
mempool.check(pcoinsTip);
@ -2777,7 +2777,7 @@ bool InvalidateBlock(CValidationState& state, CBlockIndex *pindex) {
// ActivateBestChain considers blocks already in chainActive
// unconditionally valid already, so force disconnect away from it.
if (!DisconnectTip(state)) {
mempool.removeForReorg(pcoinsTip, chainActive.Tip()->nHeight + 1);
mempool.removeForReorg(pcoinsTip, chainActive.Tip()->nHeight + 1, STANDARD_LOCKTIME_VERIFY_FLAGS);
return false;
}
}
@ -2793,7 +2793,7 @@ bool InvalidateBlock(CValidationState& state, CBlockIndex *pindex) {
}
InvalidChainFound(pindex);
mempool.removeForReorg(pcoinsTip, chainActive.Tip()->nHeight + 1);
mempool.removeForReorg(pcoinsTip, chainActive.Tip()->nHeight + 1, STANDARD_LOCKTIME_VERIFY_FLAGS);
return true;
}

4
src/txmempool.cpp

@ -171,14 +171,14 @@ void CTxMemPool::remove(const CTransaction &origTx, std::list<CTransaction>& rem
}
}
void CTxMemPool::removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMemPoolHeight)
void CTxMemPool::removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMemPoolHeight, int flags)
{
// Remove transactions spending a coinbase which are now immature and no-longer-final transactions
LOCK(cs);
list<CTransaction> transactionsToRemove;
for (indexed_transaction_set::const_iterator it = mapTx.begin(); it != mapTx.end(); it++) {
const CTransaction& tx = it->GetTx();
if (!IsFinalTx(tx, nMemPoolHeight, GetAdjustedTime())) {
if (!CheckFinalTx(tx, flags)) {
transactionsToRemove.push_back(tx);
} else if (it->GetSpendsCoinbase()) {
BOOST_FOREACH(const CTxIn& txin, tx.vin) {

2
src/txmempool.h

@ -164,7 +164,7 @@ public:
bool addUnchecked(const uint256& hash, const CTxMemPoolEntry &entry, bool fCurrentEstimate = true);
void remove(const CTransaction &tx, std::list<CTransaction>& removed, bool fRecursive = false);
void removeWithAnchor(const uint256 &invalidRoot);
void removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMemPoolHeight);
void removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMemPoolHeight, int flags);
void removeConflicts(const CTransaction &tx, std::list<CTransaction>& removed);
void removeForBlock(const std::vector<CTransaction>& vtx, unsigned int nBlockHeight,
std::list<CTransaction>& conflicts, bool fCurrentEstimate = true);

Loading…
Cancel
Save