mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
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.
This commit is contained in:
parent
eaab55ffc8
commit
abf50649d1
1 changed files with 7 additions and 11 deletions
|
@ -134,9 +134,8 @@ struct DepGraphFormatter
|
||||||
});
|
});
|
||||||
|
|
||||||
/** Which transactions the deserializer already knows when it has deserialized what has
|
/** Which transactions the deserializer already knows when it has deserialized what has
|
||||||
* been serialized here so far, and in what order. */
|
* been serialized here so far. */
|
||||||
std::vector<ClusterIndex> rebuilt_order;
|
SetType done;
|
||||||
rebuilt_order.reserve(depgraph.TxCount());
|
|
||||||
|
|
||||||
// Loop over the transactions in topological order.
|
// Loop over the transactions in topological order.
|
||||||
for (ClusterIndex topo_idx = 0; topo_idx < topo_order.size(); ++topo_idx) {
|
for (ClusterIndex topo_idx = 0; topo_idx < topo_order.size(); ++topo_idx) {
|
||||||
|
@ -166,14 +165,11 @@ struct DepGraphFormatter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Write position information.
|
// Write position information.
|
||||||
ClusterIndex insert_distance = 0;
|
// The new transaction is to be inserted N positions back from the end of the cluster.
|
||||||
while (insert_distance < rebuilt_order.size()) {
|
// Emit N to indicate that that many insertion choices are skipped.
|
||||||
// Loop to find how far from the end in rebuilt_order to insert.
|
auto skips = (done - SetType::Fill(idx)).Count();
|
||||||
if (idx > *(rebuilt_order.end() - 1 - insert_distance)) break;
|
s << VARINT(diff + skips);
|
||||||
++insert_distance;
|
done.Set(idx);
|
||||||
}
|
|
||||||
rebuilt_order.insert(rebuilt_order.end() - insert_distance, idx);
|
|
||||||
s << VARINT(diff + insert_distance);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Output a final 0 to denote the end of the graph.
|
// Output a final 0 to denote the end of the graph.
|
||||||
|
|
Loading…
Add table
Reference in a new issue