![]() |
Bitcoin Core 31.99.0
P2P Digital Currency
|
A formatter for a bespoke serialization for acyclic DepGraph objects. More...
#include <cluster_linearize.h>
Public Member Functions | |
| template<typename Stream , typename SetType > | |
| void | Unser (Stream &s, DepGraph< SetType > &depgraph) |
Static Public Member Functions | |
| static uint64_t | SignedToUnsigned (int64_t x) noexcept |
| Convert x>=0 to 2x (even), x<0 to -2x-1 (odd). More... | |
| static int64_t | UnsignedToSigned (uint64_t x) noexcept |
| Convert even x to x/2 (>=0), odd x to -(x/2)-1 (<0). More... | |
| template<typename Stream , typename SetType > | |
| static void | Ser (Stream &s, const DepGraph< SetType > &depgraph) |
A formatter for a bespoke serialization for acyclic DepGraph objects.
The serialization format outputs information about transactions in a topological order (parents before children), together with position information so transactions can be moved back to their correct position on deserialization.
The list of skip values encodes the dependencies of t, as well as its position in the cluster. Each skip value is the number of possibilities that were available, but were not taken. These possibilities are, in order:
Let's say you have a 7-transaction cluster, consisting of transactions F,A,C,B,_,G,E,_,D (where _ represent holes; unused positions within the DepGraph) but serialized in order A,B,C,D,E,F,G, because that happens to be a topological ordering. By the time G gets serialized, what has been serialized already represents the cluster F,A,C,B,_,E,_,D (in that order). G has B and E as direct parents, and E depends on C.
In this case, the possibilities are, in order:
The skip values in this case are 1 (G->F), 1 (G->D), 4 (G->A, G at end, G before D, G before hole). No skip after 4 is needed (or permitted), because there can only be one position for G. Also note that G->C is not included in the list of possibilities, as it is implied by the included G->E and E->C that came before it. On deserialization, if the last skip value was 8 or larger (putting G before the beginning of the cluster), it is interpreted as wrapping around back to the end.
Rationale:
Definition at line 97 of file cluster_linearize.h.
|
inlinestatic |
Construct a topological order to serialize the transactions in.
Which positions (incl. holes) the deserializer already knows when it has deserialized what has been serialized here so far.
Which depgraph index we are currently writing.
< How many potential parent/child relations we have skipped over.
Which depgraph index we are currently considering as parent of idx.
Definition at line 120 of file cluster_linearize.h.
|
inlinestaticnoexcept |
Convert x>=0 to 2x (even), x<0 to -2x-1 (odd).
Definition at line 100 of file cluster_linearize.h.
|
inline |
The dependency graph which we deserialize into first, with transactions in topological serialization order, not original cluster order.
Mapping from serialization order to cluster order, used later to reconstruct the cluster order.
How big the entries vector in the reconstructed depgraph will be (including holes).
< The new transaction's fee and size.
< The new transaction's ancestors (excluding itself).
< How many potential parents/insertions we have to skip.
Which topo_depgraph index we are currently considering as parent of topo_idx.
Definition at line 185 of file cluster_linearize.h.
|
inlinestaticnoexcept |
Convert even x to x/2 (>=0), odd x to -(x/2)-1 (<0).
Definition at line 110 of file cluster_linearize.h.