![]() |
Bitcoin Core 29.99.0
P2P Digital Currency
|
A class to track orphan transactions (failed on TX_MISSING_INPUTS) Since we cannot distinguish orphans from bad transactions with non-existent inputs, we heavily limit the amount of announcements (unique (NodeId, wtxid) pairs), the number of inputs, and size of the orphans stored (both individual and summed). More...
#include <txorphanage.h>
Classes | |
struct | OrphanInfo |
Allows providing orphan information externally. More... | |
Public Types | |
using | Usage = int64_t |
using | Count = unsigned int |
Public Member Functions | |
virtual | ~TxOrphanage ()=default |
virtual bool | AddTx (const CTransactionRef &tx, NodeId peer)=0 |
Add a new orphan transaction. More... | |
virtual bool | AddAnnouncer (const Wtxid &wtxid, NodeId peer)=0 |
Add an additional announcer to an orphan if it exists. More... | |
virtual CTransactionRef | GetTx (const Wtxid &wtxid) const =0 |
Get a transaction by its witness txid. More... | |
virtual bool | HaveTx (const Wtxid &wtxid) const =0 |
Check if we already have an orphan transaction (by wtxid only) More... | |
virtual bool | HaveTxFromPeer (const Wtxid &wtxid, NodeId peer) const =0 |
Check if a {tx, peer} exists in the orphanage. More... | |
virtual CTransactionRef | GetTxToReconsider (NodeId peer)=0 |
Extract a transaction from a peer's work set, and flip it back to non-reconsiderable. More... | |
virtual bool | EraseTx (const Wtxid &wtxid)=0 |
Erase an orphan by wtxid, including all announcements if there are multiple. More... | |
virtual void | EraseForPeer (NodeId peer)=0 |
Maybe erase all orphans announced by a peer (eg, after that peer disconnects). More... | |
virtual void | EraseForBlock (const CBlock &block)=0 |
Erase all orphans included in or invalidated by a new block. More... | |
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. More... | |
virtual bool | HaveTxToReconsider (NodeId peer)=0 |
Does this peer have any work to do? More... | |
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. More... | |
virtual std::vector< OrphanInfo > | GetOrphanTransactions () const =0 |
Get all orphan transactions. More... | |
virtual Usage | TotalOrphanUsage () const =0 |
Get the total usage (weight) of all orphans. More... | |
virtual Usage | UsageByPeer (NodeId peer) const =0 |
Total usage (weight) of orphans for which this peer is an announcer. More... | |
virtual void | SanityCheck () const =0 |
Check consistency between PeerOrphanInfo and m_orphans. More... | |
virtual Count | CountAnnouncements () const =0 |
Number of announcements, i.e. More... | |
virtual Count | CountUniqueOrphans () const =0 |
Number of unique orphans (by wtxid). More... | |
virtual Count | AnnouncementsFromPeer (NodeId peer) const =0 |
Number of orphans stored from this peer. More... | |
virtual Count | LatencyScoreFromPeer (NodeId peer) const =0 |
Latency score of transactions announced by this peer. More... | |
virtual Count | MaxGlobalLatencyScore () const =0 |
Get the maximum global latency score allowed. More... | |
virtual Count | TotalLatencyScore () const =0 |
Get the total latency score of all orphans. More... | |
virtual Usage | ReservedPeerUsage () const =0 |
Get the reserved usage per peer. More... | |
virtual Count | MaxPeerLatencyScore () const =0 |
Get the maximum latency score allowed per peer. More... | |
virtual Usage | MaxGlobalUsage () const =0 |
Get the maximum global usage allowed. More... | |
A class to track orphan transactions (failed on TX_MISSING_INPUTS) Since we cannot distinguish orphans from bad transactions with non-existent inputs, we heavily limit the amount of announcements (unique (NodeId, wtxid) pairs), the number of inputs, and size of the orphans stored (both individual and summed).
We also try to prevent adversaries from churning this data structure: once global limits are reached, we continuously evict the oldest announcement (sorting non-reconsiderable orphans before reconsiderable ones) from the most resource-intensive peer until we are back within limits.
Definition at line 38 of file txorphanage.h.
using node::TxOrphanage::Count = unsigned int |
Definition at line 41 of file txorphanage.h.
using node::TxOrphanage::Usage = int64_t |
Definition at line 40 of file txorphanage.h.
|
virtualdefault |
Add an additional announcer to an orphan if it exists.
Otherwise, do nothing.
Implemented in node::TxOrphanageImpl.
|
pure virtual |
Add any orphans that list a particular tx as a parent into the from peer's work set.
Implemented in node::TxOrphanageImpl.
|
pure virtual |
Add a new orphan transaction.
Implemented in node::TxOrphanageImpl.
Number of orphans stored from this peer.
Implemented in node::TxOrphanageImpl.
|
pure virtual |
Number of announcements, i.e.
total size of m_orphans. Ones for the same wtxid are not de-duplicated. Not the same as TotalLatencyScore().
Implemented in node::TxOrphanageImpl.
|
pure virtual |
Number of unique orphans (by wtxid).
Implemented in node::TxOrphanageImpl.
|
pure virtual |
Erase all orphans included in or invalidated by a new block.
Implemented in node::TxOrphanageImpl.
|
pure virtual |
Maybe erase all orphans announced by a peer (eg, after that peer disconnects).
If an orphan has been announced by another peer, don't erase, just remove this peer from the list of announcers.
Implemented in node::TxOrphanageImpl.
|
pure virtual |
Erase an orphan by wtxid, including all announcements if there are multiple.
Returns true if an orphan was erased, false if no tx with this wtxid exists.
Implemented in node::TxOrphanageImpl.
|
pure virtual |
Get all children that spend from this tx and were received from nodeid.
Sorted reconsiderable before non-reconsiderable, then from most recent to least recent.
Implemented in node::TxOrphanageImpl.
|
pure virtual |
Get all orphan transactions.
Implemented in node::TxOrphanageImpl.
|
pure virtual |
Get a transaction by its witness txid.
Implemented in node::TxOrphanageImpl.
|
pure virtual |
Extract a transaction from a peer's work set, and flip it back to non-reconsiderable.
Returns nullptr if there are no transactions to work on. Otherwise returns the transaction reference, and removes it from the work set.
Implemented in node::TxOrphanageImpl.
|
pure virtual |
Check if we already have an orphan transaction (by wtxid only)
Implemented in node::TxOrphanageImpl.
|
pure virtual |
Check if a {tx, peer} exists in the orphanage.
Implemented in node::TxOrphanageImpl.
|
pure virtual |
Does this peer have any work to do?
Implemented in node::TxOrphanageImpl.
Latency score of transactions announced by this peer.
Implemented in node::TxOrphanageImpl.
|
pure virtual |
Get the maximum global latency score allowed.
Implemented in node::TxOrphanageImpl.
|
pure virtual |
Get the maximum global usage allowed.
Implemented in node::TxOrphanageImpl.
|
pure virtual |
Get the maximum latency score allowed per peer.
Implemented in node::TxOrphanageImpl.
|
pure virtual |
Get the reserved usage per peer.
Implemented in node::TxOrphanageImpl.
|
pure virtual |
Check consistency between PeerOrphanInfo and m_orphans.
Recalculate counters and ensure they match what is cached.
Implemented in node::TxOrphanageImpl.
|
pure virtual |
Get the total latency score of all orphans.
Implemented in node::TxOrphanageImpl.
|
pure virtual |
Get the total usage (weight) of all orphans.
If an orphan has multiple announcers, its usage is only counted once within this total.
Implemented in node::TxOrphanageImpl.
Total usage (weight) of orphans for which this peer is an announcer.
If an orphan has multiple announcers, its weight will be accounted for in each PeerOrphanInfo, so the total of all peers' UsageByPeer() may be larger than TotalOrphanUsage(). Similarly, UsageByPeer() may be far higher than ReservedPeerUsage(), particularly if many peers have provided the same orphans.
Implemented in node::TxOrphanageImpl.