mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
txgraph: Abstract out ClearLocator (refactor)
Move a number of related modifications to TxGraphImpl into a separate function for removal of transactions. This is preparation for a later commit where this will be useful in more than one place.
This commit is contained in:
parent
34aa3da5ad
commit
c99c7300b4
1 changed files with 13 additions and 2 deletions
|
@ -274,6 +274,8 @@ public:
|
|||
ClusterSetIndex InsertCluster(std::unique_ptr<Cluster>&& cluster, QualityLevel quality) noexcept;
|
||||
/** Change the QualityLevel of a Cluster (identified by old_quality and old_index). */
|
||||
void SetClusterQuality(QualityLevel old_quality, ClusterSetIndex old_index, QualityLevel new_quality) noexcept;
|
||||
/** Make a transaction not exist. It must currently exist. */
|
||||
void ClearLocator(GraphIndex index) noexcept;
|
||||
|
||||
// Functions for handling Refs.
|
||||
|
||||
|
@ -335,6 +337,16 @@ public:
|
|||
void SanityCheck() const final;
|
||||
};
|
||||
|
||||
void TxGraphImpl::ClearLocator(GraphIndex idx) noexcept
|
||||
{
|
||||
auto& entry = m_entries[idx];
|
||||
Assume(entry.m_locator.IsPresent());
|
||||
// Change the locator from Present to Missing.
|
||||
entry.m_locator.SetMissing();
|
||||
// Update the transaction count.
|
||||
--m_clusterset.m_txcount;
|
||||
}
|
||||
|
||||
void Cluster::Updated(TxGraphImpl& graph) noexcept
|
||||
{
|
||||
// Update all the Locators for this Cluster's Entrys.
|
||||
|
@ -385,9 +397,8 @@ void Cluster::ApplyRemovals(TxGraphImpl& graph, std::span<GraphIndex>& to_remove
|
|||
// that causes it to be accessed regardless.
|
||||
m_mapping[locator.index] = GraphIndex(-1);
|
||||
// - Mark it as removed in the Entry's locator.
|
||||
locator.SetMissing();
|
||||
graph.ClearLocator(idx);
|
||||
to_remove = to_remove.subspan(1);
|
||||
--graph.m_clusterset.m_txcount;
|
||||
} while(!to_remove.empty());
|
||||
|
||||
auto quality = m_quality;
|
||||
|
|
Loading…
Add table
Reference in a new issue