v1

package
v0.0.0-...-47b5856 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block struct {
	Num  int64
	Hash string // Hash is stringified to allow use of block as hash key. It is NOT hex and can be cast directly to []byte
	Ts   uint64
}

func NewBlock

func NewBlock(num int64, hash []byte, ts uint64) Block

func (Block) HashBytes

func (b Block) HashBytes() []byte

func (Block) Less

func (b Block) Less(b2 Block) bool

Less returns true if b1 is less than b2 by comparing in order:

  • smaller block number
  • smaller timestamp
  • largest hash

func (Block) String

func (b Block) String() string

type Observation

type Observation struct {
	BenchmarkPrice mercury.ObsResult[*big.Int]
	Bid            mercury.ObsResult[*big.Int]
	Ask            mercury.ObsResult[*big.Int]

	CurrentBlockNum       mercury.ObsResult[int64]
	CurrentBlockHash      mercury.ObsResult[[]byte]
	CurrentBlockTimestamp mercury.ObsResult[uint64]

	LatestBlocks []Block

	// MaxFinalizedBlockNumber comes from previous report when present and is
	// only observed from mercury server when previous report is nil
	MaxFinalizedBlockNumber mercury.ObsResult[int64]
}

type ReportCodec

type ReportCodec interface {
	// BuildReport Implementers may assume that there is at most one
	// ParsedAttributedObservation per observer, and that all observers are
	// valid. However, observation values, timestamps, etc... should all be
	// treated as untrusted.
	BuildReport(fields ReportFields) (ocrtypes.Report, error)

	// MaxReportLength Returns the maximum length of a report based on n, the number of oracles.
	// The output of BuildReport must respect this maximum length.
	MaxReportLength(n int) (int, error)

	// CurrentBlockNumFromReport returns the median current block number from a report
	CurrentBlockNumFromReport(types.Report) (int64, error)
}

ReportCodec All functions on ReportCodec should be pure and thread-safe. Be careful validating and parsing any data passed.

type ReportFields

type ReportFields struct {
	Timestamp             uint32
	BenchmarkPrice        *big.Int
	Bid                   *big.Int
	Ask                   *big.Int
	CurrentBlockNum       int64
	CurrentBlockHash      []byte
	ValidFromBlockNum     int64
	CurrentBlockTimestamp uint64
}

Jump to

Keyboard shortcuts

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