mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-11 13:13:49 +01:00
txgraph: Add DoWork function (feature)
This can be called when the caller has time to spend now, and wants future operations to be fast.
This commit is contained in:
@@ -428,6 +428,8 @@ public:
|
||||
void ApplyDependencies(int level) noexcept;
|
||||
/** Make a specified Cluster have quality ACCEPTABLE or OPTIMAL. */
|
||||
void MakeAcceptable(Cluster& cluster) noexcept;
|
||||
/** Make all Clusters at the specified level have quality ACCEPTABLE or OPTIMAL. */
|
||||
void MakeAllAcceptable(int level) noexcept;
|
||||
|
||||
// Implementations for the public TxGraph interface.
|
||||
|
||||
@@ -436,6 +438,8 @@ public:
|
||||
void AddDependency(const Ref& parent, const Ref& child) noexcept final;
|
||||
void SetTransactionFee(const Ref&, int64_t fee) noexcept final;
|
||||
|
||||
void DoWork() noexcept final;
|
||||
|
||||
void StartStaging() noexcept final;
|
||||
void CommitStaging() noexcept final;
|
||||
void AbortStaging() noexcept final;
|
||||
@@ -1370,6 +1374,17 @@ void TxGraphImpl::MakeAcceptable(Cluster& cluster) noexcept
|
||||
}
|
||||
}
|
||||
|
||||
void TxGraphImpl::MakeAllAcceptable(int level) noexcept
|
||||
{
|
||||
ApplyDependencies(level);
|
||||
auto& clusterset = GetClusterSet(level);
|
||||
if (clusterset.m_oversized == true) return;
|
||||
auto& queue = clusterset.m_clusters[int(QualityLevel::NEEDS_RELINEARIZE)];
|
||||
while (!queue.empty()) {
|
||||
MakeAcceptable(*queue.back().get());
|
||||
}
|
||||
}
|
||||
|
||||
Cluster::Cluster(TxGraphImpl& graph, const FeePerWeight& feerate, GraphIndex graph_index) noexcept
|
||||
{
|
||||
// Create a new transaction in the DepGraph, and remember its position in m_mapping.
|
||||
@@ -1942,6 +1957,13 @@ void TxGraphImpl::SanityCheck() const
|
||||
}
|
||||
}
|
||||
|
||||
void TxGraphImpl::DoWork() noexcept
|
||||
{
|
||||
for (int level = 0; level <= GetTopLevel(); ++level) {
|
||||
MakeAllAcceptable(level);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
TxGraph::Ref::~Ref()
|
||||
|
||||
Reference in New Issue
Block a user