mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-26 17:02:00 +02:00
txgraph: Generalize GetClusterRefs to support subsections (preparation)
This is preparation for a next commit which will need a way to extract Refs for just individual chunks from a cluster.
This commit is contained in:
parent
c28a602e00
commit
883df3648e
@ -151,8 +151,9 @@ public:
|
|||||||
/** Process elements from the front of args that apply to this cluster, and append Refs for the
|
/** Process elements from the front of args that apply to this cluster, and append Refs for the
|
||||||
* union of their descendants to output. */
|
* union of their descendants to output. */
|
||||||
void GetDescendantRefs(const TxGraphImpl& graph, std::span<std::pair<Cluster*, DepGraphIndex>>& args, std::vector<TxGraph::Ref*>& output) noexcept;
|
void GetDescendantRefs(const TxGraphImpl& graph, std::span<std::pair<Cluster*, DepGraphIndex>>& args, std::vector<TxGraph::Ref*>& output) noexcept;
|
||||||
/** Get a vector of Refs for all elements of this Cluster, in linearization order. */
|
/** Populate range with refs for the transactions in this Cluster's linearization, from
|
||||||
std::vector<TxGraph::Ref*> GetClusterRefs(const TxGraphImpl& graph) noexcept;
|
* position start_pos until start_pos+range.size()-1, inclusive. */
|
||||||
|
void GetClusterRefs(TxGraphImpl& graph, std::span<TxGraph::Ref*> range, LinearizationIndex start_pos) noexcept;
|
||||||
/** Get the individual transaction feerate of a Cluster element. */
|
/** Get the individual transaction feerate of a Cluster element. */
|
||||||
FeePerWeight GetIndividualFeerate(DepGraphIndex idx) noexcept;
|
FeePerWeight GetIndividualFeerate(DepGraphIndex idx) noexcept;
|
||||||
/** Modify the fee of a Cluster element. */
|
/** Modify the fee of a Cluster element. */
|
||||||
@ -1632,17 +1633,16 @@ void Cluster::GetDescendantRefs(const TxGraphImpl& graph, std::span<std::pair<Cl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<TxGraph::Ref*> Cluster::GetClusterRefs(const TxGraphImpl& graph) noexcept
|
void Cluster::GetClusterRefs(TxGraphImpl& graph, std::span<TxGraph::Ref*> range, LinearizationIndex start_pos) noexcept
|
||||||
{
|
{
|
||||||
std::vector<TxGraph::Ref*> ret;
|
// Translate the transactions in the Cluster (in linearization order, starting at start_pos in
|
||||||
ret.reserve(m_linearization.size());
|
// the linearization) to Refs, and fill them in range.
|
||||||
// Translate all transactions in the Cluster (in linearization order) to Refs.
|
for (auto& ref : range) {
|
||||||
for (auto idx : m_linearization) {
|
Assume(start_pos < m_linearization.size());
|
||||||
const auto& entry = graph.m_entries[m_mapping[idx]];
|
const auto& entry = graph.m_entries[m_mapping[m_linearization[start_pos++]]];
|
||||||
Assume(entry.m_ref != nullptr);
|
Assume(entry.m_ref != nullptr);
|
||||||
ret.push_back(entry.m_ref);
|
ref = entry.m_ref;
|
||||||
}
|
}
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FeePerWeight Cluster::GetIndividualFeerate(DepGraphIndex idx) noexcept
|
FeePerWeight Cluster::GetIndividualFeerate(DepGraphIndex idx) noexcept
|
||||||
@ -1786,7 +1786,9 @@ std::vector<TxGraph::Ref*> TxGraphImpl::GetCluster(const Ref& arg, bool main_onl
|
|||||||
if (cluster == nullptr) return {};
|
if (cluster == nullptr) return {};
|
||||||
// Make sure the Cluster has an acceptable quality level, and then dispatch to it.
|
// Make sure the Cluster has an acceptable quality level, and then dispatch to it.
|
||||||
MakeAcceptable(*cluster);
|
MakeAcceptable(*cluster);
|
||||||
return cluster->GetClusterRefs(*this);
|
std::vector<TxGraph::Ref*> ret(cluster->GetTxCount());
|
||||||
|
cluster->GetClusterRefs(*this, ret, 0);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
TxGraph::GraphIndex TxGraphImpl::GetTransactionCount(bool main_only) noexcept
|
TxGraph::GraphIndex TxGraphImpl::GetTransactionCount(bool main_only) noexcept
|
||||||
|
Loading…
x
Reference in New Issue
Block a user