Documentation
¶
Overview ¶
dynssz: Dynamic SSZ encoding/decoding for Ethereum with fastssz efficiency. This file is part of the dynssz package. Copyright (c) 2024 by pk910. Refer to LICENSE for more information.
Package dynssz provides dynamic SSZ (Simple Serialize) encoding and decoding for Ethereum data structures. Unlike static code generation approaches, dynssz uses runtime reflection to handle dynamic field sizes, making it suitable for various Ethereum presets beyond the mainnet. It seamlessly integrates with fastssz for optimal performance when static definitions are applicable.
Copyright (c) 2024 by pk910. See LICENSE file for details.
dynssz: Dynamic SSZ encoding/decoding for Ethereum with fastssz efficiency. This file is part of the dynssz package. Copyright (c) 2024 by pk910. Refer to LICENSE for more information.
dynssz: Dynamic SSZ encoding/decoding for Ethereum with fastssz efficiency. This file is part of the dynssz package. Copyright (c) 2024 by pk910. Refer to LICENSE for more information.
dynssz: Dynamic SSZ encoding/decoding for Ethereum with fastssz efficiency. This file is part of the dynssz package. Copyright (c) 2024 by pk910. Refer to LICENSE for more information.
dynssz: Dynamic SSZ encoding/decoding for Ethereum with fastssz efficiency. This file is part of the dynssz package. Copyright (c) 2024 by pk910. Refer to LICENSE for more information.
dynssz: Dynamic SSZ encoding/decoding for Ethereum with fastssz efficiency. This file is part of the dynssz package. Copyright (c) 2024 by pk910. Refer to LICENSE for more information.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrOffset = fmt.Errorf("incorrect offset") ErrSize = fmt.Errorf("incorrect size") ErrBytesLength = fmt.Errorf("bytes array does not have the correct length") ErrVectorLength = fmt.Errorf("vector does not have the correct length") ErrListTooBig = fmt.Errorf("list length is higher than max value") ErrEmptyBitlist = fmt.Errorf("bitlist is empty") ErrInvalidVariableOffset = fmt.Errorf("invalid ssz encoding. first variable element offset indexes into fixed value data") )
Functions ¶
This section is empty.
Types ¶
type DynSsz ¶
func NewDynSsz ¶
NewDynSsz creates a new instance of the DynSsz encoder/decoder. The 'specs' map contains dynamic properties and configurations that will be applied during SSZ serialization and deserialization processes. This allows for flexible and dynamic handling of SSZ encoding/decoding based on the given specifications, making it suitable for various Ethereum presets and custom scenarios. Returns a pointer to the newly created DynSsz instance, ready for use in serializing and deserializing operations.
func (*DynSsz) MarshalSSZ ¶
MarshalSSZ serializes the given source into its SSZ (Simple Serialize) representation. It dynamically handles the serialization of types, including those with dynamic field sizes, by leveraging reflection at runtime. This method integrates with fastssz for types without dynamic specifications, optimizing performance. It returns the serialized data as a byte slice, or an error if serialization fails.
func (*DynSsz) MarshalSSZTo ¶
MarshalSSZTo serializes the given source into its SSZ (Simple Serialize) representation and writes the output to the provided buffer. This method allows direct control over the serialization output buffer, allowing optimizations like buffer reuse. The 'source' parameter is the structure to be serialized, and 'buf' is the pre-allocated slice where the serialized data will be written. It dynamically handles serialization for types with dynamic field sizes, seamlessly integrating with fastssz when possible. Returns the updated buffer containing the serialized data and an error if serialization fails.
func (*DynSsz) SizeSSZ ¶
SizeSSZ calculates the size of the given source object when serialized using SSZ encoding. This function is useful for pre-determining the amount of space needed to serialize a given source object. The 'source' parameter can be any Go value. It dynamically evaluates the size, accommodating types with dynamic field sizes efficiently. Returns the calculated size as an int and an error if the process fails.
func (*DynSsz) UnmarshalSSZ ¶
UnmarshalSSZ decodes the given SSZ-encoded data into the target object. The 'ssz' byte slice contains the SSZ-encoded data, and 'target' is a pointer to the Go value that will hold the decoded data. This method dynamically handles the decoding, accommodating for types with dynamic field sizes. It seamlessly integrates with fastssz for types without dynamic specifications to ensure efficient decoding. Returns an error if decoding fails or if the provided ssz data has not been fully used for decoding.