Documentation ¶
Index ¶
- func ArrayToMap[T, K comparable](ts []T, kf func(T) K) map[K]T
- func ArrayToPtrMap[T, K comparable](ts []T, kf func(T) K) map[K]*T
- func CastArray[T, V any](a []V) ([]T, error)
- func Hex20ToBytes20(str string) (result [20]byte, err error)
- func Join(errs ...error) error
- func Keys[K comparable, V any](m map[K]V) []K
- func Map[T, V any](ins []T, f func(T) V) []V
- func NewRandomizedTicker(interval time.Duration, randomDelta time.Duration) <-chan time.Time
- func PadHexString(value string, length int) (string, error)
- func TransactionHexToBytes32(address string) (result [32]byte, err error)
- func TransformSignatureRSVtoVRS(rsv []byte) (vrs []byte)
- func TransformSignatureVRStoRSV(vrs []byte) (rsv []byte)
- func UInt16ToHex(value uint16) string
- func UInt32ToHex(value uint32) string
- func UInt64ToHex(value uint64) string
- func Values[K comparable, V any](m map[K]V) []V
- type DelayedQueueManager
- type EpochTicker
- type EpochTimingConfig
- type FixedTimeProvider
- type QueueProcessorFunc
- type RealTimeProvider
- type RewardEpochConfig
- type TimeProvider
- type Timestamp
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ArrayToMap ¶
func ArrayToMap[T, K comparable](ts []T, kf func(T) K) map[K]T
Create a map from array with kf providing keys, values are array elements
func ArrayToPtrMap ¶
func ArrayToPtrMap[T, K comparable](ts []T, kf func(T) K) map[K]*T
Create a map from array with kf providing keys, values are pointers to array elements
func Hex20ToBytes20 ¶
func Keys ¶
func Keys[K comparable, V any](m map[K]V) []K
func NewRandomizedTicker ¶
func PadHexString ¶
Checks if the string is a valid hex string and pad it to the given length (even number)
func TransactionHexToBytes32 ¶
func TransformSignatureRSVtoVRS ¶
Transform signature transforms [R || S || V - 27] to [V || R || S]. No checks are performed, we assume that signature array has length 65
func TransformSignatureVRStoRSV ¶
Transform signature to be used by go-ethereum crypto.SigToPub: transforms [V || R || S] to [R || S || V - 27] No checks are performed, we assume that signature array has length 65
func UInt16ToHex ¶
func UInt32ToHex ¶
func UInt64ToHex ¶
func Values ¶
func Values[K comparable, V any](m map[K]V) []V
Types ¶
type DelayedQueueManager ¶
func NewDelayedQueueManager ¶
func NewDelayedQueueManager[T any](processor QueueProcessorFunc[T]) *DelayedQueueManager[T]
func (*DelayedQueueManager[T]) Add ¶
func (l *DelayedQueueManager[T]) Add(t time.Time, item T)
func (*DelayedQueueManager[T]) Get ¶
func (l *DelayedQueueManager[T]) Get(t time.Time) []T
type EpochTicker ¶
type EpochTicker struct { Epoch *EpochTimingConfig // C is the channel on which the epoch index is sent C <-chan int64 // contains filtered or unexported fields }
func NewEpochTicker ¶
func NewEpochTicker(epoch *EpochTimingConfig) *EpochTicker
NewEpochTicker creates a ticker that sends the epoch index on the channel C at the start of the epoch
type EpochTimingConfig ¶
type EpochTimingConfig struct { Start time.Time // start of the epoch with index 0 Period time.Duration // length of one epoch }
func NewEpochConfig ¶
func NewEpochConfig(start time.Time, duration time.Duration) *EpochTimingConfig
func (EpochTimingConfig) EndTime ¶
func (e EpochTimingConfig) EndTime(epoch int64) time.Time
EndTime returns the end time of the epoch.
func (EpochTimingConfig) EpochIndex ¶
func (e EpochTimingConfig) EpochIndex(t time.Time) int64
EpochIndex returns returns the consecutive index of the epoch that takes place at time t.
type FixedTimeProvider ¶
func (FixedTimeProvider) Now ¶
func (f FixedTimeProvider) Now() time.Time
type QueueProcessorFunc ¶
type RealTimeProvider ¶
type RealTimeProvider struct{}
func (RealTimeProvider) Now ¶
func (RealTimeProvider) Now() time.Time
type RewardEpochConfig ¶
type RewardEpochConfig struct { Start int64 // index of the voting round in which the reward epoch with index 0 starts Period int64 // length of one reward epoch in voting rounds }
func NewRewardEpochConfig ¶
func NewRewardEpochConfig(start int64, period int64) *RewardEpochConfig
func (RewardEpochConfig) EndEpoch ¶
func (e RewardEpochConfig) EndEpoch(rewardEpoch int64) int64
EndEpoch returns the index of the voting round in which the given reward epoch is expected to end.
func (RewardEpochConfig) StartEpoch ¶
func (e RewardEpochConfig) StartEpoch(rewardEpoch int64) int64
StartEpoch returns the index of the voting round in which the given reward epoch is expected to start.