Skip to content

Commit

Permalink
Updated decoding description (#111)
Browse files Browse the repository at this point in the history
* Updated decoding description

* Fixed English

* Fixed English
  • Loading branch information
ChiaMineJP authored Feb 23, 2022
1 parent 6a8a121 commit 5abb2f5
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions clvm/serialize.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
# decoding:
# read a byte
# if it's 0xfe, it's nil (which might be same as 0)
# if it's 0x80, it's nil (which might be same as 0)
# if it's 0xff, it's a cons box. Read two items, build cons
# otherwise, number of leading set bits is length in bytes to read size
# 0-0x7f are literal one byte values
# leading bits is the count of bytes to read of size
# 0x80-0xbf is a size of one byte (perform logical and of first byte with 0x3f to get size)
# 0xc0-0xdf is a size of two bytes (perform logical and of first byte with 0x1f)
# 0xe0-0xef is 3 bytes ((perform logical and of first byte with 0xf))
# 0xf0-0xf7 is 4 bytes ((perform logical and of first byte with 0x7))
# 0xf7-0xfb is 5 bytes ((perform logical and of first byte with 0x3))
# For example, if the bit fields of the first byte read are:
# 10xx xxxx -> 1 byte is allocated for size_byte, and the value of the size is 00xx xxxx
# 110x xxxx -> 2 bytes are allocated for size_byte, and the value of the size 000x xxxx xxxx xxxx
# 1110 xxxx -> 3 bytes allocated. The size is 0000 xxxx xxxx xxxx xxxx xxxx
# 1111 0xxx -> 4 bytes allocated.
# 1111 10xx -> 5 bytes allocated.
# If the first byte read is one of the following:
# 1000 0000 -> 0 bytes : nil
# 0000 0000 -> 1 byte : zero (b'\x00')
import io
from .CLVMObject import CLVMObject

Expand Down

0 comments on commit 5abb2f5

Please sign in to comment.