src/txmempool.cpp
/**
 * Called when a block is connected. Removes from mempool and updates the miner fee estimator.
 */
Called when a block is connected. Removes from mempool and updates the miner fee estimator.
Called when a block is connected . Removes from mempool and updates the miner fee estimator .
void CTxMemPool::removeForBlock(const std::vector<CTransactionRef>& vtx, unsigned int nBlockHeight)
{
    AssertLockHeld(cs);
    std::vector<const CTxMemPoolEntry*> entries;
    for (const auto& tx : vtx)
    {
        uint256 hash = tx->GetHash();
        indexed_transaction_set::iterator i = mapTx.find(hash);
        if (i != mapTx.end())
            entries.push_back(&*i);
    }
    if (minerPolicyEstimator) {minerPolicyEstimator->processBlock(nBlockHeight, entries);}
    for (const auto& tx : vtx)
    {
        txiter it = mapTx.find(tx->GetHash());
        if (it != mapTx.end()) {
            setEntries stage;
            stage.insert(it);
            RemoveStaged(stage, true, MemPoolRemovalReason::BLOCK);
        }
        removeConflicts(*tx);
        ClearPrioritisation(tx->GetHash());
        if(fAddressIndex) {
            removeAddressIndex(tx->GetHash());
            removeSpentIndex(tx->GetHash());
        }
    }
    lastRollingFeeUpdate = GetTime();
    blockSinceLastRollingFeeBump = true;
}
void CTxMemPool :: removeForBlock ( const std :: vector < CTransactionRef > & vtx , unsigned int nBlockHeight ) { AssertLockHeld ( cs ) ; std :: vector < const CTxMemPoolEntry * > entries ; for ( const auto & tx : vtx ) { uint256 hash = tx -> GetHash ( ) ; indexed_transaction_set :: iterator i = mapTx . find ( hash ) ; if ( i != mapTx . end ( ) ) entries . push_back ( & * i ) ; } if ( minerPolicyEstimator ) { minerPolicyEstimator -> processBlock ( nBlockHeight , entries ) ; } for ( const auto & tx : vtx ) { txiter it = mapTx . find ( tx -> GetHash ( ) ) ; if ( it != mapTx . end ( ) ) { setEntries stage ; stage . insert ( it ) ; RemoveStaged ( stage , true , MemPoolRemovalReason :: BLOCK ) ; } removeConflicts ( * tx ) ; ClearPrioritisation ( tx -> GetHash ( ) ) ; if ( fAddressIndex ) { removeAddressIndex ( tx -> GetHash ( ) ) ; removeSpentIndex ( tx -> GetHash ( ) ) ; } } lastRollingFeeUpdate = GetTime ( ) ; blockSinceLastRollingFeeBump = true ; }
Called when a block is connected.
Called when a block is connected .
// Before the txs in the new block have been removed from the mempool, update policy estimates