Bitcoin ABC 0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
preconsensus.cpp
Go to the documentation of this file.
1// Copyright (c) 2024 The Bitcoin developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
6
8#include <blockindex.h>
9#include <common/args.h>
10
12 if (!m_mempool || !m_blockIndex.pprev ||
13 !gArgs.GetBoolArg("-avalanchepreconsensus",
15 return true;
16 }
17
19
20 // TODO Use a CoinViewCache
21 for (const auto &tx : m_block.vtx) {
22 for (const auto &txin : tx->vin) {
25
26 // Only allow for the exact txid for each coin spent
27 if (ptxConflicting && ptxConflicting->GetId() != tx->GetId() &&
29 return state.Invalid(
31 "finalized-tx-conflict",
32 strprintf("Block %s contains tx %s that conflicts with "
33 "finalized tx %s",
35 tx->GetId().ToString(),
36 ptxConflicting->GetId().ToString()));
37 }
38 }
39 }
40
41 return true;
42}
ArgsManager gArgs
Definition args.cpp:38
static constexpr bool DEFAULT_AVALANCHE_PRECONSENSUS
Default for -avalanchepreconsensus.
Definition avalanche.h:66
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
Definition args.cpp:556
BlockHash GetHash() const
Definition block.cpp:11
std::vector< CTransactionRef > vtx
Definition block.h:63
CBlockIndex * pprev
pointer to the index of the predecessor of this block
Definition blockindex.h:32
bool isAvalancheFinalized(const TxId &txid) const
Definition txmempool.h:513
RecursiveMutex cs
This mutex needs to be locked when accessing mapTx or other members that are guarded by it.
Definition txmempool.h:307
CTransactionRef GetConflictTx(const COutPoint &prevout) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Get the transaction in the pool that spends the same prevout.
const CBlockIndex & m_blockIndex
const CTxMemPool * m_mempool
const CBlock & m_block
bool operator()(BlockPolicyValidationState &state) override EXCLUSIVE_LOCKS_REQUIRED(m_mempool -> cs)
bool Invalid(Result result, const std::string &reject_reason="", const std::string &debug_message="")
Definition validation.h:101
std::string ToString() const
Definition uint256.h:80
@ POLICY_VIOLATION
A block policy rule was violated. This block should be parked.
std::shared_ptr< const CTransaction > CTransactionRef
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
Definition random.h:85
#define AssertLockHeld(cs)
Definition sync.h:146
#define strprintf
Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for...