spec

package
v0.77.8 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2024 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BuiltinPrefix      = "vegaprotocol.builtin"
	BuiltinTimestamp   = BuiltinPrefix + ".timestamp"
	BuiltinTimeTrigger = BuiltinPrefix + ".timetrigger"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Broker

type Broker interface {
	Stage(event events.Event)
	Send(event events.Event)
	SendBatch(events []events.Event)
}

Broker interface. Do not need to mock (use package broker/mock).

type Builtin

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

func NewBuiltin

func NewBuiltin(engine *Engine, ts TimeService) *Builtin

func (*Builtin) OnTick

func (b *Builtin) OnTick(ctx context.Context, t time.Time)

type Config

type Config struct {
	Level encoding.LogLevel `long:"log-level"`
}

Config represent the configuration of the oracle engine.

func NewDefaultConfig

func NewDefaultConfig() Config

NewDefaultConfig creates an instance of the package specific configuration, given a pointer to a logger instance to be used for logging within the package.

type Engine

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

Engine is responsible for broadcasting the Data to products and risk models interested in it.

func NewEngine

func NewEngine(
	log *logging.Logger,
	conf Config,
	ts TimeService,
	broker Broker,
) *Engine

NewEngine creates a new Engine.

func (*Engine) AddSpecActivationListener

func (e *Engine) AddSpecActivationListener(listener SpecActivationsListener)

func (*Engine) BroadcastData

func (e *Engine) BroadcastData(ctx context.Context, data common.Data) error

BroadcastData broadcasts data to products and risk models that are interested in it. If no one is listening to this Data, it is discarded.

func (*Engine) HasMatch

func (e *Engine) HasMatch(data common.Data) (bool, error)

func (*Engine) ListensToSigners

func (e *Engine) ListensToSigners(data common.Data) bool

ListensToSigners checks if the signatures (pubkeys, ETH addresses) from provided sourcing Data are among the keys current Specs listen to.

func (*Engine) Subscribe

func (e *Engine) Subscribe(ctx context.Context, spec Spec, cb OnMatchedData) (SubscriptionID, Unsubscriber, error)

Subscribe registers a callback for a given Spec that is called when an signedoracle Data matches the spec. It returns a SubscriptionID that is used to Unsubscribe. If cb is nil, the method panics.

func (*Engine) Unsubscribe

func (e *Engine) Unsubscribe(ctx context.Context, id SubscriptionID)

Unsubscribe unregisters the callback associated to the SubscriptionID. If the id doesn't exist, this method panics.

type OnMatchedData

type OnMatchedData func(ctx context.Context, data common.Data) error

OnMatchedData describes the callback function used when an data dource data matches the spec.

type Spec

type Spec struct {

	// OriginalSpec is the protobuf description of Spec
	OriginalSpec *datasource.Spec
	// contains filtered or unexported fields
}

func New

func New(originalSpec datasource.Spec) (*Spec, error)

New builds a new Spec from a common.Spec (currently uses one level below - common.ExternalDataSourceSpec) in a form that suits the processing of the filters. Spec allows the existence of one and only one. Currently VEGA network utilises internal triggers in the oracle function path, even though the oracles are treated as external data sources. For this reason this function checks if the provided external type of data source definition contains a key name that indicates a builtin type of logic and if the given data source definition is an internal type of data source, for more context refer to https://github.com/vegaprotocol/specs/blob/master/protocol/0048-DSRI-data_source_internal.md#13-vega-time-changed

func (Spec) EnsureBoundableProperty

func (s Spec) EnsureBoundableProperty(property string, propType datapb.PropertyKey_Type) error

func (*Spec) MatchData

func (s *Spec) MatchData(data common.Data) (bool, error)

MatchData indicates if a given Data matches the spec or not.

func (*Spec) MatchSigners

func (s *Spec) MatchSigners(data common.Data) bool

MatchSigners tries to match the public keys from the provided Data object with the ones present in the Spec.

type SpecActivationsListener

type SpecActivationsListener interface {
	OnSpecActivated(context.Context, datasource.Spec) error
	OnSpecDeactivated(context.Context, datasource.Spec)
}

The verifier and filterer need to know about new spec immediately, waiting on the event will lead to spec not found issues

type SpecID

type SpecID string

type SpecPredicate

type SpecPredicate func(spec Spec) (bool, error)

SpecPredicate describes the predicate used to filter the subscribers. When returning true, all the subscribers associated to the matching Spec are collected. The order between specs and subscribers is preserved.

type SubscriptionID

type SubscriptionID uint64

SubscriptionID is a unique identifier referencing the subscription of an OnMatchedData to a Spec.

type SubscriptionPredicate

type SubscriptionPredicate func(spec Spec) bool

SubscriptionPredicate describes the predicate used to check if any of the currently existing subscriptions expects the public keys inside the incoming Spec object.

type TimeService

type TimeService interface {
	GetTimeNow() time.Time
}

TimeService interface.

type Unsubscriber

type Unsubscriber func(context.Context, SubscriptionID)

Unsubscriber is a closure that is created at subscription step in order to provide the ability to unsubscribe at any conveninent moment.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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