blockutil

package
v2.0.6-rc0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockTimeCalculator

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

BlockTimeCalculator calculates block time of a given height.

func NewBlockTimeCalculator

func NewBlockTimeCalculator(getBlockInterval getBlockIntervalFn, getTipHeight getTipHeightFn, getHistoryBlockTime getHistoryblockTimeFn) (*BlockTimeCalculator, error)

NewBlockTimeCalculator creates a new BlockTimeCalculator.

func (*BlockTimeCalculator) CalculateBlockTime

func (btc *BlockTimeCalculator) CalculateBlockTime(height uint64) (time.Time, error)

CalculateBlockTime returns the block time of the given height. If the height is in the future, it will predict the block time according to the tip block time and interval. If the height is in the past, it will get the block time from indexer.

Jump to

Keyboard shortcuts

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