types

package
v0.0.0-...-a9c8dba Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2024 License: AGPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxPriceAge defines the duration in which a price update is valid for.
	MaxPriceAge = time.Duration(30_000_000_000) // 30 sec, duration uses nanoseconds.
)

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