feed

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2023 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const LoggerTag = "FEED"

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// DataModels is a list of data models handled by the Feed.
	DataModels []string

	// DataProvider is a data provider which is used to fetch data points.
	DataProvider datapoint.Provider

	// Signers is a list of signers used to sign data points.
	//
	// If none of the provided signers can sign the data point, it will be
	// skipped.
	Signers []datapoint.Signer

	// Hooks is a list of hooks that will be called before broadcasting
	// data points.
	Hooks []Hook

	// Transport is an implementation of transport used to send data points to
	// the network.
	Transport transport.Service

	// Interval describes how often data points should be sent to the network.
	Interval *timeutil.Ticker

	// Logger is a current logger interface used by the Feed.
	// If nil, null logger will be used.
	Logger log.Logger
}

Config is the configuration for the Feed.

type Feed

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

Feed is a service which periodically fetches data points and then sends them to the network using transport layer.

func New

func New(cfg Config) (*Feed, error)

New creates a new instance of the Feed.

func (*Feed) Start

func (f *Feed) Start(ctx context.Context) error

Start implements the supervisor.Service interface.

func (*Feed) Wait

func (f *Feed) Wait() <-chan error

Wait implements the supervisor.Service interface.

type Hook added in v0.16.1

type Hook interface {
	BeforeSign(ctx context.Context, dp *datapoint.Point) error
	BeforeBroadcast(ctx context.Context, dp *datapoint.Point) error
}

type TickPrecisionHook added in v0.16.1

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

TickPrecisionHook is a hook that limits the precision of the price and volume of a tick.

This is done for two reasons:

  • To decrease the size of the tick, which is broadcast to all oracles.
  • To mitigate the risk of rounding errors that might occur during generating a hash for signature verification if the precision is too high. This isn't a concern as long as signatures are verified using the same library that calculated the hash. However, discrepancies may arise if a different library is used.

func NewTickPrecisionHook added in v0.16.1

func NewTickPrecisionHook(maxPricePrec, maxVolumePrec uint8) *TickPrecisionHook

NewTickPrecisionHook creates a new TickPrecisionHook with the specified price and volume precisions.

func (*TickPrecisionHook) BeforeBroadcast added in v0.16.1

func (t *TickPrecisionHook) BeforeBroadcast(_ context.Context, _ *datapoint.Point) error

BeforeBroadcast implements the Hook interface.

func (*TickPrecisionHook) BeforeSign added in v0.16.1

func (t *TickPrecisionHook) BeforeSign(_ context.Context, dp *datapoint.Point) error

BeforeSign implements the Hook interface.

type TickTraceHook added in v0.16.1

type TickTraceHook struct{}

TickTraceHook is a hook that adds a trace meta field, which stores the price of the tick at each origin.

The trace field is a map that associates each pair and origin with a price. This allows to easily verify by others that the broadcasted tick is accurately calculated by the feed.

func NewTickTraceHook added in v0.16.1

func NewTickTraceHook() *TickTraceHook

NewTickTraceHook creates a new TickTraceHook instance.

func (*TickTraceHook) BeforeBroadcast added in v0.16.1

func (t *TickTraceHook) BeforeBroadcast(_ context.Context, dp *datapoint.Point) error

BeforeBroadcast implements the Hook interface.

func (*TickTraceHook) BeforeSign added in v0.16.1

func (t *TickTraceHook) BeforeSign(_ context.Context, _ *datapoint.Point) error

BeforeSign implements the Hook interface.

Jump to

Keyboard shortcuts

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