oracle

package
v0.0.0-...-decf009 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2023 License: ISC Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Oracle

type Oracle struct {
	PriceRecords []*PriceRecord
	URLPool      []string
	PublicKeys   []string
}

Oracle represents a collection of price records and associated metadata.

func NewOracle

func NewOracle(urlPool []string, publicKeys []string) *Oracle

NewOracle creates a new instance of Oracle.

func (*Oracle) FetchPrices

func (o *Oracle) FetchPrices() error

FetchPrices updates the PriceRecords by fetching new data. This method should contain the logic to periodically fetch prices.

type PriceRecord

type PriceRecord struct {
	KSH       float64
	KRV       float64
	KUSD      float64
	KSHMA     float64
	KRVMA     float64
	KUSDMA    float64
	Timestamp int64
}

PriceRecord stores the prices and moving averages of KSH, KRV, and KUSD against USDT.

func FromBytes

func FromBytes(data []byte) (*PriceRecord, error)

FromBytes deserializes a byte slice into a PriceRecord.

func (*PriceRecord) ToBytes

func (pr *PriceRecord) ToBytes() ([]byte, error)

ToBytes serializes the PriceRecord into a byte slice.

Jump to

Keyboard shortcuts

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