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) ids.ID
- func ConvertToChainContext(ctx *quasar.Context) *commontype.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 NewUint64(val uint64) *uint64
- func TestChainContext() *commontype.ChainContext
- func TestConsensusContext() *quasar.Context
- func TimeToNewUint64(time time.Time) *uint64
- func Uint64PtrEqual(x, y *uint64) bool
- func Uint64ToTime(val *uint64) time.Time
- type AddressRange
- type BoundedWorkers
- type Cacher
- type EmptyCache
- type GenericSet
- 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 MockableTimer
- type Set
- type TestValidatorState
- func (tvs *TestValidatorState) ApplyValidatorPublicKeyDiffs(ctx context.Context, validators map[ids.NodeID]*validators.GetValidatorOutput, ...) error
- func (tvs *TestValidatorState) ApplyValidatorWeightDiffs(ctx context.Context, validators map[ids.NodeID]*validators.GetValidatorOutput, ...) error
- 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 ¶
ComputeHash256 computes SHA256 hash and returns it as bytes
func ComputeHash256Array ¶
ComputeHash256Array computes SHA256 hash and returns it as an ID
func ConvertToChainContext ¶
func ConvertToChainContext(ctx *quasar.Context) *commontype.ChainContext
ConvertToChainContext converts a quasar.Context to commontype.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 TestChainContext ¶
func TestChainContext() *commontype.ChainContext
TestChainContext returns a test ChainContext
func TestConsensusContext ¶
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 Cacher ¶
type Cacher[K comparable, V any] interface { Put(key K, value V) Get(key K) (V, bool) Evict(key K) Flush() Len() int }
Cacher is a generic cache interface
func NewLRUCache ¶
func NewLRUCache[K comparable, V any](capacity int) Cacher[K, V]
NewLRUCache creates a new LRU cache with the specified capacity
type EmptyCache ¶
type EmptyCache[K comparable, V any] struct{}
EmptyCache is a cache that never stores anything
func (*EmptyCache[K, V]) Get ¶
func (e *EmptyCache[K, V]) Get(key K) (V, bool)
Get always returns false
type GenericSet ¶
type GenericSet[T comparable] interface { Add(items ...T) Remove(item T) Contains(item T) bool Clear() Len() int List() []T }
GenericSet is a generic set interface
func NewSet ¶
func NewSet[T comparable](capacity ...int) GenericSet[T]
NewSet creates a new set with optional initial capacity
type LRUCache ¶
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 ¶
func (c *LRUCache[K, V]) Evict(key K)
Evict removes a key from 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 ¶
type MockableClock struct {
// contains filtered or unexported fields
}
MockableClock implements MockableTimer
func (*MockableClock) Advance ¶
func (c *MockableClock) Advance(d time.Duration)
Advance advances the time by duration
type MockableTimer ¶
type MockableTimer interface {
Time() time.Time
Set(time time.Time)
Advance(duration time.Duration)
}
MockableTimer is an interface for a mockable clock
func NewMockableClock ¶
func NewMockableClock() MockableTimer
NewMockableClock creates a new mockable clock
type Set ¶
type Set[T comparable] struct { // contains filtered or unexported fields }
Set implements a generic set data structure
type TestValidatorState ¶
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) ApplyValidatorPublicKeyDiffs ¶
func (tvs *TestValidatorState) ApplyValidatorPublicKeyDiffs( ctx context.Context, validators map[ids.NodeID]*validators.GetValidatorOutput, startHeight uint64, endHeight uint64, subnetID ids.ID, ) error
func (*TestValidatorState) ApplyValidatorWeightDiffs ¶
func (tvs *TestValidatorState) ApplyValidatorWeightDiffs( ctx context.Context, validators map[ids.NodeID]*validators.GetValidatorOutput, startHeight uint64, endHeight uint64, subnetID ids.ID, ) error
func (*TestValidatorState) GetCurrentHeight ¶
func (tvs *TestValidatorState) GetCurrentHeight(ctx context.Context) (uint64, error)
func (*TestValidatorState) GetCurrentValidatorSet ¶
func (tvs *TestValidatorState) GetCurrentValidatorSet(ctx context.Context, subnetID ids.ID) (map[ids.ID]*validators.GetCurrentValidatorOutput, uint64, error)
func (*TestValidatorState) GetMinimumHeight ¶
func (tvs *TestValidatorState) GetMinimumHeight(ctx context.Context) (uint64, error)
func (*TestValidatorState) GetSubnetID ¶
func (*TestValidatorState) GetValidatorSet ¶
func (tvs *TestValidatorState) GetValidatorSet(ctx context.Context, height uint64, subnetID ids.ID) (map[ids.NodeID]*validators.GetValidatorOutput, error)