fix typo, and fix bitlist end-bit description
This commit is contained in:
parent
4768ec89f6
commit
e984d10a0c
|
@ -129,7 +129,7 @@ return bytes(array)
|
|||
|
||||
### `Bitlist[N]`
|
||||
|
||||
Note that from the offset coding, the length (in bytes) of the bitlist is known. An additional `1` bit is added at position `N` where `N` is the legnth of the bitlist so that the length in bits will also be known.
|
||||
Note that from the offset coding, the length (in bytes) of the bitlist is known. An additional `1` bit is added to the end, at index `e` where `e` is the length of the bitlist (not the limit), so that the length in bits will also be known.
|
||||
|
||||
```python
|
||||
array = [0] * ((len(value) // 8) + 1)
|
||||
|
@ -179,7 +179,7 @@ Deserialization can be implemented using a recursive algorithm. The deserializat
|
|||
* Using the first offset, we can compute the length of the list (divide by `BYTES_PER_LENGTH_OFFSET`), as it gives us the total number of bytes in the offset data.
|
||||
* The size of each object in the vector/list can be inferred from the difference of two offsets. To get the size of the last object, the total number of bytes has to be known (it is not generally possible to deserialize an SSZ object of unknown length)
|
||||
* Containers follow the same principles as vectors, with the difference that there may be fixed-size objects in a container as well. This means the `fixed_parts` data will contain offsets as well as fixed-size objects.
|
||||
* In the case of bitlists, the length in bits cannot be uniquely inferred from the number of bytes in the object. Because of this, they have a bit in position `N` where `N` is the length of the list that is always set. This bit has to be used to infer the size of the bitlist in bits.
|
||||
* In the case of bitlists, the length in bits cannot be uniquely inferred from the number of bytes in the object. Because of this, they have a bit at the end that is always set. This bit has to be used to infer the size of the bitlist in bits.
|
||||
|
||||
Note that deserialization requires hardening against invalid inputs. A non-exhaustive list:
|
||||
|
||||
|
|
Loading…
Reference in New Issue