utils

package
v0.0.0-...-92d349b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 15, 2023 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bytes4ToUint32

func Bytes4ToUint32(bytes4 [4]byte) uint32

func BytesToBytes4

func BytesToBytes4(b []byte) (ret [4]byte)

func CompressSnappy

func CompressSnappy(data []byte) []byte

func DecodeSSZSnappy

func DecodeSSZSnappy(dst ssz.Unmarshaler, src []byte) error

func DecodeSSZSnappyWithVersion

func DecodeSSZSnappyWithVersion(dst ssz.Unmarshaler, src []byte, version int) error

func DecompressSnappy

func DecompressSnappy(data []byte) ([]byte, error)

func EncodeSSZSnappy

func EncodeSSZSnappy(data ssz.Marshaler) ([]byte, error)

func GetBitlistLength

func GetBitlistLength(b []byte) int

getBitlistLength return the amount of bits in given bitlist.

func GetCurrentEpoch

func GetCurrentEpoch(genesisTime uint64, secondsPerSlot uint64, slotsPerEpoch uint64) uint64

compute current epoch.

func GetCurrentSlot

func GetCurrentSlot(genesisTime uint64, secondsPerSlot uint64) uint64

compute current slot.

func IntegerSquareRoot

func IntegerSquareRoot(n uint64) uint64

func IntersectionOfSortedSets

func IntersectionOfSortedSets(v1, v2 []uint64) []uint64

func IsPowerOf2

func IsPowerOf2(n uint64) bool

func IsSliceSortedSet

func IsSliceSortedSet(vals []uint64) bool

Check if it is sorted and check if there are duplicates. O(N) complexity.

func IsValidMerkleBranch

func IsValidMerkleBranch(leaf libcommon.Hash, branch []libcommon.Hash, depth uint64, index uint64, root [32]byte) bool

Check if leaf at index verifies against the Merkle root and branch

func Keccak256

func Keccak256(data []byte, extras ...[]byte) [32]byte

General purpose Keccak256

func Max64

func Max64(a, b uint64) uint64

func Min64

func Min64(a, b uint64) uint64

func PowerOf2

func PowerOf2(n uint64) uint64

func PreparateRootsForHashing

func PreparateRootsForHashing(roots []libcommon.Hash) [][32]byte

func SlotToPeriod

func SlotToPeriod(slot uint64) uint64

compute current slot.

func Uint32ToBytes4

func Uint32ToBytes4(n uint32) (ret [4]byte)

func Uint64ToLE

func Uint64ToLE(i uint64) []byte

Types

type HashFunc

type HashFunc func(data []byte, extras ...[]byte) [32]byte

func OptimizedKeccak256

func OptimizedKeccak256() HashFunc

Optimized Keccak256, avoid pool.put/pool.get, meant for intensive operations.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL