Changeset View
Changeset View
Standalone View
Standalone View
src/txmempool.cpp
Show First 20 Lines • Show All 565 Lines • ▼ Show 20 Lines | void CTxMemPool::removeForReorg(const Config &config, | ||||
LOCK(cs); | LOCK(cs); | ||||
setEntries txToRemove; | setEntries txToRemove; | ||||
for (indexed_transaction_set::const_iterator it = mapTx.begin(); | for (indexed_transaction_set::const_iterator it = mapTx.begin(); | ||||
it != mapTx.end(); it++) { | it != mapTx.end(); it++) { | ||||
const CTransaction &tx = it->GetTx(); | const CTransaction &tx = it->GetTx(); | ||||
LockPoints lp = it->GetLockPoints(); | LockPoints lp = it->GetLockPoints(); | ||||
bool validLP = TestLockPointValidity(&lp); | bool validLP = TestLockPointValidity(&lp); | ||||
CValidationState state; | TxValidationState state; | ||||
if (!ContextualCheckTransactionForCurrentBlock( | if (!ContextualCheckTransactionForCurrentBlock( | ||||
config.GetChainParams().GetConsensus(), tx, state, flags) || | config.GetChainParams().GetConsensus(), tx, state, flags) || | ||||
!CheckSequenceLocks(*this, tx, flags, &lp, validLP)) { | !CheckSequenceLocks(*this, tx, flags, &lp, validLP)) { | ||||
// Note if CheckSequenceLocks fails the LockPoints may still be | // Note if CheckSequenceLocks fails the LockPoints may still be | ||||
// invalid. So it's critical that we remove the tx and not depend on | // invalid. So it's critical that we remove the tx and not depend on | ||||
// the LockPoints. | // the LockPoints. | ||||
txToRemove.insert(it); | txToRemove.insert(it); | ||||
} else if (it->GetSpendsCoinbase()) { | } else if (it->GetSpendsCoinbase()) { | ||||
▲ Show 20 Lines • Show All 100 Lines • ▼ Show 20 Lines | |||||
void CTxMemPool::clear() { | void CTxMemPool::clear() { | ||||
LOCK(cs); | LOCK(cs); | ||||
_clear(); | _clear(); | ||||
} | } | ||||
static void CheckInputsAndUpdateCoins(const CTransaction &tx, | static void CheckInputsAndUpdateCoins(const CTransaction &tx, | ||||
CCoinsViewCache &mempoolDuplicate, | CCoinsViewCache &mempoolDuplicate, | ||||
const int64_t spendheight) { | const int64_t spendheight) { | ||||
CValidationState state; | // Not used. CheckTxInputs() should always pass | ||||
TxValidationState dummy_state; | |||||
Amount txfee = Amount::zero(); | Amount txfee = Amount::zero(); | ||||
bool fCheckResult = | bool fCheckResult = | ||||
tx.IsCoinBase() || Consensus::CheckTxInputs(tx, state, mempoolDuplicate, | tx.IsCoinBase() || | ||||
spendheight, txfee); | Consensus::CheckTxInputs(tx, dummy_state, mempoolDuplicate, spendheight, | ||||
txfee); | |||||
assert(fCheckResult); | assert(fCheckResult); | ||||
UpdateCoins(mempoolDuplicate, tx, std::numeric_limits<int>::max()); | UpdateCoins(mempoolDuplicate, tx, std::numeric_limits<int>::max()); | ||||
} | } | ||||
void CTxMemPool::check(const CCoinsViewCache *pcoins) const { | void CTxMemPool::check(const CCoinsViewCache *pcoins) const { | ||||
LOCK(cs); | LOCK(cs); | ||||
if (nCheckFrequency == 0) { | if (nCheckFrequency == 0) { | ||||
return; | return; | ||||
▲ Show 20 Lines • Show All 682 Lines • ▼ Show 20 Lines | void DisconnectedBlockTransactions::updateMempoolForReorg(const Config &config, | ||||
// newest, but the oldest entry will be the last tx from the latest mined | // newest, but the oldest entry will be the last tx from the latest mined | ||||
// block that was disconnected. | // block that was disconnected. | ||||
// Iterate disconnectpool in reverse, so that we add transactions back to | // Iterate disconnectpool in reverse, so that we add transactions back to | ||||
// the mempool starting with the earliest transaction that had been | // the mempool starting with the earliest transaction that had been | ||||
// previously seen in a block. | // previously seen in a block. | ||||
for (const CTransactionRef &tx : | for (const CTransactionRef &tx : | ||||
reverse_iterate(queuedTx.get<insertion_order>())) { | reverse_iterate(queuedTx.get<insertion_order>())) { | ||||
// ignore validation errors in resurrected transactions | // ignore validation errors in resurrected transactions | ||||
CValidationState stateDummy; | TxValidationState stateDummy; | ||||
if (!fAddToMempool || tx->IsCoinBase() || | if (!fAddToMempool || tx->IsCoinBase() || | ||||
!AcceptToMemoryPool(config, g_mempool, stateDummy, tx, | !AcceptToMemoryPool(config, g_mempool, stateDummy, tx, | ||||
nullptr /* pfMissingInputs */, | |||||
true /* bypass_limits */, | true /* bypass_limits */, | ||||
Amount::zero() /* nAbsurdFee */)) { | Amount::zero() /* nAbsurdFee */)) { | ||||
// If the transaction doesn't make it in to the mempool, remove any | // If the transaction doesn't make it in to the mempool, remove any | ||||
// transactions that depend on it (which would now be orphans). | // transactions that depend on it (which would now be orphans). | ||||
g_mempool.removeRecursive(*tx, MemPoolRemovalReason::REORG); | g_mempool.removeRecursive(*tx, MemPoolRemovalReason::REORG); | ||||
} else if (g_mempool.exists(tx->GetId())) { | } else if (g_mempool.exists(tx->GetId())) { | ||||
txidsUpdate.push_back(tx->GetId()); | txidsUpdate.push_back(tx->GetId()); | ||||
} | } | ||||
Show All 22 Lines |