Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IterationHandler ¶
type IterationHandler func()
IterationHandler is a callback of a certain block advance.
type IterationsTicker ¶
type IterationsTicker struct {
// contains filtered or unexported fields
}
IterationsTicker represents a fixed tick number block timer.
It can tick the blocks and perform certain actions on block time intervals.
func NewIterationsTicker ¶
func NewIterationsTicker(totalBlocks uint64, times uint64, h IterationHandler) (*IterationsTicker, error)
NewIterationsTicker creates a new IterationsTicker.
It guaranties that a handler would be called the specified amount of times in the specified amount of blocks. After the last meaningful Tick, IterationsTicker becomes no-op timer.
Returns an error only if times is greater than totalBlocks.
func (*IterationsTicker) Tick ¶
func (ft *IterationsTicker) Tick() bool
Tick ticks one block in the IterationsTicker.
Returns `false` if the timer has finished its operations and there will be no more handler calls. Calling Tick after the returned `false` is safe, no-op and also returns `false`.