utils

package
v0.13.8-rc.6 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: GPL-3.0, LGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToHashSlice

func BytesToHashSlice(b []byte) []common.Hash

BytesToHashSlice packs [b] into a slice of hash values with zero padding to the right if the length of b is not a multiple of 32.

func HashSliceToBytes

func HashSliceToBytes(hashes []common.Hash) []byte

HashSliceToBytes serializes a []common.Hash into a tightly packed byte array.

func IncrOne

func IncrOne(bytes []byte)

IncrOne increments bytes value by one

func NewUint64 added in v0.12.3

func NewUint64(val uint64) *uint64

func TestSnowContext

func TestSnowContext() *snow.Context

func TimeToNewUint64 added in v0.12.3

func TimeToNewUint64(time time.Time) *uint64

func Uint64PtrEqual

func Uint64PtrEqual(x, y *uint64) bool

Uint64PtrEqual returns true if x and y pointers are equivalent ie. both nil or both contain the same value.

func Uint64ToTime added in v0.12.3

func Uint64ToTime(val *uint64) time.Time

Types

type AddressRange

type AddressRange struct {
	Start common.Address
	End   common.Address
}

AddressRange represents a continuous range of addresses

func (*AddressRange) Contains

func (a *AddressRange) Contains(addr common.Address) bool

Contains returns true iff [addr] is contained within the (inclusive) range of addresses defined by [a].

type BoundedWorkers

type BoundedWorkers struct {
	// contains filtered or unexported fields
}

func NewBoundedWorkers

func NewBoundedWorkers(max int) *BoundedWorkers

NewBoundedWorkers returns an instance of BoundedWorkers that will spawn up to [max] goroutines.

func (*BoundedWorkers) Execute

func (b *BoundedWorkers) Execute(f func())

Execute the given function on an existing goroutine waiting for more work, a new goroutine, or return if the context is canceled.

Execute must not be called after Wait, otherwise it might panic.

func (*BoundedWorkers) Wait

func (b *BoundedWorkers) Wait() int

Wait returns after all enqueued work finishes and all goroutines to exit. Wait returns the number of workers that were spawned during the run.

Wait can only be called after ALL calls to [Execute] have returned.

It is safe to call Wait multiple times but not safe to call [Execute] after [Wait] has been called.

type MeteredCache added in v0.11.4

type MeteredCache struct {
	*fastcache.Cache
	// contains filtered or unexported fields
}

MeteredCache wraps *fastcache.Cache and periodically pulls stats from it.

func NewMeteredCache added in v0.11.4

func NewMeteredCache(size int, namespace string, updateFrequency uint64) *MeteredCache

NewMeteredCache returns a new MeteredCache that will update stats to the provided namespace once per each [updateFrequency] operations. Note: if [updateFrequency] is passed as 0, it will be treated as 1.

func (*MeteredCache) Del added in v0.11.4

func (mc *MeteredCache) Del(k []byte)

func (*MeteredCache) Get added in v0.11.4

func (mc *MeteredCache) Get(dst, k []byte) []byte

func (*MeteredCache) GetBig added in v0.11.4

func (mc *MeteredCache) GetBig(dst, k []byte) []byte

func (*MeteredCache) Has added in v0.11.4

func (mc *MeteredCache) Has(k []byte) bool

func (*MeteredCache) HasGet added in v0.11.4

func (mc *MeteredCache) HasGet(dst, k []byte) ([]byte, bool)

func (*MeteredCache) Set added in v0.11.4

func (mc *MeteredCache) Set(k, v []byte)

func (*MeteredCache) SetBig added in v0.11.4

func (mc *MeteredCache) SetBig(k, v []byte)

Jump to

Keyboard shortcuts

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