Documentation
¶
Index ¶
- Constants
- func BigEqual(a, b *big.Int) bool
- func BigEqualUint64(a *big.Int, b uint64) bool
- func BigLessOrEqualUint64(a *big.Int, b uint64) bool
- func BigNumEqual(x, y *big.Int) bool
- func BytesToHashSlice(b []byte) []common.Hash
- func ComputeHash256(data []byte) []byte
- func ComputeHash256Array(data []byte) interfaces.ID
- func ConvertToChainContext(ctx *consensus.Context) *iface.ChainContext
- func HashSliceToBytes(hashes []common.Hash) []byte
- func IncrOne(bytes []byte)
- func IsBlockForked(s, head *big.Int) bool
- func IsTimestampForked(s *uint64, head uint64) bool
- func NewLRUCache[K comparable, V any](capacity int) interfaces.Cacher[K, V]
- func NewMockableClock() interfaces.MockableTimer
- func NewSet[T comparable](capacity ...int) interfaces.GenericSet[T]
- func NewUint64(val uint64) *uint64
- func TestChainContext() *iface.ChainContext
- func TestConsensusContext() *consensus.Context
- func TimeToNewUint64(time time.Time) *uint64
- func Uint64PtrEqual(x, y *uint64) bool
- func Uint64ToTime(val *uint64) time.Time
- type AddressRange
- type BoundedWorkers
- type EmptyCache
- type LRUCache
- type MeteredCache
- func (mc *MeteredCache) Del(k []byte)
- func (mc *MeteredCache) Get(dst, k []byte) []byte
- func (mc *MeteredCache) GetBig(dst, k []byte) []byte
- func (mc *MeteredCache) Has(k []byte) bool
- func (mc *MeteredCache) HasGet(dst, k []byte) ([]byte, bool)
- func (mc *MeteredCache) Set(k, v []byte)
- func (mc *MeteredCache) SetBig(k, v []byte)
- type MockableClock
- type Set
- type TestValidatorState
- func (tvs *TestValidatorState) GetCurrentHeight(ctx context.Context) (uint64, error)
- func (tvs *TestValidatorState) GetCurrentValidatorSet(ctx context.Context, subnetID ids.ID) (map[ids.ID]*validators.GetCurrentValidatorOutput, uint64, error)
- func (tvs *TestValidatorState) GetMinimumHeight(ctx context.Context) (uint64, error)
- func (tvs *TestValidatorState) GetSubnetID(ctx context.Context, chainID ids.ID) (ids.ID, error)
- func (tvs *TestValidatorState) GetValidatorSet(ctx context.Context, height uint64, subnetID ids.ID) (map[ids.NodeID]*validators.GetValidatorOutput, error)
Constants ¶
const ( Wei = 1 GWei = 1_000_000_000 * Wei Ether = 1_000_000_000 * GWei )
Variables ¶
This section is empty.
Functions ¶
func BigEqualUint64 ¶
BigEqualUint64 returns true if a is equal to b. If a is nil or not a uint64, it returns false.
func BigLessOrEqualUint64 ¶
BigLessOrEqualUint64 returns true if a is less than or equal to b. If a is nil or not a uint64, it returns false.
func BigNumEqual ¶
BigNumEqual returns true if x and y are equivalent ie. both nil or both contain the same value.
func BytesToHashSlice ¶
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 ComputeHash256 ¶ added in v0.8.0
ComputeHash256 computes SHA256 hash and returns it as bytes
func ComputeHash256Array ¶ added in v0.8.0
func ComputeHash256Array(data []byte) interfaces.ID
ComputeHash256Array computes SHA256 hash and returns it as an ID
func ConvertToChainContext ¶ added in v0.8.0
func ConvertToChainContext(ctx *consensus.Context) *iface.ChainContext
ConvertToChainContext converts a consensus.Context to iface.ChainContext
func HashSliceToBytes ¶
HashSliceToBytes serializes a []common.Hash into a tightly packed byte array.
func IsBlockForked ¶
IsBlockForked returns whether a fork scheduled at block s is active at the given head block. Whilst this method is the same as isTimestampForked, they are explicitly separate for clearer reading.
func IsTimestampForked ¶
IsTimestampForked returns whether a fork scheduled at timestamp s is active at the given head timestamp.
func NewLRUCache ¶ added in v0.8.0
func NewLRUCache[K comparable, V any](capacity int) interfaces.Cacher[K, V]
NewLRUCache creates a new LRU cache with the specified capacity
func NewMockableClock ¶ added in v0.8.0
func NewMockableClock() interfaces.MockableTimer
NewMockableClock creates a new mockable clock
func NewSet ¶ added in v0.8.0
func NewSet[T comparable](capacity ...int) interfaces.GenericSet[T]
NewSet creates a new set with optional initial capacity
func TestChainContext ¶ added in v0.8.0
func TestChainContext() *iface.ChainContext
TestChainContext returns a test ChainContext
func TestConsensusContext ¶ added in v0.7.10
func TimeToNewUint64 ¶
func Uint64PtrEqual ¶
Uint64PtrEqual returns true if x and y pointers are equivalent ie. both nil or both contain the same value.
func Uint64ToTime ¶
Types ¶
type AddressRange ¶
AddressRange represents a continuous range of addresses
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 EmptyCache ¶ added in v0.8.0
type EmptyCache[K comparable, V any] struct{}
EmptyCache is a cache that never stores anything
func (*EmptyCache[K, V]) Evict ¶ added in v0.8.0
func (e *EmptyCache[K, V]) Evict(key K)
Evict does nothing
func (*EmptyCache[K, V]) Flush ¶ added in v0.8.0
func (e *EmptyCache[K, V]) Flush()
Flush does nothing
func (*EmptyCache[K, V]) Get ¶ added in v0.8.0
func (e *EmptyCache[K, V]) Get(key K) (V, bool)
Get always returns false
func (*EmptyCache[K, V]) Len ¶ added in v0.8.0
func (e *EmptyCache[K, V]) Len() int
Len always returns 0
func (*EmptyCache[K, V]) Put ¶ added in v0.8.0
func (e *EmptyCache[K, V]) Put(key K, value V)
Put does nothing
type LRUCache ¶ added in v0.8.0
type LRUCache[K comparable, V any] struct { // contains filtered or unexported fields }
LRUCache implements an LRU cache using a simple map with a fixed size
func (*LRUCache[K, V]) Evict ¶ added in v0.8.0
func (c *LRUCache[K, V]) Evict(key K)
Evict removes a key from the cache
func (*LRUCache[K, V]) Flush ¶ added in v0.8.0
func (c *LRUCache[K, V]) Flush()
Flush clears the cache
type MeteredCache ¶
MeteredCache wraps *fastcache.Cache and periodically pulls stats from it.
func NewMeteredCache ¶
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 ¶
func (mc *MeteredCache) Del(k []byte)
func (*MeteredCache) Get ¶
func (mc *MeteredCache) Get(dst, k []byte) []byte
func (*MeteredCache) GetBig ¶
func (mc *MeteredCache) GetBig(dst, k []byte) []byte
func (*MeteredCache) Has ¶
func (mc *MeteredCache) Has(k []byte) bool
func (*MeteredCache) Set ¶
func (mc *MeteredCache) Set(k, v []byte)
func (*MeteredCache) SetBig ¶
func (mc *MeteredCache) SetBig(k, v []byte)
type MockableClock ¶ added in v0.8.0
type MockableClock struct {
// contains filtered or unexported fields
}
MockableClock implements interfaces.MockableTimer
func (*MockableClock) Advance ¶ added in v0.8.0
func (c *MockableClock) Advance(d time.Duration)
Advance advances the time by duration
func (*MockableClock) Set ¶ added in v0.8.0
func (c *MockableClock) Set(t time.Time)
Set sets the current time
func (*MockableClock) Time ¶ added in v0.8.0
func (c *MockableClock) Time() time.Time
Time returns the current time
type Set ¶ added in v0.8.0
type Set[T comparable] struct { // contains filtered or unexported fields }
Set implements a generic set data structure
type TestValidatorState ¶ added in v0.8.0
type TestValidatorState struct {
GetMinimumHeightF func(context.Context) (uint64, error)
GetCurrentHeightF func(context.Context) (uint64, error)
GetSubnetIDF func(context.Context, ids.ID) (ids.ID, error)
GetValidatorSetF func(context.Context, uint64, ids.ID) (map[ids.NodeID]*validators.GetValidatorOutput, error)
GetCurrentValidatorSetF func(context.Context, ids.ID) (map[ids.ID]*validators.GetCurrentValidatorOutput, uint64, error)
}
TestValidatorState is a test implementation of validator state
func NewTestValidatorState ¶
func NewTestValidatorState() *TestValidatorState
func (*TestValidatorState) GetCurrentHeight ¶ added in v0.8.0
func (tvs *TestValidatorState) GetCurrentHeight(ctx context.Context) (uint64, error)
func (*TestValidatorState) GetCurrentValidatorSet ¶ added in v0.8.0
func (tvs *TestValidatorState) GetCurrentValidatorSet(ctx context.Context, subnetID ids.ID) (map[ids.ID]*validators.GetCurrentValidatorOutput, uint64, error)
func (*TestValidatorState) GetMinimumHeight ¶ added in v0.8.0
func (tvs *TestValidatorState) GetMinimumHeight(ctx context.Context) (uint64, error)
func (*TestValidatorState) GetSubnetID ¶ added in v0.8.0
func (*TestValidatorState) GetValidatorSet ¶ added in v0.8.0
func (tvs *TestValidatorState) GetValidatorSet(ctx context.Context, height uint64, subnetID ids.ID) (map[ids.NodeID]*validators.GetValidatorOutput, error)