Documentation
¶
Index ¶
- func GetGeneralizedIndexFromPath(info *SszInfo, path Path) (uint64, error)
- func PopulateVariableLengthInfo(sszInfo *SszInfo, value reflect.Value) error
- type Path
- type PathElement
- type SSZDimension
- type SSZObject
- type SSZType
- type SszInfo
- func (info *SszInfo) BitlistInfo() (*bitlistInfo, error)
- func (info *SszInfo) BitvectorInfo() (*bitvectorInfo, error)
- func (info *SszInfo) ContainerInfo() (*containerInfo, error)
- func (info *SszInfo) HashTreeRoot() ([32]byte, error)
- func (info *SszInfo) ListInfo() (*listInfo, error)
- func (info *SszInfo) Print() string
- func (info *SszInfo) Size() uint64
- func (info *SszInfo) String() string
- func (info *SszInfo) VectorInfo() (*vectorInfo, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetGeneralizedIndexFromPath ¶
GetGeneralizedIndexFromPath calculates the generalized index for a given path. To calculate the generalized index, two inputs are needed: 1. The sszInfo of the root object, to be able to navigate the SSZ structure 2. The path to the field (e.g., "field_a.field_b[3].field_c") It walks the path step by step, updating the generalized index at each step.
func PopulateVariableLengthInfo ¶
PopulateVariableLengthInfo populates runtime information for SSZ fields of variable-sized types. This function updates the SszInfo structure with actual lengths and offsets that can only be determined at runtime for variable-sized items like Lists and variable-sized Container fields.
Types ¶
type Path ¶
type Path struct {
// If true, the path is querying for the length of the final element in Elements field
Length bool
// Sequence of path elements representing the navigation through the SSZ structure
Elements []PathElement
}
Path represents the entire path structure for SSZ-QL queries. It consists of multiple PathElements and a flag indicating if the path is querying for length.
func ParsePath ¶
ParsePath parses a raw path string into a slice of PathElements. note: field names are stored in snake case format. rawPath has to be provided in snake case. 1. Supports dot notation for field access (e.g., "field1.field2"). 2. Supports array indexing using square brackets (e.g., "array_field[0]"). 3. Supports length access using len() notation (e.g., "len(array_field)"). 4. Handles leading dots and validates path format.
type PathElement ¶
PathElement represents a single element in a path.
type SSZDimension ¶
type SSZDimension struct {
// contains filtered or unexported fields
}
SSZDimension holds parsed SSZ tag information for current dimension. Mutually exclusive fields indicate whether the dimension is a vector or a list.
func ParseSSZTag ¶
ParseSSZTag parses SSZ-specific tags (like `ssz-max` and `ssz-size`) and returns the first dimension and the remaining SSZ tags. This function validates the tags and returns an error if they are malformed.
func (*SSZDimension) GetListLimit ¶
func (d *SSZDimension) GetListLimit() (uint64, error)
GetListLimit returns the limit for a list in current dimension
func (*SSZDimension) GetVectorLength ¶
func (d *SSZDimension) GetVectorLength() (uint64, error)
GetVectorLength returns the length for a vector in current dimension
func (*SSZDimension) IsList ¶
func (d *SSZDimension) IsList() bool
IsList returns true if this dimension represents a list.
func (*SSZDimension) IsVector ¶
func (d *SSZDimension) IsVector() bool
IsVector returns true if this dimension represents a vector.
type SSZType ¶
type SSZType int
SSZType represents the type supported by SSZ. https://github.com/ethereum/consensus-specs/blob/master/ssz/simple-serialize.md#typing
type SszInfo ¶
type SszInfo struct {
// contains filtered or unexported fields
}
SszInfo holds the all necessary data for analyzing SSZ data types.
func AnalyzeObject ¶
AnalyzeObject analyzes given object and returns its SSZ information.
func CalculateOffsetAndLength ¶
CalculateOffsetAndLength calculates the offset and length of a given path within the SSZ object. By walking the given path, it accumulates the offsets based on SszInfo.
func (*SszInfo) BitlistInfo ¶
func (*SszInfo) BitvectorInfo ¶
func (*SszInfo) ContainerInfo ¶
func (*SszInfo) HashTreeRoot ¶
HashTreeRoot calls the HashTreeRoot method on the stored interface if it implements SSZObject. Returns the 32-byte hash tree root or an error if the interface doesn't support hashing.
func (*SszInfo) Print ¶
Print returns a string representation of the SszInfo, which is useful for debugging.
func (*SszInfo) String ¶
String implements the Stringer interface for SszInfo. This follows the notation used in the consensus specs.