Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockMeter ¶
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.