Expand description
Compact binary encoding for UBT nodes.
All node types use a 1-byte type tag prefix:
| Tag | Type | Size |
|---|---|---|
0x00 | Empty | 1 byte |
0x01 | Internal | 65 bytes (tag + two 32B hashes) |
0x02 | Stem | 64 + N×32 bytes (tag + stem + bitmap + values) |
0x03 | Leaf | 33 bytes (tag + 32B value) |
§StemNode layout
[1B type=0x02] [31B stem] [32B bitmap] [N×32B values]Bitmap: 256 bits, bit i set = subindex i present.
Bit ordering: byte[i/8] & (1 << (i%8)).
Values in ascending subindex order, only for set bits.
Enums§
- Decoded
Node - A decoded node from the wire format.
Constants§
- EMPTY_
NODE_ TAG - Type tag for empty nodes.
- INTERNAL_
NODE_ TAG - Type tag for internal nodes (two child hashes).
- LEAF_
NODE_ TAG - Type tag for leaf nodes (single value).
- STEM_
NODE_ TAG - Type tag for stem nodes (bitmap + values).
Functions§
- decode_
internal_ node - Decode an internal node from
[0x01] [32B left_hash] [32B right_hash]. - decode_
leaf_ node - Decode a leaf node from
[0x03] [32B value]. - decode_
node - Decode any node type by dispatching on the type tag.
- decode_
stem_ node - Decode a
StemNodefrom compact binary format. - encode_
empty_ node - Encode an empty node as
[0x00]. - encode_
internal_ node - Encode an internal node as
[0x01] [32B left_hash] [32B right_hash]. - encode_
leaf_ node - Encode a leaf node as
[0x03] [32B value]. - encode_
stem_ node - Encode a
StemNodeinto compact binary format. - encoded_
stem_ size - Returns the encoded size of a stem node without allocating.