datafeeds

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2025 License: LGPL-3.0, MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDecimals

func GetDecimals(dataType uint8) (uint8, bool)

GetDecimals returns the number of decimals for the fe7], derived from the data type Returns false if the data type is not a number

func GetSchema

func GetSchema(typ string, internalType string, components []abi.ArgumentMarshaling) abi.Arguments

func NewEVMTestReport

func NewEVMTestReport(t *testing.T, ccip bool) []byte

func NewFeedUpdated

func NewFeedUpdated(
	m *wt.WriteConfirmed,
	feedID FeedID,
	observationsTimestamp uint32,
	benchmarkPrice *big.Int,
	bundle []byte,
	report []byte,
	includeTxInfo bool,
) *df.FeedUpdated

newdf.FeedUpdated creates a df.FeedUpdated from the given common parameters. If includeTxInfo is true, TxSender and TxReceiver are set.

func ToBenchmarkVal

func ToBenchmarkVal(feedID FeedID, val *big.Int) float64

ToBenchmarkVal returns the benchmark i192 on-chain value decoded as an double (float64), scaled by number of decimals (e.g., 1e-18) Where the number of decimals is extracted from the feed ID.

This is the largest type Prometheus supports, and this conversion can overflow but so far was sufficient for most use-cases. For big numbers, benchmark bytes should be used instead.

Returns `math.NaN()` if report data type not a number, or `+/-Inf` if number doesn't fit in double.

Types

type CCIPFeedReport

type CCIPFeedReport struct {
	FeedID    [32]byte
	Price     *big.Int
	Timestamp uint32
}

type CCIPReports

type CCIPReports = []CCIPFeedReport

type FeedID

type FeedID [32]byte

FeedID represents a 32-byte feed ID

func NewFeedID

func NewFeedID(feedID [32]byte) FeedID

NewFeedID creates a FeedID from a 32-byte array

func NewFeedIDFromHex

func NewFeedIDFromHex(feedID string) (FeedID, error)

NewFeedIDFromHex creates a FeedID from a hex string

func (FeedID) GetDataType

func (id FeedID) GetDataType() uint8

GetDecimals returns the number of decimals for the feed, derived from the feedID

[DF2.0 | Data ID Final Specification](https://docs.google.com/document/d/13ciwTx8lSUfyz1IdETwpxlIVSn1lwYzGtzOBBTpl5Vg/edit?usp=sharing) Byte 7: Data Type - 256 options

  • Given the variety of buckets, a data type for the buckets will be useful for correct parsing
  • 0x00 = Boolean
  • 0x01= String
  • 0x02 = Address
  • 0x03 = Bytes
  • 0x04 = Bundle (Encoded Struct)
  • 0x05-0x1F reserved
  • 0x20 = Decimal0 (Integer)
  • 0x21 = Decimal1 (Float w/ 1 decimal place)
  • 0x28 = Decimal8
  • 0x32 = Decimal18
  • 0x60 = Decimal64
  • 0x61-0xFF reserved

func (FeedID) GetReportType

func (id FeedID) GetReportType() uint8

GetReportType returns the report type sourced from the feedID

[DF2.0 | Data ID Final Specification](https://docs.google.com/document/d/13ciwTx8lSUfyz1IdETwpxlIVSn1lwYzGtzOBBTpl5Vg/edit?usp=sharing) Byte 0: ID Format - 256 options (base case)

  • Incrementing from 0
  • 0x00 = current Data Streams format
  • 0x01 = this format
  • 0x02 = PoR self-serve SA team allocated IDs (15 bytes)
  • 0x03 = PoR from feeds team
  • 0xFF can extend ID format to subsequent bytes, so 0xFF00 is first, then 0xFF01, etc.

func (FeedID) String

func (id FeedID) String() string

String returns the FeedID as a 0x prefixed hex string

type FeedReport

type FeedReport struct {
	FeedID    [32]byte
	Timestamp uint32
	Price     *big.Int // *big.Int is used because go-ethereum converts large uints to *big.Int.
}

type PORReport

type PORReport struct {
	DataID    [32]byte
	Timestamp uint32
	Bundle    []byte
}

type PORReports

type PORReports = []PORReport

type Processor

type Processor struct {
	// contains filtered or unexported fields
}

EVM POR specific processor decodes writes as 'data-feeds.registry.FeedUpdated' messages + metrics

func NewProcessor

func NewProcessor(metrics *df.Metrics, emitter beholder.ProtoEmitter, schema abi.Arguments, decodeReport func(*wt.WriteConfirmed, []byte, abi.Arguments) ([]*df.FeedUpdated, error)) *Processor

func (*Processor) DecodeAsFeedUpdated

func (p *Processor) DecodeAsFeedUpdated(m *wt.WriteConfirmed) ([]*df.FeedUpdated, error)

func (*Processor) Process

func (p *Processor) Process(ctx context.Context, m proto.Message, attrKVs ...any) error

type Reports

type Reports = []FeedReport

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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