12#include <unordered_map>
28 std::unordered_map<COutPoint, TxId, SaltedOutpointHasher>
29 finalizedDisconnectedSpends;
32 const TxId txid = tx->GetId();
34 if (tx->IsCoinBase() ||
38 for (
const CTxIn &txin : tx->vin) {
39 finalizedDisconnectedSpends.emplace(txin.prevout, txid);
44 auto rejectConflict = [&](
const TxId &txid,
const TxId &conflictingId) {
46 "finalized-tx-conflict",
47 strprintf(
"Block %s contains tx %s that conflicts "
48 "with finalized tx %s",
51 conflictingId.ToString()));
56 const TxId txid = tx->GetId();
57 for (
const auto &txin : tx->vin) {
62 if (ptxConflicting && ptxConflicting->GetId() != txid &&
64 ptxConflicting->GetId())) {
65 return rejectConflict(txid, ptxConflicting->GetId());
68 auto it = finalizedDisconnectedSpends.find(txin.prevout);
69 if (it != finalizedDisconnectedSpends.end() && it->second != txid) {
70 return rejectConflict(txid, it->second);
std::vector< CTransactionRef > vtx
CBlockIndex * pprev
pointer to the index of the predecessor of this block
RecursiveMutex cs
This mutex needs to be locked when accessing mapTx or other members that are guarded by it.
bool setAvalancheFinalized(const CTxMemPoolEntryRef &tx, const Consensus::Params ¶ms, const CBlockIndex &active_chain_tip, std::vector< TxId > &finalizedTxIds) EXCLUSIVE_LOCKS_REQUIRED(bool isAvalancheFinalizedPreConsensus(const TxId &txid) const EXCLUSIVE_LOCKS_REQUIRED(cs)
CTransactionRef GetConflictTx(const COutPoint &prevout) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Get the transaction in the pool that spends the same prevout.
const indexed_disconnected_transactions & GetQueuedTx() const
const CBlockIndex & m_blockIndex
const CTxMemPool * m_mempool
const DisconnectedBlockTransactions * m_disconnectpool
bool operator()(BlockPolicyValidationState &state) override EXCLUSIVE_LOCKS_REQUIRED(m_mempool -> cs)
const avalanche::Processor & m_avalanche
bool Invalid(Result result, const std::string &reject_reason="", const std::string &debug_message="")
bool isPreconsensusActivated(const CBlockIndex *pprev) const
std::string ToString() const
@ POLICY_VIOLATION
A block policy rule was violated. This block should be parked.
std::shared_ptr< const CTransaction > CTransactionRef
A TxId is the identifier of a transaction.