diff options
author | Pieter Wuille <pieter@wuille.net> | 2024-09-08 17:42:25 -0400 |
---|---|---|
committer | Pieter Wuille <pieter@wuille.net> | 2024-10-07 13:47:52 -0400 |
commit | abf50649d13018bf40c5803730a03053737efeee (patch) | |
tree | 4a2d0c96633145b0b259479362f2b457f32f73fd /src | |
parent | eaab55ffc8102140086297877747b7fa07b419eb (diff) |
clusterlin: simplify DepGraphFormatter::Ser
This does not change the serialization format.
It turns out that it is unnecessary to keep track of the order of transactions
in the so-far reconstructed DepGraph to decide how far from the end to insert
a new transaction.
Diffstat (limited to 'src')
-rw-r--r-- | src/test/util/cluster_linearize.h | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/test/util/cluster_linearize.h b/src/test/util/cluster_linearize.h index 1ee0f7c2a7..a9ae4ff12a 100644 --- a/src/test/util/cluster_linearize.h +++ b/src/test/util/cluster_linearize.h @@ -134,9 +134,8 @@ struct DepGraphFormatter }); /** Which transactions the deserializer already knows when it has deserialized what has - * been serialized here so far, and in what order. */ - std::vector<ClusterIndex> rebuilt_order; - rebuilt_order.reserve(depgraph.TxCount()); + * been serialized here so far. */ + SetType done; // Loop over the transactions in topological order. for (ClusterIndex topo_idx = 0; topo_idx < topo_order.size(); ++topo_idx) { @@ -166,14 +165,11 @@ struct DepGraphFormatter } } // Write position information. - ClusterIndex insert_distance = 0; - while (insert_distance < rebuilt_order.size()) { - // Loop to find how far from the end in rebuilt_order to insert. - if (idx > *(rebuilt_order.end() - 1 - insert_distance)) break; - ++insert_distance; - } - rebuilt_order.insert(rebuilt_order.end() - insert_distance, idx); - s << VARINT(diff + insert_distance); + // The new transaction is to be inserted N positions back from the end of the cluster. + // Emit N to indicate that that many insertion choices are skipped. + auto skips = (done - SetType::Fill(idx)).Count(); + s << VARINT(diff + skips); + done.Set(idx); } // Output a final 0 to denote the end of the graph. |