utils

package
v0.0.0-...-1f8a15b Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: GPL-3.0 Imports: 12 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, 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 GetCurrentSlotOverTime

func GetCurrentSlotOverTime(genesisTime uint64, secondsPerSlot uint64) uint64

compute current slot.

func GetSlotTime

func GetSlotTime(genesisTime uint64, secondsPerSlot uint64, slot uint64) time.Time

compute time of slot.

func IntegerSquareRoot

func IntegerSquareRoot(n uint64) uint64

func IntersectionOfSortedSets

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

func IsPowerOf2

func IsPowerOf2(n uint64) bool

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 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 ReadZSTD

func ReadZSTD(r io.Reader, out []byte) (int, error)

func Sha256

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

General purpose Sha256

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 OptimizedSha256NotThreadSafe

func OptimizedSha256NotThreadSafe() HashFunc

Optimized Sha256, avoid pool.put/pool.get, meant for intensive operations. this version is not thread safe

Jump to

Keyboard shortcuts

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