Changeset View
Changeset View
Standalone View
Standalone View
src/kernel/disconnected_transactions.cpp
// Copyright (c) 2023 The Bitcoin Core developers | // Copyright (c) 2023 The Bitcoin Core developers | ||||
// Copyright (c) 2024 The Bitcoin developers | // Copyright (c) 2024 The Bitcoin developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <kernel/disconnected_transactions.h> | #include <kernel/disconnected_transactions.h> | ||||
#include <chain.h> | #include <chain.h> | ||||
#include <config.h> | |||||
#include <consensus/consensus.h> | #include <consensus/consensus.h> | ||||
#include <primitives/transaction.h> | #include <primitives/transaction.h> | ||||
#include <reverse_iterator.h> | #include <reverse_iterator.h> | ||||
#include <sync.h> | #include <sync.h> | ||||
#include <validation.h> | #include <validation.h> | ||||
#include <validationinterface.h> | #include <validationinterface.h> | ||||
/** Maximum bytes for transactions to store for processing during reorg */ | /** Maximum bytes for transactions to store for processing during reorg */ | ||||
▲ Show 20 Lines • Show All 150 Lines • ▼ Show 20 Lines | void DisconnectedBlockTransactions::removeForBlock( | ||||
} | } | ||||
pool.updateFeeForBlock(); | pool.updateFeeForBlock(); | ||||
removeForBlock(vtx); | removeForBlock(vtx); | ||||
} | } | ||||
void DisconnectedBlockTransactions::updateMempoolForReorg( | void DisconnectedBlockTransactions::updateMempoolForReorg( | ||||
const Config &config, Chainstate &active_chainstate, bool fAddToMempool, | Chainstate &active_chainstate, bool fAddToMempool, CTxMemPool &pool) { | ||||
CTxMemPool &pool) { | |||||
AssertLockHeld(cs_main); | AssertLockHeld(cs_main); | ||||
AssertLockHeld(pool.cs); | AssertLockHeld(pool.cs); | ||||
if (fAddToMempool) { | if (fAddToMempool) { | ||||
// disconnectpool's insertion_order index sorts the entries from oldest | // disconnectpool's insertion_order index sorts the entries from oldest | ||||
// to newest, but the oldest entry will be the last tx from the latest | // to newest, but the oldest entry will be the last tx from the latest | ||||
// mined block that was disconnected. | // mined block that was disconnected. | ||||
// Iterate disconnectpool in reverse, so that we add transactions back | // Iterate disconnectpool in reverse, so that we add transactions back | ||||
Show All 10 Lines | if (fAddToMempool) { | ||||
if (ptxInfo && ptxInfo->feeDelta != Amount::zero()) { | if (ptxInfo && ptxInfo->feeDelta != Amount::zero()) { | ||||
// manipulate mapDeltas directly (faster than calling | // manipulate mapDeltas directly (faster than calling | ||||
// PrioritiseTransaction) | // PrioritiseTransaction) | ||||
pool.mapDeltas[tx->GetId()] = ptxInfo->feeDelta; | pool.mapDeltas[tx->GetId()] = ptxInfo->feeDelta; | ||||
hasFeeDelta = true; | hasFeeDelta = true; | ||||
} | } | ||||
// ignore validation errors in resurrected transactions | // ignore validation errors in resurrected transactions | ||||
auto result = AcceptToMemoryPool( | auto result = AcceptToMemoryPool( | ||||
config, active_chainstate, tx, | active_chainstate, tx, | ||||
/*accept_time=*/ptxInfo ? ptxInfo->time.count() : GetTime(), | /*accept_time=*/ptxInfo ? ptxInfo->time.count() : GetTime(), | ||||
/*bypass_limits=*/true, /*test_accept=*/false, | /*bypass_limits=*/true, /*test_accept=*/false, | ||||
/*heightOverride=*/ptxInfo ? ptxInfo->height : 0); | /*heightOverride=*/ptxInfo ? ptxInfo->height : 0); | ||||
if (result.m_result_type != | if (result.m_result_type != | ||||
MempoolAcceptResult::ResultType::VALID && | MempoolAcceptResult::ResultType::VALID && | ||||
hasFeeDelta) { | hasFeeDelta) { | ||||
// tx not accepted: undo mapDelta insertion from above | // tx not accepted: undo mapDelta insertion from above | ||||
pool.mapDeltas.erase(tx->GetId()); | pool.mapDeltas.erase(tx->GetId()); | ||||
Show All 10 Lines |