Skip to content

Commit f2e5e47

Browse files
committed
review comments
1 parent bb1dfc8 commit f2e5e47

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

docs/compressed-serialization.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ duplicating them. These references are referred to as "back references".
99
The original serialization format had 3 tokens.
1010

1111
- `0xff` - a pair, followed by the left and right sub-trees.
12-
- `0x80` - NIL, an empty atom
13-
- Atom - serialized with a UTF-8 like encoding. (see [CLVM serialization](https://chialisp.com/clvm/#serialization))
12+
- Atom - values, in the form of an array of bytes. For more details, see [CLVM
13+
serialization](https://chialisp.com/clvm/#serialization).
1414

1515
A back reference is introduced by `0xfe` followed by an atom. The atom refers
1616
back to an already decoded sub tree. The bits are interpreted just like an
@@ -29,9 +29,9 @@ byte index: | byte 0 | byte 1 | byte 2 | byte 3 |
2929
bit traversal direction: <- x
3030
```
3131

32-
A 0 bit means follow the left sub-tree, a 1-bit means follow the right sub-tree.
33-
The last 1-bit is the terminator, and means we should pick the node at the
34-
current location in the tree.
32+
A `0` bit means follow the left sub-tree while a `1` bit means follow the right
33+
sub-tree. The last 1-bit is the terminator, and means we should pick the node at
34+
the current location in the tree.
3535

3636
e.g. The reference `0b1011` means:
3737

@@ -68,7 +68,7 @@ as we parse, so what a back reference refers to changes as we parse the
6868
serialized CLVM tree. To understand what the parse stack is, we first need to
6969
look at how CLVM is parsed.
7070

71-
The parser has a stack of _operations_ and a stack of the parsed result (the
71+
The parser has a stack of _operations_ and a stack of the parsed results (the
7272
parse stack).
7373

7474
There are 2 operations that can be pushed onto the operations stack:
@@ -81,7 +81,7 @@ encounter when parsing; an atom or a pair (followed by the left- and right
8181
sub-trees).
8282

8383
We keep popping operations off of the op-stack until it's empty. We take the
84-
following actions dependin on the operation:
84+
following actions depending on the operation:
8585

8686
- `Traverse`, inspect the next byte of the input stream. If it's a pair (`0xff`)
8787
we push `Cons`, `Traverse`, `Traverse` onto the operations stack. If it's an
@@ -128,7 +128,7 @@ A back reference to `3` would be: `0b1100` (right, left).
128128
### Example back-reference
129129

130130
Consider the following LISP structure: ((`1` . `2`) . (`1` . `2`))
131-
It Can be serialized as `0xff` `0xff` `1` `2` `0xfe` `0b10`
131+
It can be serialized as `0xff` `0xff` `1` `2` `0xfe` `0b10`
132132

133133
The parsing steps would be as follows:
134134

@@ -181,8 +181,7 @@ When serializing with compression, we need to assign a tree-hash and an
181181
the sub-tree itself or a back-reference, we need to know whether we have already
182182
serialized an identical sub tree. If we have, we then have to perform a search
183183
from that node up all of its parents until we reach the top of the parse stack.
184-
This, additionally, requires a data structure that knows about the parents of
185-
all nodes.
184+
This requires a data structure that knows about the parents of all nodes.
186185

187186
This search is performed in `find_path()`. There may be multiple paths leading
188187
to the stack (if the same structure is repeated in multiple places). We pick the

0 commit comments

Comments
 (0)