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 }
type DataSource ¶
type DataSource interface { // Observe queries the data source. Returns a value or an error. Once the // context is expires, Observe may still do cheap computations and return a // result, but should return as quickly as possible. // // More details: In the current implementation, the context passed to // Observe will time out after MaxDurationObservation. However, Observe // should *not* make any assumptions about context timeout behavior. Once // the context times out, Observe should prioritize returning as quickly as // possible, but may still perform fast computations to return a result // rather than error. For example, if Observe medianizes a number of data // sources, some of which already returned a result to Observe prior to the // context's expiry, Observe might still compute their median, and return it // instead of an error. // // Important: Observe should not perform any potentially time-consuming // actions like database access, once the context passed has expired. Observe(ctx context.Context, repts types.ReportTimestamp, fetchMaxFinalizedBlockNum bool) (Observation, error) }
DataSource implementations must be thread-safe. Observe may be called by many different threads concurrently.
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(ocrtypes.Report) (int64, error) }
ReportCodec All functions on ReportCodec should be pure and thread-safe. Be careful validating and parsing any data passed.
Click to show internal directories.
Click to hide internal directories.