timer

package
v0.44.3 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockMeter

type BlockMeter func() (uint32, error)

BlockMeter calculates block time interval dynamically.

func StaticBlockMeter

func StaticBlockMeter(d uint32) BlockMeter

StaticBlockMeter returns BlockMeters that always returns (d, nil).

type BlockTickHandler

type BlockTickHandler func()

BlockTickHandler is a callback of a certain block advance.

type BlockTimer

type BlockTimer struct {
	// contains filtered or unexported fields
}

BlockTimer represents block timer.

It can tick the blocks and perform certain actions on block time intervals.

func NewBlockTimer

func NewBlockTimer(dur BlockMeter, h BlockTickHandler) *BlockTimer

NewBlockTimer creates a new BlockTimer.

Reset should be called before timer ticking.

func NewOneTickTimer

func NewOneTickTimer(dur BlockMeter, h BlockTickHandler) *BlockTimer

NewOneTickTimer creates a new BlockTimer that ticks only once.

func (*BlockTimer) Reset

func (t *BlockTimer) Reset() error

Reset resets previous ticks of the BlockTimer.

Returns BlockMeter's error upon occurrence.

func (*BlockTimer) Tick

func (t *BlockTimer) Tick(h uint32)

Tick ticks one block in the BlockTimer.

Executes all callbacks which are awaiting execution at the new block.

Jump to

Keyboard shortcuts

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