Documentation
¶
Index ¶
- Variables
- func AppendZeroPadding(buf []byte, count int) []byte
- func CalculateLimit(maxCapacity, numItems, size uint64) uint64
- func ExpandSlice[T any](src []T, size int) []T
- func GetOffsetSlice(size int) []uint32
- func MarshalBool(dst []byte, b bool) []byte
- func MarshalOffset(dst []byte, offset int) []byte
- func MarshalUint8(dst []byte, i uint8) []byte
- func MarshalUint16(dst []byte, i uint16) []byte
- func MarshalUint32(dst []byte, i uint32) []byte
- func MarshalUint64(dst []byte, i uint64) []byte
- func NextPowerOfTwo(v uint64) uint
- func PutOffsetSlice(slice []uint32)
- func ReadOffset(buf []byte) uint64
- func ResolveSpecValueWithDefault(ds DynamicSpecs, name string, defaultValue uint64) (uint64, error)
- func UnmarshalBool(src []byte) bool
- func UnmarshallUint8(src []byte) uint8
- func UnmarshallUint16(src []byte) uint16
- func UnmarshallUint32(src []byte) uint32
- func UnmarshallUint64(src []byte) uint64
- func UpdateOffset(dst []byte, offset int)
- func ZeroBytes() []byte
- type BufferDecoder
- func (e *BufferDecoder) DecodeBool() (bool, error)
- func (e *BufferDecoder) DecodeBytes(buf []byte) ([]byte, error)
- func (e *BufferDecoder) DecodeBytesBuf(len int) ([]byte, error)
- func (e *BufferDecoder) DecodeOffset() (uint32, error)
- func (e *BufferDecoder) DecodeOffsetAt(pos int) uint32
- func (e *BufferDecoder) DecodeUint8() (uint8, error)
- func (e *BufferDecoder) DecodeUint16() (uint16, error)
- func (e *BufferDecoder) DecodeUint32() (uint32, error)
- func (e *BufferDecoder) DecodeUint64() (uint64, error)
- func (e *BufferDecoder) GetLength() int
- func (e *BufferDecoder) GetPosition() int
- func (e *BufferDecoder) PopLimit() int
- func (e *BufferDecoder) PushLimit(limit int)
- func (e *BufferDecoder) Seekable() bool
- func (e *BufferDecoder) SkipBytes(n int)
- type BufferEncoder
- func (e *BufferEncoder) EncodeBool(v bool)
- func (e *BufferEncoder) EncodeBytes(v []byte)
- func (e *BufferEncoder) EncodeOffset(v uint32)
- func (e *BufferEncoder) EncodeOffsetAt(pos int, v uint32)
- func (e *BufferEncoder) EncodeUint8(v uint8)
- func (e *BufferEncoder) EncodeUint16(v uint16)
- func (e *BufferEncoder) EncodeUint32(v uint32)
- func (e *BufferEncoder) EncodeUint64(v uint64)
- func (e *BufferEncoder) EncodeZeroPadding(n int)
- func (e *BufferEncoder) GetBuffer() []byte
- func (e *BufferEncoder) GetPosition() int
- func (e *BufferEncoder) Seekable() bool
- func (e *BufferEncoder) SetBuffer(buffer []byte)
- type Decoder
- type DynamicDecoder
- type DynamicEncoder
- type DynamicHashRoot
- type DynamicMarshaler
- type DynamicSizer
- type DynamicSpecs
- type DynamicUnmarshaler
- type Encoder
- type FastsszHashRoot
- type FastsszMarshaler
- type FastsszUnmarshaler
- type HashWalker
- type StreamDecoder
- func (e *StreamDecoder) DecodeBool() (bool, error)
- func (e *StreamDecoder) DecodeBytes(buf []byte) ([]byte, error)
- func (e *StreamDecoder) DecodeBytesBuf(l int) ([]byte, error)
- func (e *StreamDecoder) DecodeOffset() (uint32, error)
- func (e *StreamDecoder) DecodeOffsetAt(pos int) uint32
- func (e *StreamDecoder) DecodeUint8() (uint8, error)
- func (e *StreamDecoder) DecodeUint16() (uint16, error)
- func (e *StreamDecoder) DecodeUint32() (uint32, error)
- func (e *StreamDecoder) DecodeUint64() (uint64, error)
- func (e *StreamDecoder) GetLength() int
- func (e *StreamDecoder) GetPosition() int
- func (e *StreamDecoder) PopLimit() int
- func (e *StreamDecoder) PushLimit(limit int)
- func (e *StreamDecoder) Seekable() bool
- func (e *StreamDecoder) SkipBytes(n int)
- type StreamEncoder
- func (e *StreamEncoder) EncodeBool(v bool)
- func (e *StreamEncoder) EncodeBytes(v []byte)
- func (e *StreamEncoder) EncodeOffset(v uint32)
- func (e *StreamEncoder) EncodeOffsetAt(pos int, v uint32)
- func (e *StreamEncoder) EncodeUint8(v uint8)
- func (e *StreamEncoder) EncodeUint16(v uint16)
- func (e *StreamEncoder) EncodeUint32(v uint32)
- func (e *StreamEncoder) EncodeUint64(v uint64)
- func (e *StreamEncoder) EncodeZeroPadding(n int)
- func (e *StreamEncoder) GetBuffer() []byte
- func (e *StreamEncoder) GetPosition() int
- func (e *StreamEncoder) GetWriteError() error
- func (e *StreamEncoder) Seekable() bool
- func (e *StreamEncoder) SetBuffer(buffer []byte)
Constants ¶
This section is empty.
Variables ¶
var ( ErrListTooBig = fmt.Errorf("list length is higher than max value") ErrUnexpectedEOF = fmt.Errorf("unexpected end of SSZ") ErrOffset = fmt.Errorf("incorrect offset") ErrInvalidValueRange = fmt.Errorf("invalid value range") ErrInvalidUnionVariant = fmt.Errorf("invalid union variant") ErrVectorLength = fmt.Errorf("incorrect vector length") ErrNotImplemented = fmt.Errorf("not implemented") ErrBitlistNotTerminated = fmt.Errorf("bitlist misses mandatory termination bit") )
Functions ¶
func AppendZeroPadding ¶
AppendZeroPadding appends the specified number of zero bytes to buf
func CalculateLimit ¶
func ExpandSlice ¶ added in v1.1.1
ExpandSlice expands a slice to a byte slice
func GetOffsetSlice ¶ added in v1.2.0
func MarshalBool ¶
MarshalBool marshals a boolean to dst
func MarshalOffset ¶
MarshalOffset marshals an offset to dst
func MarshalUint8 ¶
MarshalUint8 marshals a little endian uint8 to dst
func MarshalUint16 ¶
MarshalUint16 marshals a little endian uint16 to dst
func MarshalUint32 ¶
MarshalUint32 marshals a little endian uint32 to dst
func MarshalUint64 ¶
MarshalUint64 marshals a little endian uint64 to dst
func NextPowerOfTwo ¶ added in v1.1.1
func PutOffsetSlice ¶ added in v1.2.0
func PutOffsetSlice(slice []uint32)
func ResolveSpecValueWithDefault ¶ added in v1.2.0
func ResolveSpecValueWithDefault(ds DynamicSpecs, name string, defaultValue uint64) (uint64, error)
func UnmarshalBool ¶
UnmarshalBool unmarshals a boolean from the src input
func UnmarshallUint8 ¶
UnmarshallUint8 unmarshals a little endian uint8 from the src input
func UnmarshallUint16 ¶
UnmarshallUint16 unmarshals a little endian uint16 from the src input
func UnmarshallUint32 ¶
UnmarshallUint32 unmarshals a little endian uint32 from the src input
func UnmarshallUint64 ¶
UnmarshallUint64 unmarshals a little endian uint64 from the src input
func UpdateOffset ¶
UpdateOffset updates the offset in dst
Types ¶
type BufferDecoder ¶ added in v1.2.0
type BufferDecoder struct {
// contains filtered or unexported fields
}
func NewBufferDecoder ¶ added in v1.2.0
func NewBufferDecoder(buffer []byte) *BufferDecoder
func (*BufferDecoder) DecodeBool ¶ added in v1.2.0
func (e *BufferDecoder) DecodeBool() (bool, error)
func (*BufferDecoder) DecodeBytes ¶ added in v1.2.0
func (e *BufferDecoder) DecodeBytes(buf []byte) ([]byte, error)
func (*BufferDecoder) DecodeBytesBuf ¶ added in v1.2.0
func (e *BufferDecoder) DecodeBytesBuf(len int) ([]byte, error)
func (*BufferDecoder) DecodeOffset ¶ added in v1.2.0
func (e *BufferDecoder) DecodeOffset() (uint32, error)
func (*BufferDecoder) DecodeOffsetAt ¶ added in v1.2.0
func (e *BufferDecoder) DecodeOffsetAt(pos int) uint32
func (*BufferDecoder) DecodeUint8 ¶ added in v1.2.0
func (e *BufferDecoder) DecodeUint8() (uint8, error)
func (*BufferDecoder) DecodeUint16 ¶ added in v1.2.0
func (e *BufferDecoder) DecodeUint16() (uint16, error)
func (*BufferDecoder) DecodeUint32 ¶ added in v1.2.0
func (e *BufferDecoder) DecodeUint32() (uint32, error)
func (*BufferDecoder) DecodeUint64 ¶ added in v1.2.0
func (e *BufferDecoder) DecodeUint64() (uint64, error)
func (*BufferDecoder) GetLength ¶ added in v1.2.0
func (e *BufferDecoder) GetLength() int
func (*BufferDecoder) GetPosition ¶ added in v1.2.0
func (e *BufferDecoder) GetPosition() int
func (*BufferDecoder) PopLimit ¶ added in v1.2.0
func (e *BufferDecoder) PopLimit() int
func (*BufferDecoder) PushLimit ¶ added in v1.2.0
func (e *BufferDecoder) PushLimit(limit int)
func (*BufferDecoder) Seekable ¶ added in v1.2.0
func (e *BufferDecoder) Seekable() bool
func (*BufferDecoder) SkipBytes ¶ added in v1.2.0
func (e *BufferDecoder) SkipBytes(n int)
type BufferEncoder ¶ added in v1.2.0
type BufferEncoder struct {
// contains filtered or unexported fields
}
func NewBufferEncoder ¶ added in v1.2.0
func NewBufferEncoder(buffer []byte) *BufferEncoder
NewBufferEncoder creates a new BufferEncoder using the provided buffer. The buffer should have sufficient capacity for the expected output.
func (*BufferEncoder) EncodeBool ¶ added in v1.2.0
func (e *BufferEncoder) EncodeBool(v bool)
func (*BufferEncoder) EncodeBytes ¶ added in v1.2.0
func (e *BufferEncoder) EncodeBytes(v []byte)
func (*BufferEncoder) EncodeOffset ¶ added in v1.2.0
func (e *BufferEncoder) EncodeOffset(v uint32)
func (*BufferEncoder) EncodeOffsetAt ¶ added in v1.2.0
func (e *BufferEncoder) EncodeOffsetAt(pos int, v uint32)
func (*BufferEncoder) EncodeUint8 ¶ added in v1.2.0
func (e *BufferEncoder) EncodeUint8(v uint8)
func (*BufferEncoder) EncodeUint16 ¶ added in v1.2.0
func (e *BufferEncoder) EncodeUint16(v uint16)
func (*BufferEncoder) EncodeUint32 ¶ added in v1.2.0
func (e *BufferEncoder) EncodeUint32(v uint32)
func (*BufferEncoder) EncodeUint64 ¶ added in v1.2.0
func (e *BufferEncoder) EncodeUint64(v uint64)
func (*BufferEncoder) EncodeZeroPadding ¶ added in v1.2.0
func (e *BufferEncoder) EncodeZeroPadding(n int)
func (*BufferEncoder) GetBuffer ¶ added in v1.2.0
func (e *BufferEncoder) GetBuffer() []byte
func (*BufferEncoder) GetPosition ¶ added in v1.2.0
func (e *BufferEncoder) GetPosition() int
func (*BufferEncoder) Seekable ¶ added in v1.2.0
func (e *BufferEncoder) Seekable() bool
func (*BufferEncoder) SetBuffer ¶ added in v1.2.0
func (e *BufferEncoder) SetBuffer(buffer []byte)
type Decoder ¶ added in v1.2.0
type Decoder interface {
Seekable() bool // can use DecodeOffsetAt() and SkipBytes()
GetPosition() int // return current position
GetLength() int // return remaining length
PushLimit(limit int)
PopLimit() int
DecodeBool() (bool, error)
DecodeUint8() (uint8, error)
DecodeUint16() (uint16, error)
DecodeUint32() (uint32, error)
DecodeUint64() (uint64, error)
DecodeBytes(buf []byte) ([]byte, error)
DecodeBytesBuf(len int) ([]byte, error)
DecodeOffset() (uint32, error)
DecodeOffsetAt(pos int) uint32
SkipBytes(n int)
}
type DynamicDecoder ¶ added in v1.2.0
type DynamicDecoder interface {
UnmarshalSSZDecoder(ds DynamicSpecs, decoder Decoder) error
}
DynamicDecoder is the interface implemented by types that can unmarshal using dynamic SSZ and a decoder
type DynamicEncoder ¶ added in v1.2.0
type DynamicEncoder interface {
MarshalSSZEncoder(ds DynamicSpecs, encoder Encoder) error
}
DynamicEncoder is the interface implemented by types that can marshal themselves using dynamic SSZ and an encoder
type DynamicHashRoot ¶
type DynamicHashRoot interface {
HashTreeRootWithDyn(ds DynamicSpecs, hh HashWalker) error
}
type DynamicMarshaler ¶
type DynamicMarshaler interface {
MarshalSSZDyn(ds DynamicSpecs, buf []byte) ([]byte, error)
}
DynamicMarshaler is the interface implemented by types that can marshal themselves using dynamic SSZ
type DynamicSizer ¶
type DynamicSizer interface {
SizeSSZDyn(ds DynamicSpecs) int
}
DynamicSizer is the interface implemented by types that can calculate their own SSZ size dynamically
type DynamicSpecs ¶ added in v1.1.0
DynamicSsz is the interface for a dynamic SSZ encoder/decoder
type DynamicUnmarshaler ¶
type DynamicUnmarshaler interface {
UnmarshalSSZDyn(ds DynamicSpecs, buf []byte) error
}
DynamicUnmarshaler is the interface implemented by types that can unmarshal using dynamic SSZ
type Encoder ¶ added in v1.2.0
type Encoder interface {
Seekable() bool // can use EncodeOffsetAt()
GetPosition() int
GetBuffer() []byte // return the output buffer (or a temp buffer if Seekable() is false)
SetBuffer(buffer []byte) // set new output buffer (or write the buffer to the stream if Seekable() is false)
EncodeBool(v bool)
EncodeUint8(v uint8)
EncodeUint16(v uint16)
EncodeUint32(v uint32)
EncodeUint64(v uint64)
EncodeBytes(v []byte)
EncodeOffset(v uint32)
EncodeOffsetAt(pos int, v uint32)
EncodeZeroPadding(n int)
}
type FastsszHashRoot ¶
type FastsszMarshaler ¶
type FastsszMarshaler interface {
MarshalSSZTo(dst []byte) ([]byte, error)
MarshalSSZ() ([]byte, error)
SizeSSZ() int
}
FastsszMarshaler is the interface implemented by types that can marshal themselves into valid SZZ using fastssz.
type FastsszUnmarshaler ¶
FastsszUnmarshaler is the interface implemented by types that can unmarshal a SSZ description of themselves
type HashWalker ¶
type HashWalker interface {
// Hash returns the latest hash generated during merkleize
Hash() []byte
// Methods for appending single values
AppendBool(b bool)
AppendUint8(i uint8)
AppendUint16(i uint16)
AppendUint32(i uint32)
AppendUint64(i uint64)
AppendBytes32(b []byte)
// Methods for putting values into the buffer
PutUint64Array(b []uint64, maxCapacity ...uint64)
PutUint64(i uint64)
PutUint32(i uint32)
PutUint16(i uint16)
PutUint8(i uint8)
PutBitlist(bb []byte, maxSize uint64)
PutProgressiveBitlist(bb []byte)
PutBool(b bool)
PutBytes(b []byte)
// Buffer manipulation methods
FillUpTo32()
Append(i []byte)
Index() int
// temporary buffer methods
WithTemp(func(tmp []byte) []byte)
// Merkleization methods
Merkleize(indx int)
MerkleizeWithMixin(indx int, num, limit uint64)
MerkleizeProgressive(indx int)
MerkleizeProgressiveWithMixin(indx int, num uint64)
MerkleizeProgressiveWithActiveFields(indx int, activeFields []byte)
// HashRoot methods
HashRoot() ([32]byte, error)
}
HashWalker is our own interface that mirrors fastssz.HashWalker This allows us to avoid importing fastssz directly while still being compatible with types that implement HashTreeRootWith
type StreamDecoder ¶ added in v1.2.0
type StreamDecoder struct {
// contains filtered or unexported fields
}
func NewStreamDecoder ¶ added in v1.2.0
func NewStreamDecoder(reader io.Reader, totalLen int) *StreamDecoder
func (*StreamDecoder) DecodeBool ¶ added in v1.2.0
func (e *StreamDecoder) DecodeBool() (bool, error)
func (*StreamDecoder) DecodeBytes ¶ added in v1.2.0
func (e *StreamDecoder) DecodeBytes(buf []byte) ([]byte, error)
func (*StreamDecoder) DecodeBytesBuf ¶ added in v1.2.0
func (e *StreamDecoder) DecodeBytesBuf(l int) ([]byte, error)
func (*StreamDecoder) DecodeOffset ¶ added in v1.2.0
func (e *StreamDecoder) DecodeOffset() (uint32, error)
func (*StreamDecoder) DecodeOffsetAt ¶ added in v1.2.0
func (e *StreamDecoder) DecodeOffsetAt(pos int) uint32
func (*StreamDecoder) DecodeUint8 ¶ added in v1.2.0
func (e *StreamDecoder) DecodeUint8() (uint8, error)
func (*StreamDecoder) DecodeUint16 ¶ added in v1.2.0
func (e *StreamDecoder) DecodeUint16() (uint16, error)
func (*StreamDecoder) DecodeUint32 ¶ added in v1.2.0
func (e *StreamDecoder) DecodeUint32() (uint32, error)
func (*StreamDecoder) DecodeUint64 ¶ added in v1.2.0
func (e *StreamDecoder) DecodeUint64() (uint64, error)
func (*StreamDecoder) GetLength ¶ added in v1.2.0
func (e *StreamDecoder) GetLength() int
func (*StreamDecoder) GetPosition ¶ added in v1.2.0
func (e *StreamDecoder) GetPosition() int
func (*StreamDecoder) PopLimit ¶ added in v1.2.0
func (e *StreamDecoder) PopLimit() int
func (*StreamDecoder) PushLimit ¶ added in v1.2.0
func (e *StreamDecoder) PushLimit(limit int)
func (*StreamDecoder) Seekable ¶ added in v1.2.0
func (e *StreamDecoder) Seekable() bool
func (*StreamDecoder) SkipBytes ¶ added in v1.2.0
func (e *StreamDecoder) SkipBytes(n int)
type StreamEncoder ¶ added in v1.2.0
type StreamEncoder struct {
// contains filtered or unexported fields
}
func NewStreamEncoder ¶ added in v1.2.0
func NewStreamEncoder(writer io.Writer) *StreamEncoder
func (*StreamEncoder) EncodeBool ¶ added in v1.2.0
func (e *StreamEncoder) EncodeBool(v bool)
func (*StreamEncoder) EncodeBytes ¶ added in v1.2.0
func (e *StreamEncoder) EncodeBytes(v []byte)
func (*StreamEncoder) EncodeOffset ¶ added in v1.2.0
func (e *StreamEncoder) EncodeOffset(v uint32)
func (*StreamEncoder) EncodeOffsetAt ¶ added in v1.2.0
func (e *StreamEncoder) EncodeOffsetAt(pos int, v uint32)
func (*StreamEncoder) EncodeUint8 ¶ added in v1.2.0
func (e *StreamEncoder) EncodeUint8(v uint8)
func (*StreamEncoder) EncodeUint16 ¶ added in v1.2.0
func (e *StreamEncoder) EncodeUint16(v uint16)
func (*StreamEncoder) EncodeUint32 ¶ added in v1.2.0
func (e *StreamEncoder) EncodeUint32(v uint32)
func (*StreamEncoder) EncodeUint64 ¶ added in v1.2.0
func (e *StreamEncoder) EncodeUint64(v uint64)
func (*StreamEncoder) EncodeZeroPadding ¶ added in v1.2.0
func (e *StreamEncoder) EncodeZeroPadding(n int)
func (*StreamEncoder) GetBuffer ¶ added in v1.2.0
func (e *StreamEncoder) GetBuffer() []byte
func (*StreamEncoder) GetPosition ¶ added in v1.2.0
func (e *StreamEncoder) GetPosition() int
func (*StreamEncoder) GetWriteError ¶ added in v1.2.0
func (e *StreamEncoder) GetWriteError() error
func (*StreamEncoder) Seekable ¶ added in v1.2.0
func (e *StreamEncoder) Seekable() bool
func (*StreamEncoder) SetBuffer ¶ added in v1.2.0
func (e *StreamEncoder) SetBuffer(buffer []byte)