types

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PriceTimestamp

type PriceTimestamp struct {
	LastUpdateTime time.Time
	Price          uint64
}

PriceTimestamp maintains a price and its last update timestamp.

func NewPriceTimestamp

func NewPriceTimestamp() *PriceTimestamp

NewPriceTimestamp creates a new PriceTimestamp.

func (*PriceTimestamp) GetValidPrice

func (pt *PriceTimestamp) GetValidPrice(cutoffTime time.Time) (uint64, bool)

GetValidPrice returns (price, true) if the last update time is greater than or equal to the given cutoff time. Otherwise returns (0, false).

func (*PriceTimestamp) UpdatePrice

func (pt *PriceTimestamp) UpdatePrice(price uint64, newUpdateTime *time.Time) bool

UpdatePrice updates the price if the given update has a greater timestamp. Returns true if updating succeeds. Otherwise, returns false.

type Resolver

type Resolver func([]uint64) (uint64, error)

Resolver is a function type that "resolves" a slice of values to a single value. The function also returns an error if there was an error in resolving the value.

Jump to

Keyboard shortcuts

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