timer
Package timer
import "github.com/luxfi/node/utils/timer"Functions
EstimateETA
func EstimateETA(startTime time.Time, progress, end uint64) time.DurationEstimateETA attempts to estimate the remaining time for a job to finish given the [startTime] and it's current progress.
ProgressFromHash
func ProgressFromHash(b []byte) uint64ProgressFromHash returns the progress out of MaxUint64 assuming [b] is a key in a uniformly distributed sequence that is being iterated lexicographically.
StoppedTimer
func StoppedTimer() *time.TimerStoppedTimer returns a stopped timer so that there is no entry on the C channel (and there isn't one scheduled to be added).
This means that after calling Reset there will be no events on the channel until the timer fires (at which point there will be exactly one event sent to the channel).
It enables re-using the timer across loop iterations without needing to have the first loop iteration perform any == nil checks to initialize the first invocation.
Types
AdaptiveTimeoutConfig
AdaptiveTimeoutConfig contains the parameters provided to the adaptive timeout manager.
AdaptiveTimeoutManager
func NewAdaptiveTimeoutManager(
config *AdaptiveTimeoutConfig,
registry metric.Registry,
) (AdaptiveTimeoutManager, error)EtaTracker
EtaTracker provides exponentially weighted moving average ETA estimates
func NewEtaTracker(samples int, alpha float64) *EtaTrackerfunc (e *EtaTracker) AddSample(progress, total uint64, sampleTime time.Time) (*time.Duration, float64)func (e *EtaTracker) ETA(progress, total uint64) time.Durationfunc (e *EtaTracker) Update(progress, total uint64)Meter
Meter tracks the number of occurrences of a specified event
Timer
Timer wraps a timer object. This allows a user to specify a handler. Once specifying the handler, the dispatch thread can be called. The dispatcher will only return after calling Stop. SetTimeoutIn will result in calling the handler in the specified amount of time.
func NewStagedTimer(f func() (time.Duration, bool)) *Timerfunc NewTimer(handler func()) *Timerfunc (t *Timer) Cancel()func (t *Timer) Dispatch()func (t *Timer) SetTimeoutIn(duration time.Duration)func (t *Timer) Stop()