clusterlin: add DepGraph::RemoveTransactions and support for holes in DepGraph

This commits introduces support in DepGraph for the transaction positions to be
non-continuous. Specifically, it adds:
* DepGraph::RemoveTransactions which removes 0 or more positions from a DepGraph.
* DepGraph::Positions() to get a set of which positions are in use.
* DepGraph::PositionRange() to get the highest used position in a DepGraph + 1.

In addition, it extends the DepGraphFormatter format to support holes in a
compatible way (it serializes non-holey DepGraphs identically to the old code,
and deserializes them the same way)
This commit is contained in:
Pieter Wuille
2024-09-09 15:12:15 -04:00
parent 75b5d42419
commit 0606e66fdb
7 changed files with 267 additions and 79 deletions

View File

@@ -40,7 +40,7 @@ void assertion_fail(std::string_view file, int line, std::string_view func, std:
/** Helper for Assert()/Assume() */
template <bool IS_ASSERT, typename T>
T&& inline_assertion_check(LIFETIMEBOUND T&& val, [[maybe_unused]] const char* file, [[maybe_unused]] int line, [[maybe_unused]] const char* func, [[maybe_unused]] const char* assertion)
constexpr T&& inline_assertion_check(LIFETIMEBOUND T&& val, [[maybe_unused]] const char* file, [[maybe_unused]] int line, [[maybe_unused]] const char* func, [[maybe_unused]] const char* assertion)
{
if constexpr (IS_ASSERT
#ifdef ABORT_ON_FAILED_ASSUME

View File

@@ -64,13 +64,13 @@ struct FeeFrac
int32_t size;
/** Construct an IsEmpty() FeeFrac. */
inline FeeFrac() noexcept : fee{0}, size{0} {}
constexpr inline FeeFrac() noexcept : fee{0}, size{0} {}
/** Construct a FeeFrac with specified fee and size. */
inline FeeFrac(int64_t f, int32_t s) noexcept : fee{f}, size{s} {}
constexpr inline FeeFrac(int64_t f, int32_t s) noexcept : fee{f}, size{s} {}
inline FeeFrac(const FeeFrac&) noexcept = default;
inline FeeFrac& operator=(const FeeFrac&) noexcept = default;
constexpr inline FeeFrac(const FeeFrac&) noexcept = default;
constexpr inline FeeFrac& operator=(const FeeFrac&) noexcept = default;
/** Check if this is empty (size and fee are 0). */
bool inline IsEmpty() const noexcept {