Documentation ¶
Index ¶
Constants ¶
View Source
const ( ByteRangeStart = 0x00 // not in use, here only for inclusivity ByteRangeEnd = 0x7f ShortStringRangeStart = 0x80 ShortStringRangeEnd = 0xb7 LongStringRangeStart = 0xb8 LongStringRangeEnd = 0xbf ShortListRangeStart = 0xc0 ShortListRangeEnd = 0xf7 LongListRangeStart = 0xf8 LongListRangeEnd = 0xff // not in use, here only for inclusivity MaxShortLengthAllowed = 55 MaxLongLengthAllowed = math.MaxInt64 )
Variables ¶
View Source
var ( ErrEmptyInput = errors.New("input data is empty") ErrInvalidStartIndex = errors.New("invalid start index") ErrIncompleteInput = errors.New("incomplete input! not enough bytes to read") ErrNonCanonicalInput = errors.New("non-canonical encoded input") ErrDataSizeTooLarge = errors.New("data size is larger than what is supported") ErrListSizeMismatch = errors.New("list size doesn't match the size of items") ErrTypeMismatch = errors.New("type extracted from input doesn't match the function") )
Functions ¶
func DecodeList ¶
DecodeList decodes a RLP-encoded list given the startIndex it returns a list of encodedItems, number of bytes that were read and err if any
func DecodeString ¶
DecodeString decodes a RLP-encoded string given the startIndex it returns decoded string, number of bytes that were read and err if any
func ReadSize ¶
ReadSize looks at the first byte at startIndex to decode the type and reads as many bytes as needed to determine the data byte size, it returns a flag if the type is string, start index of data part in the input, number of bytes that has to be read for data (from start index of data) and error if any.
it only supports RLP canonical form. RLP canonical form requires:
- if string is 0-55 bytes long (first byte is [0x80, 0xb7]), string length can't be 1 while string <= 0x7f
- if string is more than 55 bytes long (first byte is [0xb8, 0xbf]), string length can't be <= 55
- if string is more than 55 bytes long (first byte is [0xb8, 0xbf]), string length can't be encoded with leading 0s
- if list payload is more than 55 bytes long (first byte is [0xf8, 0xff]), list payload length can't be <= 55
- if list payload is more than 55 bytes long (first byte is [0xf8, 0xff]), list payload length can't be encoded with leading 0s
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.