ticker

package
v0.41.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 27, 2024 License: GPL-3.0 Imports: 2 Imported by: 0

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`.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL