15 #ifndef BITCOIN_TXGRAPH_H 16 #define BITCOIN_TXGRAPH_H 98 virtual void AddDependency(
const Ref& parent,
const Ref& child) noexcept = 0;
108 virtual bool DoWork(uint64_t max_cost) noexcept = 0;
130 virtual
bool Exists(const Ref& arg,
Level level) noexcept = 0;
178 virtual
std::vector<Ref*>
Trim() noexcept = 0;
190 virtual std::optional<std::pair<std::vector<Ref*>,
FeePerWeight>> GetCurrentChunk() noexcept = 0;
192 virtual void Include() noexcept = 0;
195 virtual void Skip() noexcept = 0;
242 Ref() noexcept = default;
247 Ref& operator=(
Ref&& other) noexcept = delete;
248 Ref(
Ref&& other) noexcept;
251 Ref& operator=(const
Ref&) = delete;
267 unsigned max_cluster_count,
268 uint64_t max_cluster_size,
269 uint64_t acceptable_cost,
273 #endif // BITCOIN_TXGRAPH_H Always refers to the main graph, whether staging is present or not.
static constexpr unsigned MAX_CLUSTER_COUNT_LIMIT
static GraphIndex & GetRefIndex(Ref &arg) noexcept
virtual void UnlinkRef(GraphIndex index) noexcept=0
Inform the TxGraph implementation that a TxGraph::Ref was destroyed.
virtual void AbortStaging() noexcept=0
Discard the existing active staging graph (which must exist).
static TxGraph *& GetRefGraph(Ref &arg) noexcept
virtual std::strong_ordering CompareMainOrder(const Ref &a, const Ref &b) noexcept=0
Compare two transactions according to their order in the main graph.
virtual std::unique_ptr< BlockBuilder > GetBlockBuilder() noexcept=0
Construct a block builder, drawing chunks in order, from the main graph, which cannot be oversized...
GraphIndex m_index
Index into the Graph's m_entries.
virtual std::vector< Ref * > GetDescendantsUnion(std::span< const Ref *const > args, Level level) noexcept=0
Like GetDescendants, but return the Refs for all transactions in the union of the provided arguments'...
virtual size_t GetMainMemoryUsage() noexcept=0
Get the approximate memory usage for this object, just counting the main graph.
Tagged wrapper around FeeFrac to avoid unit confusion.
virtual void UpdateRef(GraphIndex index, Ref &new_location) noexcept=0
Inform the TxGraph implementation that a TxGraph::Ref has moved.
virtual void AddTransaction(Ref &arg, const FeePerWeight &feerate) noexcept=0
Initialize arg (which must be an empty Ref) to refer to a new transaction in this graph with the spec...
virtual void SetTransactionFee(const Ref &arg, int64_t fee) noexcept=0
Modify the fee of the specified transaction, in both the main graph and the staging graph if it exist...
TxGraph * m_graph
Which Graph the Entry lives in.
Data structure to encapsulate fees, sizes, and dependencies for a set of transactions.
Interface returned by GetBlockBuilder.
virtual void CommitStaging() noexcept=0
Replace the main graph with the staging graph (which must exist).
Ref() noexcept=default
Construct an empty Ref.
virtual FeePerWeight GetIndividualFeerate(const Ref &arg) noexcept=0
Get the individual transaction feerate of transaction arg.
virtual ~TxGraph()=default
Virtual destructor, so inheriting is safe.
virtual std::pair< std::vector< Ref * >, FeePerWeight > GetWorstMainChunk() noexcept=0
Get the last chunk in the main graph, i.e., the last chunk that would be returned by a BlockBuilder c...
virtual std::vector< Ref * > Trim() noexcept=0
Remove transactions (including their own descendants) according to a fast but best-effort strategy su...
uint32_t GraphIndex
Internal identifier for a transaction within a TxGraph.
virtual void RemoveTransaction(const Ref &arg) noexcept=0
Remove the specified transaction.
virtual bool DoWork(uint64_t max_cost) noexcept=0
TxGraph is internally lazy, and will not compute many things until they are needed.
virtual void SanityCheck() const =0
Perform an internal consistency check on this object.
virtual std::pair< std::vector< FeeFrac >, std::vector< FeeFrac > > GetMainStagingDiagrams() noexcept=0
For both main and staging (which must both exist and not be oversized), return the combined respectiv...
static TxGraph * GetRefGraph(const Ref &arg) noexcept
virtual std::vector< Ref * > GetDescendants(const Ref &arg, Level level) noexcept=0
Get pointers to all descendants of the specified transaction (including the transaction itself)...
virtual FeePerWeight GetMainChunkFeerate(const Ref &arg) noexcept=0
Get the feerate of the chunk which transaction arg is in, in the main graph.
Data structure storing a fee and size, ordered by increasing fee/size.
virtual void StartStaging() noexcept=0
Create a staging graph (which cannot exist already).
virtual GraphIndex CountDistinctClusters(std::span< const Ref *const >, Level level) noexcept=0
Count the number of distinct clusters that the specified transactions belong to.
virtual std::vector< Ref * > GetAncestors(const Ref &arg, Level level) noexcept=0
Get pointers to all ancestors of the specified transaction (including the transaction itself)...
virtual bool IsOversized(Level level) noexcept=0
Determine whether the graph is oversized (contains a connected component of more than the configured ...
virtual GraphIndex GetTransactionCount(Level level) noexcept=0
Get the total number of transactions in the graph.
virtual void AddDependency(const Ref &parent, const Ref &child) noexcept=0
Add a dependency between two specified transactions.
virtual bool Exists(const Ref &arg, Level level) noexcept=0
Determine whether arg exists in the graph (i.e., was not removed).
virtual std::vector< Ref * > GetCluster(const Ref &arg, Level level) noexcept=0
Get pointers to all transactions in the cluster which arg is in.
std::unique_ptr< TxGraph > MakeTxGraph(unsigned max_cluster_count, uint64_t max_cluster_size, uint64_t acceptable_cost, const std::function< std::strong_ordering(const TxGraph::Ref &, const TxGraph::Ref &)> &fallback_order) noexcept
Construct a new TxGraph with the specified limit on the number of transactions within a cluster...
virtual std::vector< Ref * > GetAncestorsUnion(std::span< const Ref *const > args, Level level) noexcept=0
Like GetAncestors, but return the Refs for all transactions in the union of the provided arguments' a...
Refers to staging if it exists, main otherwise.
virtual bool HaveStaging() const noexcept=0
Check whether a staging graph exists.
static GraphIndex GetRefIndex(const Ref &arg) noexcept