Documentation
¶
Overview ¶
Package ssz is a simplified SSZ encoder/decoder.
Index ¶
- Variables
- func DecodeArrayOfBits[T commonBitsLengths](dec *Decoder, bits *T, size uint64)
- func DecodeArrayOfBitsPointerOnFork[T commonBitsLengths](dec *Decoder, bits **T, size uint64, filter ForkFilter)
- func DecodeArrayOfStaticBytes[T commonBytesArrayLengths[U], U commonBytesLengths](dec *Decoder, blobs *T)
- func DecodeArrayOfUint64s[T commonUint64sLengths](dec *Decoder, ns *T)
- func DecodeArrayOfUint64sPointerOnFork[T commonUint64sLengths](dec *Decoder, ns **T, filter ForkFilter)
- func DecodeBool[T ~bool](dec *Decoder, v *T)
- func DecodeBoolPointerOnFork[T ~bool](dec *Decoder, v **T, filter ForkFilter)
- func DecodeCheckedArrayOfStaticBytes[T commonBytesLengths](dec *Decoder, blobs *[]T, size uint64)
- func DecodeCheckedStaticBytes(dec *Decoder, blob *[]byte, size uint64)
- func DecodeDynamicBytesContent(dec *Decoder, blob *[]byte, maxSize uint64)
- func DecodeDynamicBytesContentOnFork(dec *Decoder, blob *[]byte, maxSize uint64, filter ForkFilter)
- func DecodeDynamicBytesOffset(dec *Decoder, blob *[]byte)
- func DecodeDynamicBytesOffsetOnFork(dec *Decoder, blob *[]byte, filter ForkFilter)
- func DecodeDynamicObjectContent[T newableDynamicObject[U], U any](dec *Decoder, obj *T)
- func DecodeDynamicObjectContentOnFork[T newableDynamicObject[U], U any](dec *Decoder, obj *T, filter ForkFilter)
- func DecodeDynamicObjectOffset[T newableDynamicObject[U], U any](dec *Decoder, obj *T)
- func DecodeDynamicObjectOffsetOnFork[T newableDynamicObject[U], U any](dec *Decoder, obj *T, filter ForkFilter)
- func DecodeFromBytes(blob []byte, obj Object) error
- func DecodeFromBytesOnFork(blob []byte, obj Object, fork Fork) error
- func DecodeFromStream(r io.Reader, obj Object, size uint32) error
- func DecodeFromStreamOnFork(r io.Reader, obj Object, size uint32, fork Fork) error
- func DecodeSliceOfBitsContent(dec *Decoder, bitlist *bitfield.Bitlist, maxBits uint64)
- func DecodeSliceOfBitsContentOnFork(dec *Decoder, bitlist *bitfield.Bitlist, maxBits uint64, filter ForkFilter)
- func DecodeSliceOfBitsOffset(dec *Decoder, bitlist *bitfield.Bitlist)
- func DecodeSliceOfBitsOffsetOnFork(dec *Decoder, bitlist *bitfield.Bitlist, filter ForkFilter)
- func DecodeSliceOfDynamicBytesContent(dec *Decoder, blobs *[][]byte, maxItems uint64, maxSize uint64)
- func DecodeSliceOfDynamicBytesContentOnFork(dec *Decoder, blobs *[][]byte, maxItems uint64, maxSize uint64, ...)
- func DecodeSliceOfDynamicBytesOffset(dec *Decoder, blobs *[][]byte)
- func DecodeSliceOfDynamicBytesOffsetOnFork(dec *Decoder, blobs *[][]byte, filter ForkFilter)
- func DecodeSliceOfDynamicObjectsContent[T newableDynamicObject[U], U any](dec *Decoder, objects *[]T, maxItems uint64)
- func DecodeSliceOfDynamicObjectsContentOnFork[T newableDynamicObject[U], U any](dec *Decoder, objects *[]T, maxItems uint64, filter ForkFilter)
- func DecodeSliceOfDynamicObjectsOffset[T newableDynamicObject[U], U any](dec *Decoder, objects *[]T)
- func DecodeSliceOfDynamicObjectsOffsetOnFork[T newableDynamicObject[U], U any](dec *Decoder, objects *[]T, filter ForkFilter)
- func DecodeSliceOfStaticBytesContent[T commonBytesLengths](dec *Decoder, blobs *[]T, maxItems uint64)
- func DecodeSliceOfStaticBytesContentOnFork[T commonBytesLengths](dec *Decoder, blobs *[]T, maxItems uint64, filter ForkFilter)
- func DecodeSliceOfStaticBytesOffset[T commonBytesLengths](dec *Decoder, blobs *[]T)
- func DecodeSliceOfStaticBytesOffsetOnFork[T commonBytesLengths](dec *Decoder, blobs *[]T, filter ForkFilter)
- func DecodeSliceOfStaticObjectsContent[T newableStaticObject[U], U any](dec *Decoder, objects *[]T, maxItems uint64)
- func DecodeSliceOfStaticObjectsContentOnFork[T newableStaticObject[U], U any](dec *Decoder, objects *[]T, maxItems uint64, filter ForkFilter)
- func DecodeSliceOfStaticObjectsOffset[T newableStaticObject[U], U any](dec *Decoder, objects *[]T)
- func DecodeSliceOfStaticObjectsOffsetOnFork[T newableStaticObject[U], U any](dec *Decoder, objects *[]T, filter ForkFilter)
- func DecodeSliceOfUint64sContent[T ~uint64](dec *Decoder, ns *[]T, maxItems uint64)
- func DecodeSliceOfUint64sContentOnFork[T ~uint64](dec *Decoder, ns *[]T, maxItems uint64, filter ForkFilter)
- func DecodeSliceOfUint64sOffset[T ~uint64](dec *Decoder, ns *[]T)
- func DecodeSliceOfUint64sOffsetOnFork[T ~uint64](dec *Decoder, ns *[]T, filter ForkFilter)
- func DecodeStaticBytes[T commonBytesLengths](dec *Decoder, blob *T)
- func DecodeStaticBytesPointerOnFork[T commonBytesLengths](dec *Decoder, blob **T, filter ForkFilter)
- func DecodeStaticObject[T newableStaticObject[U], U any](dec *Decoder, obj *T)
- func DecodeStaticObjectOnFork[T newableStaticObject[U], U any](dec *Decoder, obj *T, filter ForkFilter)
- func DecodeUint16[T ~uint16](dec *Decoder, n *T)
- func DecodeUint16PointerOnFork[T ~uint16](dec *Decoder, n **T, filter ForkFilter)
- func DecodeUint256(dec *Decoder, n **uint256.Int)
- func DecodeUint256BigInt(dec *Decoder, n **big.Int)
- func DecodeUint256BigIntOnFork(dec *Decoder, n **big.Int, filter ForkFilter)
- func DecodeUint256OnFork(dec *Decoder, n **uint256.Int, filter ForkFilter)
- func DecodeUint32[T ~uint32](dec *Decoder, n *T)
- func DecodeUint32PointerOnFork[T ~uint32](dec *Decoder, n **T, filter ForkFilter)
- func DecodeUint64[T ~uint64](dec *Decoder, n *T)
- func DecodeUint64PointerOnFork[T ~uint64](dec *Decoder, n **T, filter ForkFilter)
- func DecodeUint8[T ~uint8](dec *Decoder, n *T)
- func DecodeUint8PointerOnFork[T ~uint8](dec *Decoder, n **T, filter ForkFilter)
- func DecodeUnsafeArrayOfStaticBytes[T commonBytesLengths](dec *Decoder, blobs []T)
- func DefineArrayOfBits[T commonBitsLengths](c *Codec, bits *T, size uint64)
- func DefineArrayOfBitsPointerOnFork[T commonBitsLengths](c *Codec, bits **T, size uint64, filter ForkFilter)
- func DefineArrayOfStaticBytes[T commonBytesArrayLengths[U], U commonBytesLengths](c *Codec, blobs *T)
- func DefineArrayOfUint64s[T commonUint64sLengths](c *Codec, ns *T)
- func DefineArrayOfUint64sPointerOnFork[T commonUint64sLengths](c *Codec, ns **T, filter ForkFilter)
- func DefineBool[T ~bool](c *Codec, v *T)
- func DefineBoolPointerOnFork[T ~bool](c *Codec, v **T, filter ForkFilter)
- func DefineCheckedArrayOfStaticBytes[T commonBytesLengths](c *Codec, blobs *[]T, size uint64)
- func DefineCheckedStaticBytes(c *Codec, blob *[]byte, size uint64)
- func DefineDynamicBytesContent(c *Codec, blob *[]byte, maxSize uint64)
- func DefineDynamicBytesContentOnFork(c *Codec, blob *[]byte, maxSize uint64, filter ForkFilter)
- func DefineDynamicBytesOffset(c *Codec, blob *[]byte, maxSize uint64)
- func DefineDynamicBytesOffsetOnFork(c *Codec, blob *[]byte, maxSize uint64, filter ForkFilter)
- func DefineDynamicObjectContent[T newableDynamicObject[U], U any](c *Codec, obj *T)
- func DefineDynamicObjectContentOnFork[T newableDynamicObject[U], U any](c *Codec, obj *T, filter ForkFilter)
- func DefineDynamicObjectOffset[T newableDynamicObject[U], U any](c *Codec, obj *T)
- func DefineDynamicObjectOffsetOnFork[T newableDynamicObject[U], U any](c *Codec, obj *T, filter ForkFilter)
- func DefineSliceOfBitsContent(c *Codec, bits *bitfield.Bitlist, maxBits uint64)
- func DefineSliceOfBitsContentOnFork(c *Codec, bits *bitfield.Bitlist, maxBits uint64, filter ForkFilter)
- func DefineSliceOfBitsOffset(c *Codec, bits *bitfield.Bitlist, maxBits uint64)
- func DefineSliceOfBitsOffsetOnFork(c *Codec, bits *bitfield.Bitlist, maxBits uint64, filter ForkFilter)
- func DefineSliceOfDynamicBytesContent(c *Codec, blobs *[][]byte, maxItems uint64, maxSize uint64)
- func DefineSliceOfDynamicBytesContentOnFork(c *Codec, blobs *[][]byte, maxItems uint64, maxSize uint64, filter ForkFilter)
- func DefineSliceOfDynamicBytesOffset(c *Codec, blobs *[][]byte, maxItems uint64, maxSize uint64)
- func DefineSliceOfDynamicBytesOffsetOnFork(c *Codec, blobs *[][]byte, maxItems uint64, maxSize uint64, filter ForkFilter)
- func DefineSliceOfDynamicObjectsContent[T newableDynamicObject[U], U any](c *Codec, objects *[]T, maxItems uint64)
- func DefineSliceOfDynamicObjectsContentOnFork[T newableDynamicObject[U], U any](c *Codec, objects *[]T, maxItems uint64, filter ForkFilter)
- func DefineSliceOfDynamicObjectsOffset[T newableDynamicObject[U], U any](c *Codec, objects *[]T, maxItems uint64)
- func DefineSliceOfDynamicObjectsOffsetOnFork[T newableDynamicObject[U], U any](c *Codec, objects *[]T, maxItems uint64, filter ForkFilter)
- func DefineSliceOfStaticBytesContent[T commonBytesLengths](c *Codec, blobs *[]T, maxItems uint64)
- func DefineSliceOfStaticBytesContentOnFork[T commonBytesLengths](c *Codec, blobs *[]T, maxItems uint64, filter ForkFilter)
- func DefineSliceOfStaticBytesOffset[T commonBytesLengths](c *Codec, bytes *[]T, maxItems uint64)
- func DefineSliceOfStaticBytesOffsetOnFork[T commonBytesLengths](c *Codec, bytes *[]T, maxItems uint64, filter ForkFilter)
- func DefineSliceOfStaticObjectsContent[T newableStaticObject[U], U any](c *Codec, objects *[]T, maxItems uint64)
- func DefineSliceOfStaticObjectsContentOnFork[T newableStaticObject[U], U any](c *Codec, objects *[]T, maxItems uint64, filter ForkFilter)
- func DefineSliceOfStaticObjectsOffset[T newableStaticObject[U], U any](c *Codec, objects *[]T, maxItems uint64)
- func DefineSliceOfStaticObjectsOffsetOnFork[T newableStaticObject[U], U any](c *Codec, objects *[]T, maxItems uint64, filter ForkFilter)
- func DefineSliceOfUint64sContent[T ~uint64](c *Codec, ns *[]T, maxItems uint64)
- func DefineSliceOfUint64sContentOnFork[T ~uint64](c *Codec, ns *[]T, maxItems uint64, filter ForkFilter)
- func DefineSliceOfUint64sOffset[T ~uint64](c *Codec, ns *[]T, maxItems uint64)
- func DefineSliceOfUint64sOffsetOnFork[T ~uint64](c *Codec, ns *[]T, maxItems uint64, filter ForkFilter)
- func DefineStaticBytes[T commonBytesLengths](c *Codec, blob *T)
- func DefineStaticBytesPointerOnFork[T commonBytesLengths](c *Codec, blob **T, filter ForkFilter)
- func DefineStaticObject[T newableStaticObject[U], U any](c *Codec, obj *T)
- func DefineStaticObjectOnFork[T newableStaticObject[U], U any](c *Codec, obj *T, filter ForkFilter)
- func DefineUint16[T ~uint16](c *Codec, n *T)
- func DefineUint16PointerOnFork[T ~uint16](c *Codec, n **T, filter ForkFilter)
- func DefineUint256(c *Codec, n **uint256.Int)
- func DefineUint256BigInt(c *Codec, n **big.Int)
- func DefineUint256BigIntOnFork(c *Codec, n **big.Int, filter ForkFilter)
- func DefineUint256OnFork(c *Codec, n **uint256.Int, filter ForkFilter)
- func DefineUint32[T ~uint32](c *Codec, n *T)
- func DefineUint32PointerOnFork[T ~uint32](c *Codec, n **T, filter ForkFilter)
- func DefineUint64[T ~uint64](c *Codec, n *T)
- func DefineUint64PointerOnFork[T ~uint64](c *Codec, n **T, filter ForkFilter)
- func DefineUint8[T ~uint8](c *Codec, n *T)
- func DefineUint8PointerOnFork[T ~uint8](c *Codec, n **T, filter ForkFilter)
- func DefineUnsafeArrayOfStaticBytes[T commonBytesLengths](c *Codec, blobs []T)
- func EncodeArrayOfBits[T commonBitsLengths](enc *Encoder, bits *T)
- func EncodeArrayOfBitsPointerOnFork[T commonBitsLengths](enc *Encoder, bits *T, filter ForkFilter)
- func EncodeArrayOfStaticBytes[T commonBytesArrayLengths[U], U commonBytesLengths](enc *Encoder, blobs *T)
- func EncodeArrayOfUint64s[T commonUint64sLengths](enc *Encoder, ns *T)
- func EncodeArrayOfUint64sPointerOnFork[T commonUint64sLengths](enc *Encoder, ns *T, filter ForkFilter)
- func EncodeBool[T ~bool](enc *Encoder, v T)
- func EncodeBoolPointerOnFork[T ~bool](enc *Encoder, v *T, filter ForkFilter)
- func EncodeCheckedArrayOfStaticBytes[T commonBytesLengths](enc *Encoder, blobs []T, size uint64)
- func EncodeCheckedStaticBytes(enc *Encoder, blob []byte, size uint64)
- func EncodeDynamicBytesContent(enc *Encoder, blob []byte)
- func EncodeDynamicBytesContentOnFork(enc *Encoder, blob []byte, filter ForkFilter)
- func EncodeDynamicBytesOffset(enc *Encoder, blob []byte)
- func EncodeDynamicBytesOffsetOnFork(enc *Encoder, blob []byte, filter ForkFilter)
- func EncodeDynamicObjectContent[T newableDynamicObject[U], U any](enc *Encoder, obj T)
- func EncodeDynamicObjectContentOnFork[T newableDynamicObject[U], U any](enc *Encoder, obj T, filter ForkFilter)
- func EncodeDynamicObjectOffset[T newableDynamicObject[U], U any](enc *Encoder, obj T)
- func EncodeDynamicObjectOffsetOnFork[T newableDynamicObject[U], U any](enc *Encoder, obj T, filter ForkFilter)
- func EncodeSliceOfBitsContent(enc *Encoder, bits bitfield.Bitlist)
- func EncodeSliceOfBitsContentOnFork(enc *Encoder, bits bitfield.Bitlist, filter ForkFilter)
- func EncodeSliceOfBitsOffset(enc *Encoder, bits bitfield.Bitlist)
- func EncodeSliceOfBitsOffsetOnFork(enc *Encoder, bits bitfield.Bitlist, filter ForkFilter)
- func EncodeSliceOfDynamicBytesContent(enc *Encoder, blobs [][]byte)
- func EncodeSliceOfDynamicBytesContentOnFork(enc *Encoder, blobs [][]byte, filter ForkFilter)
- func EncodeSliceOfDynamicBytesOffset(enc *Encoder, blobs [][]byte)
- func EncodeSliceOfDynamicBytesOffsetOnFork(enc *Encoder, blobs [][]byte, filter ForkFilter)
- func EncodeSliceOfDynamicObjectsContent[T DynamicObject](enc *Encoder, objects []T)
- func EncodeSliceOfDynamicObjectsContentOnFork[T DynamicObject](enc *Encoder, objects []T, filter ForkFilter)
- func EncodeSliceOfDynamicObjectsOffset[T DynamicObject](enc *Encoder, objects []T)
- func EncodeSliceOfDynamicObjectsOffsetOnFork[T DynamicObject](enc *Encoder, objects []T, filter ForkFilter)
- func EncodeSliceOfStaticBytesContent[T commonBytesLengths](enc *Encoder, blobs []T)
- func EncodeSliceOfStaticBytesContentOnFork[T commonBytesLengths](enc *Encoder, blobs []T, filter ForkFilter)
- func EncodeSliceOfStaticBytesOffset[T commonBytesLengths](enc *Encoder, blobs []T)
- func EncodeSliceOfStaticBytesOffsetOnFork[T commonBytesLengths](enc *Encoder, blobs []T, filter ForkFilter)
- func EncodeSliceOfStaticObjectsContent[T StaticObject](enc *Encoder, objects []T)
- func EncodeSliceOfStaticObjectsContentOnFork[T StaticObject](enc *Encoder, objects []T, filter ForkFilter)
- func EncodeSliceOfStaticObjectsOffset[T StaticObject](enc *Encoder, objects []T)
- func EncodeSliceOfStaticObjectsOffsetOnFork[T StaticObject](enc *Encoder, objects []T, filter ForkFilter)
- func EncodeSliceOfUint64sContent[T ~uint64](enc *Encoder, ns []T)
- func EncodeSliceOfUint64sContentOnFork[T ~uint64](enc *Encoder, ns []T, filter ForkFilter)
- func EncodeSliceOfUint64sOffset[T ~uint64](enc *Encoder, ns []T)
- func EncodeSliceOfUint64sOffsetOnFork[T ~uint64](enc *Encoder, ns []T, filter ForkFilter)
- func EncodeStaticBytes[T commonBytesLengths](enc *Encoder, blob *T)
- func EncodeStaticBytesPointerOnFork[T commonBytesLengths](enc *Encoder, blob *T, filter ForkFilter)
- func EncodeStaticObject[T newableStaticObject[U], U any](enc *Encoder, obj T)
- func EncodeStaticObjectOnFork[T newableStaticObject[U], U any](enc *Encoder, obj T, filter ForkFilter)
- func EncodeToBytes(buf []byte, obj Object) error
- func EncodeToBytesOnFork(buf []byte, obj Object, fork Fork) error
- func EncodeToStream(w io.Writer, obj Object) error
- func EncodeToStreamOnFork(w io.Writer, obj Object, fork Fork) error
- func EncodeUint16[T ~uint16](enc *Encoder, n T)
- func EncodeUint16PointerOnFork[T ~uint16](enc *Encoder, n *T, filter ForkFilter)
- func EncodeUint256(enc *Encoder, n *uint256.Int)
- func EncodeUint256BigInt(enc *Encoder, n *big.Int)
- func EncodeUint256BigIntOnFork(enc *Encoder, n *big.Int, filter ForkFilter)
- func EncodeUint256OnFork(enc *Encoder, n *uint256.Int, filter ForkFilter)
- func EncodeUint32[T ~uint32](enc *Encoder, n T)
- func EncodeUint32PointerOnFork[T ~uint32](enc *Encoder, n *T, filter ForkFilter)
- func EncodeUint64[T ~uint64](enc *Encoder, n T)
- func EncodeUint64PointerOnFork[T ~uint64](enc *Encoder, n *T, filter ForkFilter)
- func EncodeUint8[T ~uint8](enc *Encoder, n T)
- func EncodeUint8PointerOnFork[T ~uint8](enc *Encoder, n *T, filter ForkFilter)
- func EncodeUnsafeArrayOfStaticBytes[T commonBytesLengths](enc *Encoder, blobs []T)
- func HashArrayOfBits[T commonBitsLengths](h *Hasher, bits *T)
- func HashArrayOfBitsPointerOnFork[T commonBitsLengths](h *Hasher, bits *T, filter ForkFilter)
- func HashArrayOfStaticBytes[T commonBytesArrayLengths[U], U commonBytesLengths](h *Hasher, blobs *T)
- func HashArrayOfUint64s[T commonUint64sLengths](h *Hasher, ns *T)
- func HashArrayOfUint64sPointerOnFork[T commonUint64sLengths](h *Hasher, ns *T, filter ForkFilter)
- func HashBool[T ~bool](h *Hasher, v T)
- func HashBoolPointerOnFork[T ~bool](h *Hasher, v *T, filter ForkFilter)
- func HashCheckedArrayOfStaticBytes[T commonBytesLengths](h *Hasher, blobs []T)
- func HashCheckedStaticBytes(h *Hasher, blob []byte)
- func HashConcurrent(obj Object) [32]byte
- func HashConcurrentOnFork(obj Object, fork Fork) [32]byte
- func HashDynamicBytes(h *Hasher, blob []byte, maxSize uint64)
- func HashDynamicBytesOnFork(h *Hasher, blob []byte, maxSize uint64, filter ForkFilter)
- func HashDynamicObject[T newableDynamicObject[U], U any](h *Hasher, obj T)
- func HashDynamicObjectOnFork[T newableDynamicObject[U], U any](h *Hasher, obj T, filter ForkFilter)
- func HashSequential(obj Object) [32]byte
- func HashSequentialOnFork(obj Object, fork Fork) [32]byte
- func HashSliceOfBits(h *Hasher, bits bitfield.Bitlist, maxBits uint64)
- func HashSliceOfBitsOnFork(h *Hasher, bits bitfield.Bitlist, maxBits uint64, filter ForkFilter)
- func HashSliceOfDynamicBytes(h *Hasher, blobs [][]byte, maxItems uint64, maxSize uint64)
- func HashSliceOfDynamicBytesOnFork(h *Hasher, blobs [][]byte, maxItems uint64, maxSize uint64, filter ForkFilter)
- func HashSliceOfDynamicObjects[T DynamicObject](h *Hasher, objects []T, maxItems uint64)
- func HashSliceOfDynamicObjectsOnFork[T DynamicObject](h *Hasher, objects []T, maxItems uint64, filter ForkFilter)
- func HashSliceOfStaticBytes[T commonBytesLengths](h *Hasher, blobs []T, maxItems uint64)
- func HashSliceOfStaticBytesOnFork[T commonBytesLengths](h *Hasher, blobs []T, maxItems uint64, filter ForkFilter)
- func HashSliceOfStaticObjects[T StaticObject](h *Hasher, objects []T, maxItems uint64)
- func HashSliceOfStaticObjectsOnFork[T StaticObject](h *Hasher, objects []T, maxItems uint64, filter ForkFilter)
- func HashSliceOfUint64s[T ~uint64](h *Hasher, ns []T, maxItems uint64)
- func HashSliceOfUint64sOnFork[T ~uint64](h *Hasher, ns []T, maxItems uint64, filter ForkFilter)
- func HashStaticBytes[T commonBytesLengths](h *Hasher, blob *T)
- func HashStaticBytesPointerOnFork[T commonBytesLengths](h *Hasher, blob *T, filter ForkFilter)
- func HashStaticObject[T newableStaticObject[U], U any](h *Hasher, obj T)
- func HashStaticObjectOnFork[T newableStaticObject[U], U any](h *Hasher, obj T, filter ForkFilter)
- func HashUint16[T ~uint16](h *Hasher, n T)
- func HashUint16PointerOnFork[T ~uint16](h *Hasher, n *T, filter ForkFilter)
- func HashUint256(h *Hasher, n *uint256.Int)
- func HashUint256BigInt(h *Hasher, n *big.Int)
- func HashUint256BigIntOnFork(h *Hasher, n *big.Int, filter ForkFilter)
- func HashUint256OnFork(h *Hasher, n *uint256.Int, filter ForkFilter)
- func HashUint32[T ~uint32](h *Hasher, n T)
- func HashUint32PointerOnFork[T ~uint32](h *Hasher, n *T, filter ForkFilter)
- func HashUint64[T ~uint64](h *Hasher, n T)
- func HashUint64PointerOnFork[T ~uint64](h *Hasher, n *T, filter ForkFilter)
- func HashUint8[T ~uint8](h *Hasher, n T)
- func HashUint8PointerOnFork[T ~uint8](h *Hasher, n *T, filter ForkFilter)
- func HashUnsafeArrayOfStaticBytes[T commonBytesLengths](h *Hasher, blobs []T)
- func PrecomputeStaticSizeCache(obj Object) []uint32
- func Size(obj Object) uint32
- func SizeDynamicBytes(siz *Sizer, blobs []byte) uint32
- func SizeDynamicObject[T newableDynamicObject[U], U any](siz *Sizer, obj T) uint32
- func SizeOnFork(obj Object, fork Fork) uint32
- func SizeSliceOfBits(siz *Sizer, bits bitfield.Bitlist) uint32
- func SizeSliceOfDynamicBytes(siz *Sizer, blobs [][]byte) uint32
- func SizeSliceOfDynamicObjects[T DynamicObject](siz *Sizer, objects []T) uint32
- func SizeSliceOfStaticBytes[T commonBytesLengths](siz *Sizer, blobs []T) uint32
- func SizeSliceOfStaticObjects[T StaticObject](siz *Sizer, objects []T) uint32
- func SizeSliceOfUint64s[T ~uint64](siz *Sizer, ns []T) uint32
- type Codec
- type Decoder
- type DynamicObject
- type Encoder
- type Fork
- type ForkFilter
- type Hasher
- type Object
- type Sizer
- type StaticObject
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ErrBadCounterOffset = errors.New("ssz: counter offset not multiple of 4-bytes")
ErrBadCounterOffset is returned when a list of offsets are consumed and the first offset is not a multiple of 4-bytes.
var ErrBadOffsetProgression = errors.New("ssz: offset smaller than previous")
ErrBadOffsetProgression is returned when an offset is parsed, and is smaller than a previously seen offset (meaning negative dynamic data size).
var ErrBufferTooSmall = errors.New("ssz: output buffer too small")
ErrBufferTooSmall is returned from encoding if the provided output byte buffer is too small to hold the encoding of the object.
var ErrDynamicStaticsIndivisible = errors.New("ssz: list of fixed objects not divisible")
ErrDynamicStaticsIndivisible is returned when a list of static objects is to be decoded, but the list's total length is not divisible by the item size.
var ErrFirstOffsetMismatch = errors.New("ssz: first offset mismatch")
ErrFirstOffsetMismatch is returned when parsing dynamic types and the first offset (which is supposed to signal the start of the dynamic area) does not match with the computed fixed area size.
var ErrInvalidBoolean = errors.New("ssz: invalid boolean")
ErrInvalidBoolean is returned from decoding if a boolean slot contains some other byte than 0x00 or 0x01.
var ErrJunkInBitlist = errors.New("ssz: junk in bitlist unused bits")
ErrJunkInBitlist is returned from decoding if the high (unused) bits of a bitlist contains junk, instead of being all 0.
var ErrJunkInBitvector = errors.New("ssz: junk in bitvector unused bits")
ErrJunkInBitvector is returned from decoding if the high (unused) bits of a bitvector contains junk, instead of being all 0.
var ErrMaxItemsExceeded = errors.New("ssz: maximum item count exceeded")
ErrMaxItemsExceeded is returned when the number of items in a dynamic list type is later than permitted.
var ErrMaxLengthExceeded = errors.New("ssz: maximum item size exceeded")
ErrMaxLengthExceeded is returned when the size calculated for a dynamic type is larger than permitted.
var ErrObjectSlotSizeMismatch = errors.New("ssz: object didn't consume all designated data")
ErrObjectSlotSizeMismatch is returned from decoding if an object's slot in the ssz stream contains more data than the object cares to consume.
var ErrOffsetBeyondCapacity = errors.New("ssz: offset beyond capacity")
ErrOffsetBeyondCapacity is returned when an offset is parsed, and is larger than the total capacity allowed by the decoder (i.e. message size)
var ErrShortCounterOffset = errors.New("ssz: insufficient data for 4-byte counter offset")
ErrShortCounterOffset is returned if a counter offset it attempted to be read but there are fewer bytes available on the stream.
var ErrZeroCounterOffset = errors.New("ssz: counter offset zero")
ErrZeroCounterOffset is returned when a list of offsets are consumed and the first offset is zero, which means the list should not have existed.
var ForkMapping = map[string]Fork{ "unknown": ForkUnknown, "frontier": ForkFrontier, "homestead": ForkHomestead, "dao": ForkDAO, "tangerine": ForkTangerine, "spurious": ForkSpurious, "byzantium": ForkByzantium, "constantinople": ForkConstantinople, "istanbul": ForkIstanbul, "muir": ForkMuir, "phase0": ForkPhase0, "berlin": ForkBerlin, "london": ForkLondon, "altair": ForkAltair, "arrow": ForkArrow, "gray": ForkGray, "bellatrix": ForkBellatrix, "paris": ForkParis, "merge": ForkMerge, "shapella": ForkShapella, "shanghai": ForkShanghai, "capella": ForkCapella, "dencun": ForkDencun, "cancun": ForkCancun, "deneb": ForkDeneb, "pectra": ForkPectra, "prague": ForkPrague, "electra": ForkElectra, "future": ForkFuture, }
ForkMapping maps fork names to fork values. This is used internally by the ssz codec generator to convert tags to values.
Functions ¶
func DecodeArrayOfBits ¶
DecodeArrayOfBits parses a static array of (packed) bits.
func DecodeArrayOfBitsPointerOnFork ¶ added in v0.3.0
func DecodeArrayOfBitsPointerOnFork[T commonBitsLengths](dec *Decoder, bits **T, size uint64, filter ForkFilter)
DecodeArrayOfBitsPointerOnFork parses a static array of (packed) bits if present in a fork. If not, the bit array pointer is set to nil.
func DecodeArrayOfStaticBytes ¶
func DecodeArrayOfStaticBytes[T commonBytesArrayLengths[U], U commonBytesLengths](dec *Decoder, blobs *T)
DecodeArrayOfStaticBytes parses a static array of static binary blobs.
func DecodeArrayOfUint64s ¶
func DecodeArrayOfUint64s[T commonUint64sLengths](dec *Decoder, ns *T)
DecodeArrayOfUint64s parses a static array of uint64s.
func DecodeArrayOfUint64sPointerOnFork ¶ added in v0.3.0
func DecodeArrayOfUint64sPointerOnFork[T commonUint64sLengths](dec *Decoder, ns **T, filter ForkFilter)
DecodeArrayOfUint64sPointerOnFork parses a static array of uint64s if present in a fork. If not, the bit array pointer is set to nil.
func DecodeBoolPointerOnFork ¶ added in v0.3.0
func DecodeBoolPointerOnFork[T ~bool](dec *Decoder, v **T, filter ForkFilter)
DecodeBoolPointerOnFork parses a boolean if present in a fork. If not, the boolean pointer is set to nil.
This method is similar to DecodeBool, but will also initialize the pointer if it is not allocated yet.
func DecodeCheckedArrayOfStaticBytes ¶
DecodeCheckedArrayOfStaticBytes parses a static array of static binary blobs.
func DecodeCheckedStaticBytes ¶
DecodeCheckedStaticBytes parses a static binary blob.
func DecodeDynamicBytesContent ¶
DecodeDynamicBytesContent is the lazy data reader of DecodeDynamicBytesOffset.
func DecodeDynamicBytesContentOnFork ¶ added in v0.3.0
func DecodeDynamicBytesContentOnFork(dec *Decoder, blob *[]byte, maxSize uint64, filter ForkFilter)
DecodeDynamicBytesContentOnFork is the lazy data reader of DecodeDynamicBytesOffsetOnFork.
func DecodeDynamicBytesOffset ¶
DecodeDynamicBytesOffset parses the offset of a dynamic binary blob.
func DecodeDynamicBytesOffsetOnFork ¶ added in v0.3.0
func DecodeDynamicBytesOffsetOnFork(dec *Decoder, blob *[]byte, filter ForkFilter)
DecodeDynamicBytesOffsetOnFork parses the offset of dynamic binary blob if present in a fork.
func DecodeDynamicObjectContent ¶
DecodeDynamicObjectContent is the lazy data reader of DecodeDynamicObjectOffset.
func DecodeDynamicObjectContentOnFork ¶ added in v0.3.0
func DecodeDynamicObjectContentOnFork[T newableDynamicObject[U], U any](dec *Decoder, obj *T, filter ForkFilter)
DecodeDynamicObjectContentOnFork is the lazy data reader of DecodeDynamicObjectOffsetOnFork.
func DecodeDynamicObjectOffset ¶
DecodeDynamicObjectOffset parses a dynamic ssz object.
func DecodeDynamicObjectOffsetOnFork ¶ added in v0.3.0
func DecodeDynamicObjectOffsetOnFork[T newableDynamicObject[U], U any](dec *Decoder, obj *T, filter ForkFilter)
DecodeDynamicObjectOffsetOnFork parses a dynamic ssz object if present in a fork.
func DecodeFromBytes ¶
DecodeFromBytes parses a non-monolithic object from a byte buffer. If the type contains fork-specific rules, use DecodeFromBytesOnFork.
Do not use this method if you want to first read the buffer from a stream via some reader, as that would double the memory use for the temporary buffer. For that use case, use DecodeFromStream instead.
func DecodeFromBytesOnFork ¶ added in v0.3.0
DecodeFromBytesOnFork parses a monolithic object from a byte buffer. If the type does not contain fork-specific rules, you can also use DecodeFromBytes.
Do not use this method if you want to first read the buffer from a stream via some reader, as that would double the memory use for the temporary buffer. For that use case, use DecodeFromStreamOnFork instead.
func DecodeFromStream ¶
DecodeFromStream parses a non-monolithic object with the given size out of a stream. If the type contains fork-specific rules, use DecodeFromStreamOnFork.
Do not use this method with a bytes.Buffer to read from a []byte slice, as that will double the byte copying. For that use case, use DecodeFromBytes.
func DecodeFromStreamOnFork ¶ added in v0.3.0
DecodeFromStreamOnFork parses a monolithic object with the given size out of a stream. If the type does not contain fork-specific rules, you can also use DecodeFromStream.
Do not use this method with a bytes.Buffer to read from a []byte slice, as that will double the byte copying. For that use case, use DecodeFromBytesOnFork.
func DecodeSliceOfBitsContent ¶
DecodeSliceOfBitsContent is the lazy data reader of DecodeSliceOfBitsOffset.
func DecodeSliceOfBitsContentOnFork ¶ added in v0.3.0
func DecodeSliceOfBitsContentOnFork(dec *Decoder, bitlist *bitfield.Bitlist, maxBits uint64, filter ForkFilter)
DecodeSliceOfBitsContentOnFork is the lazy data reader of DecodeSliceOfBitsOffsetOnFork.
func DecodeSliceOfBitsOffset ¶
DecodeSliceOfBitsOffset parses a dynamic slice of (packed) bits.
func DecodeSliceOfBitsOffsetOnFork ¶ added in v0.3.0
func DecodeSliceOfBitsOffsetOnFork(dec *Decoder, bitlist *bitfield.Bitlist, filter ForkFilter)
DecodeSliceOfBitsOffsetOnFork parses a dynamic slice of (packed) bits if present in a fork.
func DecodeSliceOfDynamicBytesContent ¶
func DecodeSliceOfDynamicBytesContent(dec *Decoder, blobs *[][]byte, maxItems uint64, maxSize uint64)
DecodeSliceOfDynamicBytesContent is the lazy data reader of DecodeSliceOfDynamicBytesOffset.
func DecodeSliceOfDynamicBytesContentOnFork ¶ added in v0.3.0
func DecodeSliceOfDynamicBytesContentOnFork(dec *Decoder, blobs *[][]byte, maxItems uint64, maxSize uint64, filter ForkFilter)
DecodeSliceOfDynamicBytesContentOnFork is the lazy data reader of DecodeSliceOfDynamicBytesOffsetOnFork.
func DecodeSliceOfDynamicBytesOffset ¶
DecodeSliceOfDynamicBytesOffset parses a dynamic slice of dynamic binary blobs.
func DecodeSliceOfDynamicBytesOffsetOnFork ¶ added in v0.3.0
func DecodeSliceOfDynamicBytesOffsetOnFork(dec *Decoder, blobs *[][]byte, filter ForkFilter)
DecodeSliceOfDynamicBytesOffsetOnFork parses a dynamic slice of dynamic binary blobs if present in a fork.
func DecodeSliceOfDynamicObjectsContent ¶
func DecodeSliceOfDynamicObjectsContent[T newableDynamicObject[U], U any](dec *Decoder, objects *[]T, maxItems uint64)
DecodeSliceOfDynamicObjectsContent is the lazy data reader of DecodeSliceOfDynamicObjectsOffset.
func DecodeSliceOfDynamicObjectsContentOnFork ¶ added in v0.3.0
func DecodeSliceOfDynamicObjectsContentOnFork[T newableDynamicObject[U], U any](dec *Decoder, objects *[]T, maxItems uint64, filter ForkFilter)
DecodeSliceOfDynamicObjectsContentOnFork is the lazy data reader of DecodeSliceOfDynamicObjectsOffsetOnFork.
func DecodeSliceOfDynamicObjectsOffset ¶
func DecodeSliceOfDynamicObjectsOffset[T newableDynamicObject[U], U any](dec *Decoder, objects *[]T)
DecodeSliceOfDynamicObjectsOffset parses a dynamic slice of dynamic ssz objects.
func DecodeSliceOfDynamicObjectsOffsetOnFork ¶ added in v0.3.0
func DecodeSliceOfDynamicObjectsOffsetOnFork[T newableDynamicObject[U], U any](dec *Decoder, objects *[]T, filter ForkFilter)
DecodeSliceOfDynamicObjectsOffsetOnFork parses a dynamic slice of dynamic ssz objects if present in a fork.
func DecodeSliceOfStaticBytesContent ¶
func DecodeSliceOfStaticBytesContent[T commonBytesLengths](dec *Decoder, blobs *[]T, maxItems uint64)
DecodeSliceOfStaticBytesContent is the lazy data reader of DecodeSliceOfStaticBytesOffset.
func DecodeSliceOfStaticBytesContentOnFork ¶ added in v0.3.0
func DecodeSliceOfStaticBytesContentOnFork[T commonBytesLengths](dec *Decoder, blobs *[]T, maxItems uint64, filter ForkFilter)
DecodeSliceOfStaticBytesContentOnFork is the lazy data reader of DecodeSliceOfStaticBytesOffsetOnFork.
func DecodeSliceOfStaticBytesOffset ¶
func DecodeSliceOfStaticBytesOffset[T commonBytesLengths](dec *Decoder, blobs *[]T)
DecodeSliceOfStaticBytesOffset parses a dynamic slice of static binary blobs.
func DecodeSliceOfStaticBytesOffsetOnFork ¶ added in v0.3.0
func DecodeSliceOfStaticBytesOffsetOnFork[T commonBytesLengths](dec *Decoder, blobs *[]T, filter ForkFilter)
DecodeSliceOfStaticBytesOffsetOnFork parses a dynamic slice of static binary blobs if present in a fork.
func DecodeSliceOfStaticObjectsContent ¶
func DecodeSliceOfStaticObjectsContent[T newableStaticObject[U], U any](dec *Decoder, objects *[]T, maxItems uint64)
DecodeSliceOfStaticObjectsContent is the lazy data reader of DecodeSliceOfStaticObjectsOffset.
func DecodeSliceOfStaticObjectsContentOnFork ¶ added in v0.3.0
func DecodeSliceOfStaticObjectsContentOnFork[T newableStaticObject[U], U any](dec *Decoder, objects *[]T, maxItems uint64, filter ForkFilter)
DecodeSliceOfStaticObjectsContentOnFork is the lazy data reader of DecodeSliceOfStaticObjectsOffsetOnFork.
func DecodeSliceOfStaticObjectsOffset ¶
DecodeSliceOfStaticObjectsOffset parses a dynamic slice of static ssz objects.
func DecodeSliceOfStaticObjectsOffsetOnFork ¶ added in v0.3.0
func DecodeSliceOfStaticObjectsOffsetOnFork[T newableStaticObject[U], U any](dec *Decoder, objects *[]T, filter ForkFilter)
DecodeSliceOfStaticObjectsOffsetOnFork parses a dynamic slice of static ssz objects if present in a fork.
func DecodeSliceOfUint64sContent ¶
DecodeSliceOfUint64sContent is the lazy data reader of DecodeSliceOfUint64sOffset.
func DecodeSliceOfUint64sContentOnFork ¶ added in v0.3.0
func DecodeSliceOfUint64sContentOnFork[T ~uint64](dec *Decoder, ns *[]T, maxItems uint64, filter ForkFilter)
DecodeSliceOfUint64sContentOnFork is the lazy data reader of DecodeSliceOfUint64sOffsetOnFork.
func DecodeSliceOfUint64sOffset ¶
DecodeSliceOfUint64sOffset parses a dynamic slice of uint64s.
func DecodeSliceOfUint64sOffsetOnFork ¶ added in v0.3.0
func DecodeSliceOfUint64sOffsetOnFork[T ~uint64](dec *Decoder, ns *[]T, filter ForkFilter)
DecodeSliceOfUint64sOffsetOnFork parses a dynamic slice of uint64s if present in a fork.
func DecodeStaticBytes ¶
func DecodeStaticBytes[T commonBytesLengths](dec *Decoder, blob *T)
DecodeStaticBytes parses a static binary blob.
func DecodeStaticBytesPointerOnFork ¶ added in v0.3.0
func DecodeStaticBytesPointerOnFork[T commonBytesLengths](dec *Decoder, blob **T, filter ForkFilter)
DecodeStaticBytesPointerOnFork parses a static binary blob if present in a fork. If not, the bytes are set to nil.
func DecodeStaticObject ¶
DecodeStaticObject parses a static ssz object.
func DecodeStaticObjectOnFork ¶ added in v0.3.0
func DecodeStaticObjectOnFork[T newableStaticObject[U], U any](dec *Decoder, obj *T, filter ForkFilter)
DecodeStaticObjectOnFork parses a static ssz object if present in a fork.
func DecodeUint16 ¶ added in v0.3.0
DecodeUint16 parses a uint16.
func DecodeUint16PointerOnFork ¶ added in v0.3.0
func DecodeUint16PointerOnFork[T ~uint16](dec *Decoder, n **T, filter ForkFilter)
DecodeUint16PointerOnFork parses a uint16 if present in a fork. If not, the uint16 pointer is set to nil.
This method is similar to DecodeUint16, but will also initialize the pointer if it is not allocated yet.
func DecodeUint256 ¶
DecodeUint256 parses a uint256.
func DecodeUint256BigInt ¶ added in v0.3.0
DecodeUint256BigInt parses a uint256 into a big.Int.
func DecodeUint256BigIntOnFork ¶ added in v0.3.0
func DecodeUint256BigIntOnFork(dec *Decoder, n **big.Int, filter ForkFilter)
DecodeUint256BigIntOnFork parses a uint256 into a big.Int if present in a fork.
func DecodeUint256OnFork ¶ added in v0.3.0
func DecodeUint256OnFork(dec *Decoder, n **uint256.Int, filter ForkFilter)
DecodeUint256OnFork parses a uint256 if present in a fork.
func DecodeUint32 ¶ added in v0.3.0
DecodeUint32 parses a uint32.
func DecodeUint32PointerOnFork ¶ added in v0.3.0
func DecodeUint32PointerOnFork[T ~uint32](dec *Decoder, n **T, filter ForkFilter)
DecodeUint32PointerOnFork parses a uint32 if present in a fork. If not, the uint32 pointer is set to nil.
This method is similar to DecodeUint32, but will also initialize the pointer if it is not allocated yet.
func DecodeUint64PointerOnFork ¶ added in v0.3.0
func DecodeUint64PointerOnFork[T ~uint64](dec *Decoder, n **T, filter ForkFilter)
DecodeUint64PointerOnFork parses a uint64 if present in a fork. If not, the uint64 pointer is set to nil.
This method is similar to DecodeUint64, but will also initialize the pointer if it is not allocated yet.
func DecodeUint8 ¶ added in v0.3.0
DecodeUint8 parses a uint8.
func DecodeUint8PointerOnFork ¶ added in v0.3.0
func DecodeUint8PointerOnFork[T ~uint8](dec *Decoder, n **T, filter ForkFilter)
DecodeUint8PointerOnFork parses a uint8 if present in a fork. If not, the uint8 pointer is set to nil.
This method is similar to DecodeUint8, but will also initialize the pointer if it is not allocated yet.
func DecodeUnsafeArrayOfStaticBytes ¶
func DecodeUnsafeArrayOfStaticBytes[T commonBytesLengths](dec *Decoder, blobs []T)
DecodeUnsafeArrayOfStaticBytes parses a static array of static binary blobs.
func DefineArrayOfBits ¶
DefineArrayOfBits defines the next field as a static array of (packed) bits.
func DefineArrayOfBitsPointerOnFork ¶ added in v0.3.0
func DefineArrayOfBitsPointerOnFork[T commonBitsLengths](c *Codec, bits **T, size uint64, filter ForkFilter)
DefineArrayOfBitsPointerOnFork defines the next field as a static array of (packed) bits if present in a fork.
func DefineArrayOfStaticBytes ¶
func DefineArrayOfStaticBytes[T commonBytesArrayLengths[U], U commonBytesLengths](c *Codec, blobs *T)
DefineArrayOfStaticBytes defines the next field as a static array of static binary blobs.
func DefineArrayOfUint64s ¶
func DefineArrayOfUint64s[T commonUint64sLengths](c *Codec, ns *T)
DefineArrayOfUint64s defines the next field as a static array of uint64s.
func DefineArrayOfUint64sPointerOnFork ¶ added in v0.3.0
func DefineArrayOfUint64sPointerOnFork[T commonUint64sLengths](c *Codec, ns **T, filter ForkFilter)
DefineArrayOfUint64sPointerOnFork defines the next field as a static array of uint64s if present in a fork.
func DefineBool ¶
DefineBool defines the next field as a 1 byte boolean.
func DefineBoolPointerOnFork ¶ added in v0.3.0
func DefineBoolPointerOnFork[T ~bool](c *Codec, v **T, filter ForkFilter)
DefineBoolPointerOnFork defines the next field as a 1 byte boolean if present in a fork.
func DefineCheckedArrayOfStaticBytes ¶
DefineCheckedArrayOfStaticBytes defines the next field as a static array of static binary blobs. This method can be used for plain slices of byte arrays, which is more expensive since it needs runtime size validation.
func DefineCheckedStaticBytes ¶
DefineCheckedStaticBytes defines the next field as static binary blob. This method can be used for plain byte slices, which is more expensive, since it needs runtime size validation.
func DefineDynamicBytesContent ¶
DefineDynamicBytesContent defines the next field as dynamic binary blob.
func DefineDynamicBytesContentOnFork ¶ added in v0.3.0
func DefineDynamicBytesContentOnFork(c *Codec, blob *[]byte, maxSize uint64, filter ForkFilter)
DefineDynamicBytesContentOnFork defines the next field as dynamic binary blob if present in a fork.
func DefineDynamicBytesOffset ¶
DefineDynamicBytesOffset defines the next field as dynamic binary blob.
func DefineDynamicBytesOffsetOnFork ¶ added in v0.3.0
func DefineDynamicBytesOffsetOnFork(c *Codec, blob *[]byte, maxSize uint64, filter ForkFilter)
DefineDynamicBytesOffsetOnFork defines the next field as dynamic binary blob if present in a fork.
func DefineDynamicObjectContent ¶
DefineDynamicObjectContent defines the next field as a dynamic ssz object.
func DefineDynamicObjectContentOnFork ¶ added in v0.3.0
func DefineDynamicObjectContentOnFork[T newableDynamicObject[U], U any](c *Codec, obj *T, filter ForkFilter)
DefineDynamicObjectContentOnFork defines the next field as a dynamic ssz object if present in a fork.
func DefineDynamicObjectOffset ¶
DefineDynamicObjectOffset defines the next field as a dynamic ssz object.
func DefineDynamicObjectOffsetOnFork ¶ added in v0.3.0
func DefineDynamicObjectOffsetOnFork[T newableDynamicObject[U], U any](c *Codec, obj *T, filter ForkFilter)
DefineDynamicObjectOffsetOnFork defines the next field as a dynamic ssz object if present in a fork.
func DefineSliceOfBitsContent ¶
DefineSliceOfBitsContent defines the next field as a dynamic slice of (packed) bits.
func DefineSliceOfBitsContentOnFork ¶ added in v0.3.0
func DefineSliceOfBitsContentOnFork(c *Codec, bits *bitfield.Bitlist, maxBits uint64, filter ForkFilter)
DefineSliceOfBitsContentOnFork defines the next field as a dynamic slice of (packed) bits if present in a fork.
func DefineSliceOfBitsOffset ¶
DefineSliceOfBitsOffset defines the next field as a dynamic slice of (packed) bits.
func DefineSliceOfBitsOffsetOnFork ¶ added in v0.3.0
func DefineSliceOfBitsOffsetOnFork(c *Codec, bits *bitfield.Bitlist, maxBits uint64, filter ForkFilter)
DefineSliceOfBitsOffsetOnFork defines the next field as a dynamic slice of (packed) bits if present in a fork.
func DefineSliceOfDynamicBytesContent ¶
DefineSliceOfDynamicBytesContent defines the next field as a dynamic slice of dynamic binary blobs.
func DefineSliceOfDynamicBytesContentOnFork ¶ added in v0.3.0
func DefineSliceOfDynamicBytesContentOnFork(c *Codec, blobs *[][]byte, maxItems uint64, maxSize uint64, filter ForkFilter)
DefineSliceOfDynamicBytesContentOnFork defines the next field as a dynamic slice of dynamic binary blobs.
func DefineSliceOfDynamicBytesOffset ¶
DefineSliceOfDynamicBytesOffset defines the next field as a dynamic slice of dynamic binary blobs.
func DefineSliceOfDynamicBytesOffsetOnFork ¶ added in v0.3.0
func DefineSliceOfDynamicBytesOffsetOnFork(c *Codec, blobs *[][]byte, maxItems uint64, maxSize uint64, filter ForkFilter)
DefineSliceOfDynamicBytesOffsetOnFork defines the next field as a dynamic slice of dynamic binary blobs if present in a fork.
func DefineSliceOfDynamicObjectsContent ¶
func DefineSliceOfDynamicObjectsContent[T newableDynamicObject[U], U any](c *Codec, objects *[]T, maxItems uint64)
DefineSliceOfDynamicObjectsContent defines the next field as a dynamic slice of dynamic ssz objects.
func DefineSliceOfDynamicObjectsContentOnFork ¶ added in v0.3.0
func DefineSliceOfDynamicObjectsContentOnFork[T newableDynamicObject[U], U any](c *Codec, objects *[]T, maxItems uint64, filter ForkFilter)
DefineSliceOfDynamicObjectsContentOnFork defines the next field as a dynamic slice of dynamic ssz objects if present in a fork.
func DefineSliceOfDynamicObjectsOffset ¶
func DefineSliceOfDynamicObjectsOffset[T newableDynamicObject[U], U any](c *Codec, objects *[]T, maxItems uint64)
DefineSliceOfDynamicObjectsOffset defines the next field as a dynamic slice of dynamic ssz objects.
func DefineSliceOfDynamicObjectsOffsetOnFork ¶ added in v0.3.0
func DefineSliceOfDynamicObjectsOffsetOnFork[T newableDynamicObject[U], U any](c *Codec, objects *[]T, maxItems uint64, filter ForkFilter)
DefineSliceOfDynamicObjectsOffsetOnFork defines the next field as a dynamic slice of dynamic ssz objects if present in a fork.
func DefineSliceOfStaticBytesContent ¶
DefineSliceOfStaticBytesContent defines the next field as a dynamic slice of static binary blobs.
func DefineSliceOfStaticBytesContentOnFork ¶ added in v0.3.0
func DefineSliceOfStaticBytesContentOnFork[T commonBytesLengths](c *Codec, blobs *[]T, maxItems uint64, filter ForkFilter)
DefineSliceOfStaticBytesContentOnFork defines the next field as a dynamic slice of static binary blobs if present in a fork.
func DefineSliceOfStaticBytesOffset ¶
DefineSliceOfStaticBytesOffset defines the next field as a dynamic slice of static binary blobs.
func DefineSliceOfStaticBytesOffsetOnFork ¶ added in v0.3.0
func DefineSliceOfStaticBytesOffsetOnFork[T commonBytesLengths](c *Codec, bytes *[]T, maxItems uint64, filter ForkFilter)
DefineSliceOfStaticBytesOffsetOnFork defines the next field as a dynamic slice of static binary blobs if present in a fork.
func DefineSliceOfStaticObjectsContent ¶
func DefineSliceOfStaticObjectsContent[T newableStaticObject[U], U any](c *Codec, objects *[]T, maxItems uint64)
DefineSliceOfStaticObjectsContent defines the next field as a dynamic slice of static ssz objects.
func DefineSliceOfStaticObjectsContentOnFork ¶ added in v0.3.0
func DefineSliceOfStaticObjectsContentOnFork[T newableStaticObject[U], U any](c *Codec, objects *[]T, maxItems uint64, filter ForkFilter)
DefineSliceOfStaticObjectsContentOnFork defines the next field as a dynamic slice of static ssz objects if present in a fork.
func DefineSliceOfStaticObjectsOffset ¶
func DefineSliceOfStaticObjectsOffset[T newableStaticObject[U], U any](c *Codec, objects *[]T, maxItems uint64)
DefineSliceOfStaticObjectsOffset defines the next field as a dynamic slice of static ssz objects.
func DefineSliceOfStaticObjectsOffsetOnFork ¶ added in v0.3.0
func DefineSliceOfStaticObjectsOffsetOnFork[T newableStaticObject[U], U any](c *Codec, objects *[]T, maxItems uint64, filter ForkFilter)
DefineSliceOfStaticObjectsOffsetOnFork defines the next field as a dynamic slice of static ssz objects if present in a fork.
func DefineSliceOfUint64sContent ¶
DefineSliceOfUint64sContent defines the next field as a dynamic slice of uint64s.
func DefineSliceOfUint64sContentOnFork ¶ added in v0.3.0
func DefineSliceOfUint64sContentOnFork[T ~uint64](c *Codec, ns *[]T, maxItems uint64, filter ForkFilter)
DefineSliceOfUint64sContentOnFork defines the next field as a dynamic slice of uint64s if present in a fork.
func DefineSliceOfUint64sOffset ¶
DefineSliceOfUint64sOffset defines the next field as a dynamic slice of uint64s.
func DefineSliceOfUint64sOffsetOnFork ¶ added in v0.3.0
func DefineSliceOfUint64sOffsetOnFork[T ~uint64](c *Codec, ns *[]T, maxItems uint64, filter ForkFilter)
DefineSliceOfUint64sOffsetOnFork defines the next field as a dynamic slice of uint64s if present in a fork.
func DefineStaticBytes ¶
func DefineStaticBytes[T commonBytesLengths](c *Codec, blob *T)
DefineStaticBytes defines the next field as static binary blob. This method can be used for byte arrays.
func DefineStaticBytesPointerOnFork ¶ added in v0.3.0
func DefineStaticBytesPointerOnFork[T commonBytesLengths](c *Codec, blob **T, filter ForkFilter)
DefineStaticBytesPointerOnFork defines the next field as static binary blob if present in a fork. This method can be used for byte arrays.
func DefineStaticObject ¶
DefineStaticObject defines the next field as a static ssz object.
func DefineStaticObjectOnFork ¶ added in v0.3.0
func DefineStaticObjectOnFork[T newableStaticObject[U], U any](c *Codec, obj *T, filter ForkFilter)
DefineStaticObjectOnFork defines the next field as a static ssz object if present in a fork.
func DefineUint16 ¶ added in v0.3.0
DefineUint16 defines the next field as a uint16.
func DefineUint16PointerOnFork ¶ added in v0.3.0
func DefineUint16PointerOnFork[T ~uint16](c *Codec, n **T, filter ForkFilter)
DefineUint16PointerOnFork defines the next field as a uint16 if present in a fork.
func DefineUint256 ¶
DefineUint256 defines the next field as a uint256.
func DefineUint256BigInt ¶ added in v0.3.0
DefineUint256BigInt defines the next field as a uint256.
func DefineUint256BigIntOnFork ¶ added in v0.3.0
func DefineUint256BigIntOnFork(c *Codec, n **big.Int, filter ForkFilter)
DefineUint256BigIntOnFork defines the next field as a uint256 if present in a fork.
func DefineUint256OnFork ¶ added in v0.3.0
func DefineUint256OnFork(c *Codec, n **uint256.Int, filter ForkFilter)
DefineUint256OnFork defines the next field as a uint256 if present in a fork.
func DefineUint32 ¶ added in v0.3.0
DefineUint32 defines the next field as a uint32.
func DefineUint32PointerOnFork ¶ added in v0.3.0
func DefineUint32PointerOnFork[T ~uint32](c *Codec, n **T, filter ForkFilter)
DefineUint32PointerOnFork defines the next field as a uint32 if present in a fork.
func DefineUint64 ¶
DefineUint64 defines the next field as a uint64.
func DefineUint64PointerOnFork ¶ added in v0.3.0
func DefineUint64PointerOnFork[T ~uint64](c *Codec, n **T, filter ForkFilter)
DefineUint64PointerOnFork defines the next field as a uint64 if present in a fork.
func DefineUint8 ¶ added in v0.3.0
DefineUint8 defines the next field as a uint8.
func DefineUint8PointerOnFork ¶ added in v0.3.0
func DefineUint8PointerOnFork[T ~uint8](c *Codec, n **T, filter ForkFilter)
DefineUint8PointerOnFork defines the next field as a uint8 if present in a fork.
func DefineUnsafeArrayOfStaticBytes ¶
func DefineUnsafeArrayOfStaticBytes[T commonBytesLengths](c *Codec, blobs []T)
DefineUnsafeArrayOfStaticBytes defines the next field as a static array of static binary blobs. This method operates on plain slices of byte arrays and will crash if provided a slice of a non-array. Its purpose is to get around Go's generics limitations in generated code (use DefineArrayOfStaticBytes).
func EncodeArrayOfBits ¶
func EncodeArrayOfBits[T commonBitsLengths](enc *Encoder, bits *T)
EncodeArrayOfBits serializes a static array of (packed) bits.
func EncodeArrayOfBitsPointerOnFork ¶ added in v0.3.0
func EncodeArrayOfBitsPointerOnFork[T commonBitsLengths](enc *Encoder, bits *T, filter ForkFilter)
EncodeArrayOfBitsPointerOnFork serializes a static array of (packed) bits if present in a fork.
Note, a nil pointer is serialized as a zero-value bit array.
func EncodeArrayOfStaticBytes ¶
func EncodeArrayOfStaticBytes[T commonBytesArrayLengths[U], U commonBytesLengths](enc *Encoder, blobs *T)
EncodeArrayOfStaticBytes serializes a static array of static binary blobs.
The reason the blobs is passed by pointer and not by value is to prevent it from escaping to the heap (and incurring an allocation) when passing it to the output stream.
func EncodeArrayOfUint64s ¶
func EncodeArrayOfUint64s[T commonUint64sLengths](enc *Encoder, ns *T)
EncodeArrayOfUint64s serializes a static array of uint64s.
The reason the ns is passed by pointer and not by value is to prevent it from escaping to the heap (and incurring an allocation) when passing it to the output stream.
func EncodeArrayOfUint64sPointerOnFork ¶ added in v0.3.0
func EncodeArrayOfUint64sPointerOnFork[T commonUint64sLengths](enc *Encoder, ns *T, filter ForkFilter)
EncodeArrayOfUint64sPointerOnFork serializes a static array of uint64s if present in a fork.
Note, a nil pointer is serialized as a uint64 array filled with zeroes.
func EncodeBoolPointerOnFork ¶ added in v0.3.0
func EncodeBoolPointerOnFork[T ~bool](enc *Encoder, v *T, filter ForkFilter)
EncodeBoolPointerOnFork serializes a boolean if present in a fork.
Note, a nil pointer is serialized as false.
func EncodeCheckedArrayOfStaticBytes ¶
EncodeCheckedArrayOfStaticBytes serializes a static array of static binary blobs.
func EncodeCheckedStaticBytes ¶
EncodeCheckedStaticBytes serializes a static binary blob.
func EncodeDynamicBytesContent ¶
EncodeDynamicBytesContent is the lazy data writer for EncodeDynamicBytesOffset.
func EncodeDynamicBytesContentOnFork ¶ added in v0.3.0
func EncodeDynamicBytesContentOnFork(enc *Encoder, blob []byte, filter ForkFilter)
EncodeDynamicBytesContentOnFork is the lazy data writer for EncodeDynamicBytesOffsetOnFork.
func EncodeDynamicBytesOffset ¶
EncodeDynamicBytesOffset serializes a dynamic binary blob.
func EncodeDynamicBytesOffsetOnFork ¶ added in v0.3.0
func EncodeDynamicBytesOffsetOnFork(enc *Encoder, blob []byte, filter ForkFilter)
EncodeDynamicBytesOffsetOnFork serializes a dynamic binary blob if present in a fork.
func EncodeDynamicObjectContent ¶
EncodeDynamicObjectContent is the lazy data writer for EncodeDynamicObjectOffset.
Note, nil will be encoded as a zero-value initialized object.
func EncodeDynamicObjectContentOnFork ¶ added in v0.3.0
func EncodeDynamicObjectContentOnFork[T newableDynamicObject[U], U any](enc *Encoder, obj T, filter ForkFilter)
EncodeDynamicObjectContentOnFork is the lazy data writer for EncodeDynamicObjectOffsetOnFork.
Note, nil will be encoded as a zero-value initialized object.
func EncodeDynamicObjectOffset ¶
EncodeDynamicObjectOffset serializes a dynamic ssz object.
Note, nil will be encoded as a zero-value initialized object.
func EncodeDynamicObjectOffsetOnFork ¶ added in v0.3.0
func EncodeDynamicObjectOffsetOnFork[T newableDynamicObject[U], U any](enc *Encoder, obj T, filter ForkFilter)
EncodeDynamicObjectOffsetOnFork serializes a dynamic ssz object if present in a fork.
Note, nil will be encoded as a zero-value initialized object.
func EncodeSliceOfBitsContent ¶
EncodeSliceOfBitsContent is the lazy data writer for EncodeSliceOfBitsOffset.
Note, a nil slice of bits is serialized as an empty bit list.
func EncodeSliceOfBitsContentOnFork ¶ added in v0.3.0
func EncodeSliceOfBitsContentOnFork(enc *Encoder, bits bitfield.Bitlist, filter ForkFilter)
EncodeSliceOfBitsContentOnFork is the lazy data writer for EncodeSliceOfBitsOffsetOnFork.
Note, a nil slice of bits is serialized as an empty bit list.
func EncodeSliceOfBitsOffset ¶
EncodeSliceOfBitsOffset serializes a dynamic slice of (packed) bits.
Note, a nil slice of bits is serialized as an empty bit list.
func EncodeSliceOfBitsOffsetOnFork ¶ added in v0.3.0
func EncodeSliceOfBitsOffsetOnFork(enc *Encoder, bits bitfield.Bitlist, filter ForkFilter)
EncodeSliceOfBitsOffsetOnFork serializes a dynamic slice of (packed) bits if present in a fork.
Note, a nil slice of bits is serialized as an empty bit list.
func EncodeSliceOfDynamicBytesContent ¶
EncodeSliceOfDynamicBytesContent is the lazy data writer for EncodeSliceOfDynamicBytesOffset.
func EncodeSliceOfDynamicBytesContentOnFork ¶ added in v0.3.0
func EncodeSliceOfDynamicBytesContentOnFork(enc *Encoder, blobs [][]byte, filter ForkFilter)
EncodeSliceOfDynamicBytesContentOnFork is the lazy data writer for EncodeSliceOfDynamicBytesOffsetOnFork.
func EncodeSliceOfDynamicBytesOffset ¶
EncodeSliceOfDynamicBytesOffset serializes a dynamic slice of dynamic binary blobs.
func EncodeSliceOfDynamicBytesOffsetOnFork ¶ added in v0.3.0
func EncodeSliceOfDynamicBytesOffsetOnFork(enc *Encoder, blobs [][]byte, filter ForkFilter)
EncodeSliceOfDynamicBytesOffsetOnFork serializes a dynamic slice of dynamic binary blob if present in a fork.
func EncodeSliceOfDynamicObjectsContent ¶
func EncodeSliceOfDynamicObjectsContent[T DynamicObject](enc *Encoder, objects []T)
EncodeSliceOfDynamicObjectsContent is the lazy data writer for EncodeSliceOfDynamicObjectsOffset.
func EncodeSliceOfDynamicObjectsContentOnFork ¶ added in v0.3.0
func EncodeSliceOfDynamicObjectsContentOnFork[T DynamicObject](enc *Encoder, objects []T, filter ForkFilter)
EncodeSliceOfDynamicObjectsContentOnFork is the lazy data writer for EncodeSliceOfDynamicObjectsOffsetOnFork.
func EncodeSliceOfDynamicObjectsOffset ¶
func EncodeSliceOfDynamicObjectsOffset[T DynamicObject](enc *Encoder, objects []T)
EncodeSliceOfDynamicObjectsOffset serializes a dynamic slice of dynamic ssz objects.
func EncodeSliceOfDynamicObjectsOffsetOnFork ¶ added in v0.3.0
func EncodeSliceOfDynamicObjectsOffsetOnFork[T DynamicObject](enc *Encoder, objects []T, filter ForkFilter)
EncodeSliceOfDynamicObjectsOffsetOnFork serializes a dynamic slice of dynamic ssz objects if present in a fork.
func EncodeSliceOfStaticBytesContent ¶
func EncodeSliceOfStaticBytesContent[T commonBytesLengths](enc *Encoder, blobs []T)
EncodeSliceOfStaticBytesContent is the lazy data writer for EncodeSliceOfStaticBytesOffset.
func EncodeSliceOfStaticBytesContentOnFork ¶ added in v0.3.0
func EncodeSliceOfStaticBytesContentOnFork[T commonBytesLengths](enc *Encoder, blobs []T, filter ForkFilter)
EncodeSliceOfStaticBytesContentOnFork is the lazy data writer for EncodeSliceOfStaticBytesOffsetOnFork.
func EncodeSliceOfStaticBytesOffset ¶
func EncodeSliceOfStaticBytesOffset[T commonBytesLengths](enc *Encoder, blobs []T)
EncodeSliceOfStaticBytesOffset serializes a dynamic slice of static binary blobs.
func EncodeSliceOfStaticBytesOffsetOnFork ¶ added in v0.3.0
func EncodeSliceOfStaticBytesOffsetOnFork[T commonBytesLengths](enc *Encoder, blobs []T, filter ForkFilter)
EncodeSliceOfStaticBytesOffsetOnFork serializes a dynamic slice of static binary blobs.
func EncodeSliceOfStaticObjectsContent ¶
func EncodeSliceOfStaticObjectsContent[T StaticObject](enc *Encoder, objects []T)
EncodeSliceOfStaticObjectsContent is the lazy data writer for EncodeSliceOfStaticObjectsOffset.
func EncodeSliceOfStaticObjectsContentOnFork ¶ added in v0.3.0
func EncodeSliceOfStaticObjectsContentOnFork[T StaticObject](enc *Encoder, objects []T, filter ForkFilter)
EncodeSliceOfStaticObjectsContentOnFork is the lazy data writer for EncodeSliceOfStaticObjectsOffsetOnFork.
func EncodeSliceOfStaticObjectsOffset ¶
func EncodeSliceOfStaticObjectsOffset[T StaticObject](enc *Encoder, objects []T)
EncodeSliceOfStaticObjectsOffset serializes a dynamic slice of static ssz objects.
func EncodeSliceOfStaticObjectsOffsetOnFork ¶ added in v0.3.0
func EncodeSliceOfStaticObjectsOffsetOnFork[T StaticObject](enc *Encoder, objects []T, filter ForkFilter)
EncodeSliceOfStaticObjectsOffsetOnFork serializes a dynamic slice of static ssz objects if present in a fork.
func EncodeSliceOfUint64sContent ¶
EncodeSliceOfUint64sContent is the lazy data writer for EncodeSliceOfUint64sOffset.
func EncodeSliceOfUint64sContentOnFork ¶ added in v0.3.0
func EncodeSliceOfUint64sContentOnFork[T ~uint64](enc *Encoder, ns []T, filter ForkFilter)
EncodeSliceOfUint64sContentOnFork is the lazy data writer for EncodeSliceOfUint64sOffsetOnFork.
func EncodeSliceOfUint64sOffset ¶
EncodeSliceOfUint64sOffset serializes a dynamic slice of uint64s.
func EncodeSliceOfUint64sOffsetOnFork ¶ added in v0.3.0
func EncodeSliceOfUint64sOffsetOnFork[T ~uint64](enc *Encoder, ns []T, filter ForkFilter)
EncodeSliceOfUint64sOffsetOnFork serializes a dynamic slice of uint64s if present in a fork.
func EncodeStaticBytes ¶
func EncodeStaticBytes[T commonBytesLengths](enc *Encoder, blob *T)
EncodeStaticBytes serializes a static binary blob.
The blob is passed by pointer to avoid high stack copy costs and a potential escape to the heap.
func EncodeStaticBytesPointerOnFork ¶ added in v0.3.0
func EncodeStaticBytesPointerOnFork[T commonBytesLengths](enc *Encoder, blob *T, filter ForkFilter)
EncodeStaticBytesPointerOnFork serializes a static binary blob if present in a fork.
Note, a nil pointer is serialized as a zero-value blob.
func EncodeStaticObject ¶
EncodeStaticObject serializes a static ssz object.
Note, nil will be encoded as a zero-value initialized object.
Example ¶
// ssz: Go Simple Serialize (SSZ) codec library
// Copyright 2024 ssz Authors
// SPDX-License-Identifier: BSD-3-Clause
package main
import (
"bytes"
"fmt"
"github.com/karalabe/ssz"
)
type Address [20]byte
type Withdrawal struct {
Index uint64 `ssz-size:"8"`
Validator uint64 `ssz-size:"8"`
Address Address `ssz-size:"20"`
Amount uint64 `ssz-size:"8"`
}
func (w *Withdrawal) SizeSSZ(siz *ssz.Sizer) uint32 { return 44 }
func (w *Withdrawal) DefineSSZ(codec *ssz.Codec) {
ssz.DefineUint64(codec, &w.Index) // Field (0) - Index - 8 bytes
ssz.DefineUint64(codec, &w.Validator) // Field (1) - ValidatorIndex - 8 bytes
ssz.DefineStaticBytes(codec, &w.Address) // Field (2) - Address - 20 bytes
ssz.DefineUint64(codec, &w.Amount) // Field (3) - Amount - 8 bytes
}
func main() {
out := new(bytes.Buffer)
if err := ssz.EncodeToStream(out, new(Withdrawal)); err != nil {
panic(err)
}
hash := ssz.HashSequential(new(Withdrawal))
fmt.Printf("ssz: %#x\nhash: %#x\n", out, hash)
}
Output: ssz: 0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 hash: 0xdb56114e00fdd4c1f85c892bf35ac9a89289aaecb1ebd0a96cde606a748b5d71
func EncodeStaticObjectOnFork ¶ added in v0.3.0
func EncodeStaticObjectOnFork[T newableStaticObject[U], U any](enc *Encoder, obj T, filter ForkFilter)
EncodeStaticObjectOnFork serializes a static ssz object is present in a fork.
Note, nil will be encoded as a zero-value initialized object.
func EncodeToBytes ¶
EncodeToBytes serializes a non-monolithic object into a byte buffer. If the type contains fork-specific rules, use EncodeToBytesOnFork.
Don't use this method if you want to then write the buffer into a stream via some writer, as that would double the memory use for the temporary buffer. For that use case, use EncodeToStream.
func EncodeToBytesOnFork ¶ added in v0.3.0
EncodeToBytesOnFork serializes a monolithic object into a byte buffer. If the type does not contain fork-specific rules, you can also use EncodeToBytes.
Don't use this method if you want to then write the buffer into a stream via some writer, as that would double the memory use for the temporary buffer. For that use case, use EncodeToStreamOnFork.
func EncodeToStream ¶
EncodeToStream serializes a non-monolithic object into a data stream. If the type contains fork-specific rules, use EncodeToStreamOnFork.
Do not use this method with a bytes.Buffer to write into a []byte slice, as that will do double the byte copying. For that use case, use EncodeToBytes.
func EncodeToStreamOnFork ¶ added in v0.3.0
EncodeToStreamOnFork serializes a monolithic object into a data stream. If the type does not contain fork-specific rules, you can also use EncodeToStream.
Do not use this method with a bytes.Buffer to write into a []byte slice, as that will do double the byte copying. For that use case, use EncodeToBytesOnFork.
func EncodeUint16 ¶ added in v0.3.0
EncodeUint16 serializes a uint16.
func EncodeUint16PointerOnFork ¶ added in v0.3.0
func EncodeUint16PointerOnFork[T ~uint16](enc *Encoder, n *T, filter ForkFilter)
EncodeUint16PointerOnFork serializes a uint16 if present in a fork.
Note, a nil pointer is serialized as zero.
func EncodeUint256BigInt ¶ added in v0.3.0
EncodeUint256BigInt serializes a big.Int as uint256.
Note, a nil pointer is serialized as zero. Note, an overflow will be silently dropped.
func EncodeUint256BigIntOnFork ¶ added in v0.3.0
func EncodeUint256BigIntOnFork(enc *Encoder, n *big.Int, filter ForkFilter)
EncodeUint256BigIntOnFork serializes a big.Int as uint256 if present in a fork.
Note, a nil pointer is serialized as zero. Note, an overflow will be silently dropped.
func EncodeUint256OnFork ¶ added in v0.3.0
func EncodeUint256OnFork(enc *Encoder, n *uint256.Int, filter ForkFilter)
EncodeUint256OnFork serializes a uint256 if present in a fork.
Note, a nil pointer is serialized as zero.
func EncodeUint32 ¶ added in v0.3.0
EncodeUint32 serializes a uint32.
func EncodeUint32PointerOnFork ¶ added in v0.3.0
func EncodeUint32PointerOnFork[T ~uint32](enc *Encoder, n *T, filter ForkFilter)
EncodeUint32PointerOnFork serializes a uint32 if present in a fork.
Note, a nil pointer is serialized as zero.
func EncodeUint64 ¶
EncodeUint64 serializes a uint64.
func EncodeUint64PointerOnFork ¶ added in v0.3.0
func EncodeUint64PointerOnFork[T ~uint64](enc *Encoder, n *T, filter ForkFilter)
EncodeUint64PointerOnFork serializes a uint64 if present in a fork.
Note, a nil pointer is serialized as zero.
func EncodeUint8 ¶ added in v0.3.0
EncodeUint8 serializes a uint8.
func EncodeUint8PointerOnFork ¶ added in v0.3.0
func EncodeUint8PointerOnFork[T ~uint8](enc *Encoder, n *T, filter ForkFilter)
EncodeUint8PointerOnFork serializes a uint8 if present in a fork.
Note, a nil pointer is serialized as zero.
func EncodeUnsafeArrayOfStaticBytes ¶
func EncodeUnsafeArrayOfStaticBytes[T commonBytesLengths](enc *Encoder, blobs []T)
EncodeUnsafeArrayOfStaticBytes serializes a static array of static binary blobs.
func HashArrayOfBits ¶ added in v0.2.0
func HashArrayOfBits[T commonBitsLengths](h *Hasher, bits *T)
HashArrayOfBits hashes a static array of (packed) bits.
func HashArrayOfBitsPointerOnFork ¶ added in v0.3.0
func HashArrayOfBitsPointerOnFork[T commonBitsLengths](h *Hasher, bits *T, filter ForkFilter)
HashArrayOfBitsPointerOnFork hashes a static array of (packed) bits if present in a fork.
func HashArrayOfStaticBytes ¶ added in v0.2.0
func HashArrayOfStaticBytes[T commonBytesArrayLengths[U], U commonBytesLengths](h *Hasher, blobs *T)
HashArrayOfStaticBytes hashes a static array of static binary blobs.
The reason the blobs is passed by pointer and not by value is to prevent it from escaping to the heap (and incurring an allocation) when passing it to the output stream.
func HashArrayOfUint64s ¶ added in v0.2.0
func HashArrayOfUint64s[T commonUint64sLengths](h *Hasher, ns *T)
HashArrayOfUint64s hashes a static array of uint64s.
The reason the ns is passed by pointer and not by value is to prevent it from escaping to the heap (and incurring an allocation) when passing it to the hasher.
func HashArrayOfUint64sPointerOnFork ¶ added in v0.3.0
func HashArrayOfUint64sPointerOnFork[T commonUint64sLengths](h *Hasher, ns *T, filter ForkFilter)
HashArrayOfUint64sPointerOnFork hashes a static array of uint64s if present in a fork.
func HashBoolPointerOnFork ¶ added in v0.3.0
func HashBoolPointerOnFork[T ~bool](h *Hasher, v *T, filter ForkFilter)
HashBoolPointerOnFork hashes a boolean if present in a fork.
Note, a nil pointer is hashed as zero.
func HashCheckedArrayOfStaticBytes ¶ added in v0.2.0
func HashCheckedArrayOfStaticBytes[T commonBytesLengths](h *Hasher, blobs []T)
HashCheckedArrayOfStaticBytes hashes a static array of static binary blobs.
func HashCheckedStaticBytes ¶ added in v0.2.0
HashCheckedStaticBytes hashes a static binary blob.
func HashConcurrent ¶ added in v0.2.0
HashConcurrent computes the merkle root of a non-monolithic object on potentially multiple concurrent threads (iff some data segments are large enough to be worth it). This is useful for processing large objects, but will place a bigger load on your CPU and GC; and might be more variable timing wise depending on other load.
If the type contains fork-specific rules, use HashConcurrentOnFork.
func HashConcurrentOnFork ¶ added in v0.3.0
HashConcurrentOnFork computes the merkle root of a monolithic object on potentially multiple concurrent threads (iff some data segments are large enough to be worth it). This is useful for processing large objects, but will place a bigger load on your CPU and GC; and might be more variable timing wise depending on other load.
If the type does not contain fork-specific rules, you can also use HashConcurrent.
func HashDynamicBytes ¶ added in v0.2.0
HashDynamicBytes hashes a dynamic binary blob.
func HashDynamicBytesOnFork ¶ added in v0.3.0
func HashDynamicBytesOnFork(h *Hasher, blob []byte, maxSize uint64, filter ForkFilter)
HashDynamicBytesOnFork hashes a dynamic binary blob if present in a fork.
func HashDynamicObject ¶ added in v0.2.0
HashDynamicObject hashes a dynamic ssz object.
func HashDynamicObjectOnFork ¶ added in v0.3.0
func HashDynamicObjectOnFork[T newableDynamicObject[U], U any](h *Hasher, obj T, filter ForkFilter)
HashDynamicObjectOnFork hashes a dynamic ssz object if present in a fork.
func HashSequential ¶ added in v0.2.0
HashSequential computes the merkle root of a non-monolithic object on a single thread. This is useful for processing small objects with stable runtime and O(1) GC guarantees.
If the type contains fork-specific rules, use HashSequentialOnFork.
func HashSequentialOnFork ¶ added in v0.3.0
HashSequentialOnFork computes the merkle root of a monolithic object on a single thread. This is useful for processing small objects with stable runtime and O(1) GC guarantees.
If the type does not contain fork-specific rules, you can also use HashSequential.
func HashSliceOfBits ¶ added in v0.2.0
HashSliceOfBits hashes a dynamic slice of (packed) bits.
Note, a nil slice of bits is serialized as an empty bit list.
func HashSliceOfBitsOnFork ¶ added in v0.3.0
func HashSliceOfBitsOnFork(h *Hasher, bits bitfield.Bitlist, maxBits uint64, filter ForkFilter)
HashSliceOfBitsOnFork hashes a dynamic slice of (packed) bits if present in a fork.
Note, a nil slice of bits is serialized as an empty bit list.
func HashSliceOfDynamicBytes ¶ added in v0.2.0
HashSliceOfDynamicBytes hashes a dynamic slice of dynamic binary blobs.
func HashSliceOfDynamicBytesOnFork ¶ added in v0.3.0
func HashSliceOfDynamicBytesOnFork(h *Hasher, blobs [][]byte, maxItems uint64, maxSize uint64, filter ForkFilter)
HashSliceOfDynamicBytesOnFork hashes a dynamic slice of dynamic binary blobs if present in a fork.
func HashSliceOfDynamicObjects ¶ added in v0.2.0
func HashSliceOfDynamicObjects[T DynamicObject](h *Hasher, objects []T, maxItems uint64)
HashSliceOfDynamicObjects hashes a dynamic slice of dynamic ssz objects.
func HashSliceOfDynamicObjectsOnFork ¶ added in v0.3.0
func HashSliceOfDynamicObjectsOnFork[T DynamicObject](h *Hasher, objects []T, maxItems uint64, filter ForkFilter)
HashSliceOfDynamicObjectsOnFork hashes a dynamic slice of dynamic ssz objects if present in a fork.
func HashSliceOfStaticBytes ¶ added in v0.2.0
HashSliceOfStaticBytes hashes a dynamic slice of static binary blobs.
func HashSliceOfStaticBytesOnFork ¶ added in v0.3.0
func HashSliceOfStaticBytesOnFork[T commonBytesLengths](h *Hasher, blobs []T, maxItems uint64, filter ForkFilter)
HashSliceOfStaticBytesOnFork hashes a dynamic slice of static binary blobs if present in a fork.
func HashSliceOfStaticObjects ¶ added in v0.2.0
func HashSliceOfStaticObjects[T StaticObject](h *Hasher, objects []T, maxItems uint64)
HashSliceOfStaticObjects hashes a dynamic slice of static ssz objects.
func HashSliceOfStaticObjectsOnFork ¶ added in v0.3.0
func HashSliceOfStaticObjectsOnFork[T StaticObject](h *Hasher, objects []T, maxItems uint64, filter ForkFilter)
HashSliceOfStaticObjectsOnFork hashes a dynamic slice of static ssz objects if present in a fork.
func HashSliceOfUint64s ¶ added in v0.2.0
HashSliceOfUint64s hashes a dynamic slice of uint64s.
func HashSliceOfUint64sOnFork ¶ added in v0.3.0
func HashSliceOfUint64sOnFork[T ~uint64](h *Hasher, ns []T, maxItems uint64, filter ForkFilter)
HashSliceOfUint64sOnFork hashes a dynamic slice of uint64s if present in a fork.
func HashStaticBytes ¶ added in v0.2.0
func HashStaticBytes[T commonBytesLengths](h *Hasher, blob *T)
HashStaticBytes hashes a static binary blob.
The blob is passed by pointer to avoid high stack copy costs and a potential escape to the heap.
func HashStaticBytesPointerOnFork ¶ added in v0.3.0
func HashStaticBytesPointerOnFork[T commonBytesLengths](h *Hasher, blob *T, filter ForkFilter)
HashStaticBytesPointerOnFork hashes a static binary blob if present in a fork.
Note, a nil pointer is hashed as an empty binary blob.
func HashStaticObject ¶ added in v0.2.0
HashStaticObject hashes a static ssz object.
func HashStaticObjectOnFork ¶ added in v0.3.0
func HashStaticObjectOnFork[T newableStaticObject[U], U any](h *Hasher, obj T, filter ForkFilter)
HashStaticObjectOnFork hashes a static ssz object if present in a fork.
func HashUint16 ¶ added in v0.3.0
HashUint16 hashes a uint16.
func HashUint16PointerOnFork ¶ added in v0.3.0
func HashUint16PointerOnFork[T ~uint16](h *Hasher, n *T, filter ForkFilter)
HashUint16PointerOnFork hashes a uint16 if present in a fork.
Note, a nil pointer is hashed as zero.
func HashUint256 ¶ added in v0.2.0
HashUint256 hashes a uint256.
Note, a nil pointer is hashed as zero.
func HashUint256BigInt ¶ added in v0.3.0
HashUint256BigInt hashes a big.Int as uint256.
Note, a nil pointer is hashed as zero. Note, an overflow will be silently dropped.
func HashUint256BigIntOnFork ¶ added in v0.3.0
func HashUint256BigIntOnFork(h *Hasher, n *big.Int, filter ForkFilter)
HashUint256BigIntOnFork hashes a big.Int as uint256 if present in a fork.
Note, a nil pointer is hashed as zero. Note, an overflow will be silently dropped.
func HashUint256OnFork ¶ added in v0.3.0
func HashUint256OnFork(h *Hasher, n *uint256.Int, filter ForkFilter)
HashUint256OnFork hashes a uint256 if present in a fork.
Note, a nil pointer is hashed as zero.
func HashUint32 ¶ added in v0.3.0
HashUint32 hashes a uint32.
func HashUint32PointerOnFork ¶ added in v0.3.0
func HashUint32PointerOnFork[T ~uint32](h *Hasher, n *T, filter ForkFilter)
HashUint32PointerOnFork hashes a uint32 if present in a fork.
Note, a nil pointer is hashed as zero.
func HashUint64 ¶ added in v0.2.0
HashUint64 hashes a uint64.
func HashUint64PointerOnFork ¶ added in v0.3.0
func HashUint64PointerOnFork[T ~uint64](h *Hasher, n *T, filter ForkFilter)
HashUint64PointerOnFork hashes a uint64 if present in a fork.
Note, a nil pointer is hashed as zero.
func HashUint8PointerOnFork ¶ added in v0.3.0
func HashUint8PointerOnFork[T ~uint8](h *Hasher, n *T, filter ForkFilter)
HashUint8PointerOnFork hashes a uint8 if present in a fork.
Note, a nil pointer is hashed as zero.
func HashUnsafeArrayOfStaticBytes ¶ added in v0.2.0
func HashUnsafeArrayOfStaticBytes[T commonBytesLengths](h *Hasher, blobs []T)
HashUnsafeArrayOfStaticBytes hashes a static array of static binary blobs.
func PrecomputeStaticSizeCache ¶ added in v0.3.0
PrecomputeStaticSizeCache is a helper to precompute SSZ (static) sizes for a monolith type on different forks.
For non-monolith types that are constant across forks (or are not meant to be used across forks), all the sizes will be the same so might as well hard-code it instead.
func Size ¶
Size retrieves the size of a non-monolithic object, independent if it is static or dynamic. If the type contains fork-specific rules, use SizeOnFork.
func SizeDynamicBytes ¶
SizeDynamicBytes returns the serialized size of the dynamic part of a dynamic blob.
func SizeDynamicObject ¶
SizeDynamicObject returns the serialized size of the dynamic part of a dynamic object.
func SizeOnFork ¶ added in v0.3.0
SizeOnFork retrieves the size of a monolithic object, independent if it is static or dynamic. If the type does not contain fork-specific rules, you can also use Size.
func SizeSliceOfBits ¶
SizeSliceOfBits returns the serialized size of the dynamic part of a slice of bits.
Note, a nil slice of bits is sized as an empty bit list.
func SizeSliceOfDynamicBytes ¶
SizeSliceOfDynamicBytes returns the serialized size of the dynamic part of a dynamic list of dynamic blobs.
func SizeSliceOfDynamicObjects ¶
func SizeSliceOfDynamicObjects[T DynamicObject](siz *Sizer, objects []T) uint32
SizeSliceOfDynamicObjects returns the serialized size of the dynamic part of a dynamic list of dynamic objects.
func SizeSliceOfStaticBytes ¶
SizeSliceOfStaticBytes returns the serialized size of the dynamic part of a dynamic list of static blobs.
func SizeSliceOfStaticObjects ¶
func SizeSliceOfStaticObjects[T StaticObject](siz *Sizer, objects []T) uint32
SizeSliceOfStaticObjects returns the serialized size of the dynamic part of a dynamic list of static objects.
func SizeSliceOfUint64s ¶
SizeSliceOfUint64s returns the serialized size of the dynamic part of a dynamic list of uint64s.
Types ¶
type Codec ¶
type Codec struct {
// contains filtered or unexported fields
}
Codec is a unified SSZ encoder and decoder that allows simple structs to define their schemas once and have that work for both operations at once (with the same speed as explicitly typing them out would, of course).
func (*Codec) DefineDecoder ¶
DefineDecoder uses a dedicated decoder in case the types SSZ conversion is for some reason asymmetric (e.g. encoding depends on fields, decoding depends on outer context).
In reality, it will be the live code run when the object is being parsed.
func (*Codec) DefineEncoder ¶
DefineEncoder uses a dedicated encoder in case the types SSZ conversion is for some reason asymmetric (e.g. encoding depends on fields, decoding depends on outer context).
In reality, it will be the live code run when the object is being serialized.
func (*Codec) DefineHasher ¶ added in v0.2.0
DefineHasher uses a dedicated hasher in case the types SSZ conversion is for some reason asymmetric (e.g. encoding depends on fields, decoding depends on outer context).
In reality, it will be the live code run when the object is being parsed.
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder is a wrapper around an io.Reader or a []byte buffer to implement SSZ decoding in a streaming or buffered way. It has the following behaviors:
The decoder does not buffer, simply reads from the wrapped input stream directly. If you need buffering, that is up to you.
The decoder does not return errors that were hit during reading from the underlying input stream from individual encoding methods. Since there is no expectation (in general) for failure, user code can be denser if error checking is done at the end. Internally, of course, an error will halt all future input operations.
Internally there are a few implementation details that maintainers need to be aware of when modifying the code:
The decoder supports two modes of operation: streaming and buffered. Any high level Go code would achieve that with two decoder types implementing a common interface. Unfortunately, the DecodeXYZ methods are using Go's generic system, which is not supported on struct/interface *methods*. As such, `Decoder.DecodeUint64s[T ~uint64](ns []T)` style methods cannot be used, only `DecodeUint64s[T ~uint64](end *Decoder, ns []T)`. The latter form then requires each method internally to do some soft of type cast to handle different decoder implementations. To avoid runtime type asserts, we've opted for a combo decoder with 2 possible outputs and switching on which one is set. Elegant? No. Fast? Yes.
A lot of code snippets are repeated (e.g. encoding the offset, which is the exact same for all the different types, yet the code below has them copied verbatim). Unfortunately the Go compiler doesn't inline functions aggressively enough (neither does it allow explicitly directing it to), and in such tight loops, extra calls matter on performance.
type DynamicObject ¶
type DynamicObject interface {
Object
// SizeSSZ returns either the static size of the object if fixed == true, or
// the total size otherwise.
//
// Note, StaticObject.SizeSSZ and DynamicObject.SizeSSZ deliberately clash
// to allow the compiler to detect placing one or the other in reversed data
// slots on an SSZ containers.
SizeSSZ(siz *Sizer, fixed bool) uint32
}
DynamicObject defines the methods a type needs to implement to be used as a ssz encodable and decodable dynamic object.
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
Encoder is a wrapper around an io.Writer or a []byte buffer to implement SSZ encoding in a streaming or buffered way. It has the following behaviors:
The encoder does not buffer, simply writes to the wrapped output stream directly. If you need buffering (and flushing), that is up to you.
The encoder does not return errors that were hit during writing to the underlying output stream from individual encoding methods. Since there is no expectation (in general) for failure, user code can be denser if error checking is done at the end. Internally, of course, an error will halt all future output operations.
The offsets for dynamic fields are tracked internally by the encoder, so the caller only needs to provide the field, the offset of which should be included at the allotted slot.
The contents for dynamic fields are not appended explicitly, rather the caller needs to provide them once more at the end of encoding. This is a design choice to keep the encoder 0-alloc (vs having to stash away the dynamic fields internally).
The encoder does not enforce defined size limits on the dynamic fields. If the caller provided bad data to encode, it is a programming error and a runtime error will not fix anything.
Internally there are a few implementation details that maintainers need to be aware of when modifying the code:
The encoder supports two modes of operation: streaming and buffered. Any high level Go code would achieve that with two encoder types implementing a common interface. Unfortunately, the EncodeXYZ methods are using Go's generic system, which is not supported on struct/interface *methods*. As such, `Encoder.EncodeUint64s[T ~uint64](ns []T)` style methods cannot be used, only `EncodeUint64s[T ~uint64](end *Encoder, ns []T)`. The latter form then requires each method internally to do some soft of type cast to handle different encoder implementations. To avoid runtime type asserts, we've opted for a combo encoder with 2 possible outputs and switching on which one is set. Elegant? No. Fast? Yes.
A lot of code snippets are repeated (e.g. encoding the offset, which is the exact same for all the different types, yet the code below has them copied verbatim). Unfortunately the Go compiler doesn't inline functions aggressively enough (neither does it allow explicitly directing it to), and in such tight loops, extra calls matter on performance.
type Fork ¶ added in v0.3.0
type Fork int
Fork is an enum with all the hard forks that Ethereum mainnet went through, which can be used to multiplex monolith types that can encode/decode across a range of forks, not just for one specific.
These enums are only meaningful in relation to one another, but are completely meaningless numbers otherwise. Do not persist them across code versions.
const ( ForkUnknown Fork = iota // Placeholder if forks haven't been specified (must be index 0) ForkFrontier // https://ethereum.org/en/history/#frontier ForkHomestead // https://ethereum.org/en/history/#homestead ForkDAO // https://ethereum.org/en/history/#dao-fork ForkTangerine // https://ethereum.org/en/history/#tangerine-whistle ForkSpurious // https://ethereum.org/en/history/#spurious-dragon ForkByzantium // https://ethereum.org/en/history/#byzantium ForkConstantinople // https://ethereum.org/en/history/#constantinople ForkIstanbul // https://ethereum.org/en/history/#istanbul ForkMuir // https://ethereum.org/en/history/#muir-glacier ForkPhase0 // https://ethereum.org/en/history/#beacon-chain-genesis ForkBerlin // https://ethereum.org/en/history/#berlin ForkLondon // https://ethereum.org/en/history/#london ForkAltair // https://ethereum.org/en/history/#altair ForkArrow // https://ethereum.org/en/history/#arrow-glacier ForkGray // https://ethereum.org/en/history/#gray-glacier ForkBellatrix // https://ethereum.org/en/history/#bellatrix ForkParis // https://ethereum.org/en/history/#paris ForkShapella // https://ethereum.org/en/history/#shapella ForkDencun // https://ethereum.org/en/history/#dencun ForkPectra // https://ethereum.org/en/history/#pectra ForkFuture // Use this for specifying future features (must be last index, no gaps) ForkMerge = ForkParis // Common alias for Paris ForkShanghai = ForkShapella // EL alias for Shapella ForkCapella = ForkShapella // CL alias for Shapella ForkCancun = ForkDencun // EL alias for Dencun ForkDeneb = ForkDencun // CL alias for Dencun ForkPrague = ForkPectra // EL alias for Pectra ForkElectra = ForkPectra // CL alias for Pectra )
type ForkFilter ¶ added in v0.3.0
ForkFilter can be used by the XXXOnFork methods inside monolithic types to define certain fields appearing only in certain forks.
type Hasher ¶ added in v0.2.0
type Hasher struct {
// contains filtered or unexported fields
}
Hasher is an SSZ Merkle Hash Root computer.
type Object ¶
type Object interface {
// DefineSSZ defines how an object would be encoded/decoded.
DefineSSZ(codec *Codec)
}
Object defines the methods a type needs to implement to be used as a ssz encodable and decodable object.
type Sizer ¶ added in v0.3.0
type Sizer struct {
// contains filtered or unexported fields
}
Sizer is an SSZ static and dynamic size computer.
type StaticObject ¶
type StaticObject interface {
Object
// SizeSSZ returns the total size of the ssz object.
//
// Note, StaticObject.SizeSSZ and DynamicObject.SizeSSZ deliberately clash
// to allow the compiler to detect placing one or the other in reversed data
// slots on an SSZ containers.
SizeSSZ(siz *Sizer) uint32
}
StaticObject defines the methods a type needs to implement to be used as a ssz encodable and decodable static object.
