5#ifndef BITCOIN_NODE_TXORPHANAGE_H
6#define BITCOIN_NODE_TXORPHANAGE_H
The basic transaction that is broadcasted on the network and contained in blocks.
A class to track orphan transactions (failed on TX_MISSING_INPUTS) Since we cannot distinguish orphan...
virtual void SanityCheck() const =0
Check consistency between PeerOrphanInfo and m_orphans.
virtual Count CountAnnouncements() const =0
Number of announcements, i.e.
virtual std::vector< CTransactionRef > GetChildrenFromSamePeer(const CTransactionRef &parent, NodeId nodeid) const =0
Get all children that spend from this tx and were received from nodeid.
virtual bool HaveTxToReconsider(NodeId peer)=0
Does this peer have any work to do?
virtual bool AddTx(const CTransactionRef &tx, NodeId peer)=0
Add a new orphan transaction.
virtual Usage MaxGlobalUsage() const =0
Get the maximum global usage allowed.
virtual Count AnnouncementsFromPeer(NodeId peer) const =0
Number of orphans stored from this peer.
virtual Count CountUniqueOrphans() const =0
Number of unique orphans (by wtxid).
virtual std::vector< OrphanInfo > GetOrphanTransactions() const =0
Get all orphan transactions.
virtual Usage TotalOrphanUsage() const =0
Get the total usage (weight) of all orphans.
virtual void EraseForBlock(const CBlock &block)=0
Erase all orphans included in or invalidated by a new block.
virtual Count TotalLatencyScore() const =0
Get the total latency score of all orphans.
virtual ~TxOrphanage()=default
virtual std::vector< std::pair< Wtxid, NodeId > > AddChildrenToWorkSet(const CTransaction &tx, FastRandomContext &rng)=0
Add any orphans that list a particular tx as a parent into the from peer's work set.
virtual Usage UsageByPeer(NodeId peer) const =0
Total usage (weight) of orphans for which this peer is an announcer.
virtual bool AddAnnouncer(const Wtxid &wtxid, NodeId peer)=0
Add an additional announcer to an orphan if it exists.
virtual Count MaxGlobalLatencyScore() const =0
Get the maximum global latency score allowed.
virtual CTransactionRef GetTx(const Wtxid &wtxid) const =0
Get a transaction by its witness txid.
virtual Count MaxPeerLatencyScore() const =0
Get the maximum latency score allowed per peer.
virtual bool HaveTxFromPeer(const Wtxid &wtxid, NodeId peer) const =0
Check if a {tx, peer} exists in the orphanage.
virtual void EraseForPeer(NodeId peer)=0
Maybe erase all orphans announced by a peer (eg, after that peer disconnects).
virtual CTransactionRef GetTxToReconsider(NodeId peer)=0
Extract a transaction from a peer's work set, and flip it back to non-reconsiderable.
virtual Usage ReservedPeerUsage() const =0
Get the reserved usage per peer.
virtual bool HaveTx(const Wtxid &wtxid) const =0
Check if we already have an orphan transaction (by wtxid only)
virtual Count LatencyScoreFromPeer(NodeId peer) const =0
Latency score of transactions announced by this peer.
virtual bool EraseTx(const Wtxid &wtxid)=0
Erase an orphan by wtxid, including all announcements if there are multiple.
transaction_identifier represents the two canonical transaction identifier types (txid,...
std::unique_ptr< TxOrphanage > MakeTxOrphanage() noexcept
Create a new TxOrphanage instance.
static constexpr unsigned int DEFAULT_MAX_ORPHANAGE_LATENCY_SCORE
Default value for TxOrphanage::m_max_global_latency_score.
static constexpr int64_t DEFAULT_RESERVED_ORPHAN_WEIGHT_PER_PEER
Default value for TxOrphanage::m_reserved_usage_per_peer.
std::shared_ptr< const CTransaction > CTransactionRef
Allows providing orphan information externally.
std::set< NodeId > announcers
Peers added with AddTx or AddAnnouncer.
OrphanInfo(CTransactionRef tx, std::set< NodeId > &&announcers)