Documentation ¶
Index ¶
- Constants
- Variables
- type Broker
- type Builtin
- type Config
- type Engine
- func (e *Engine) BroadcastData(ctx context.Context, data OracleData) error
- func (e *Engine) HasMatch(data OracleData) (bool, error)
- func (e *Engine) ListensToSigners(data OracleData) bool
- func (e *Engine) Subscribe(ctx context.Context, spec OracleSpec, cb OnMatchedOracleData) (SubscriptionID, Unsubscriber)
- func (e *Engine) Unsubscribe(ctx context.Context, id SubscriptionID)
- type OnMatchedOracleData
- type OracleData
- func (d OracleData) Debug() []zap.Field
- func (d OracleData) FromInternalOracle() bool
- func (d OracleData) GetBoolean(propertyName string) (bool, error)
- func (d OracleData) GetDecimal(propertyName string) (num.Decimal, error)
- func (d OracleData) GetInteger(propertyName string) (*num.Int, error)
- func (d OracleData) GetString(propertyName string) (string, error)
- func (d OracleData) GetTimestamp(propertyName string) (int64, error)
- func (d OracleData) GetUint(name string) (*num.Uint, error)
- type OracleSpec
- type OracleSpecID
- type OracleSpecPredicate
- type OracleSubscriptionPredicate
- type SubscriptionID
- type TimeService
- type Unsubscriber
Constants ¶
const ( BuiltinOraclePrefix = "vegaprotocol.builtin" BuiltinOracleTimestamp = BuiltinOraclePrefix + ".timestamp" )
Variables ¶
var ( // ErrMissingSigners is returned when the datapb.OracleSpec is missing // its signers. ErrMissingSigners = errors.New("signers are required") // ErrAtLeastOneFilterIsRequired is returned when the datapb.OracleSpec // has no expected properties nor filters. At least one of these should be // defined. ErrAtLeastOneFilterIsRequired = errors.New("at least one filter is required") // ErrInvalidTimestamp is returned when the timestamp has a negative value // which may happen in case of unsigned integer overflow. ErrInvalidTimestamp = errors.New("invalid timestamp") // ErrMissingPropertyKey is returned when a property key is undefined. ErrMissingPropertyKey = errors.New("a property key is required") // ErrMissingPropertyName is returned when a property as no name. ErrMissingPropertyName = errors.New("a property name is required") // ErrInvalidPropertyKey is returned if validation finds a reserved Vega property key. ErrInvalidPropertyKey = errors.New("property key is reserved") )
Functions ¶
This section is empty.
Types ¶
type Builtin ¶
type Builtin struct {
// contains filtered or unexported fields
}
func NewBuiltinOracle ¶
func NewBuiltinOracle(engine *Engine, ts TimeService) *Builtin
type Config ¶
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 OracleData to products and risk models interested in it.
func (*Engine) BroadcastData ¶
func (e *Engine) BroadcastData(ctx context.Context, data OracleData) error
BroadcastData broadcasts data to products and risk models that are interested in it. If no one is listening to this OracleData, it is discarded.
func (*Engine) ListensToSigners ¶ added in v0.61.0
func (e *Engine) ListensToSigners(data OracleData) bool
ListensToSigners checks if the signatures (pubkeys, ETH addresses) from provided OracleData are among the keys current OracleSpecs listen to.
func (*Engine) Subscribe ¶
func (e *Engine) Subscribe(ctx context.Context, spec OracleSpec, cb OnMatchedOracleData) (SubscriptionID, Unsubscriber)
Subscribe registers a callback for a given OracleSpec that is called when an OracleData 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 OnMatchedOracleData ¶
type OnMatchedOracleData func(ctx context.Context, data OracleData) error
OnMatchedOracleData describes the callback function used when an oracle data matches the spec.
type OracleData ¶
OracleData holds normalized data coming from an oracle.
func (OracleData) Debug ¶
func (d OracleData) Debug() []zap.Field
func (OracleData) FromInternalOracle ¶
func (d OracleData) FromInternalOracle() bool
FromInternalOracle returns true if the oracle data has been emitted by an internal oracle.
func (OracleData) GetBoolean ¶
func (d OracleData) GetBoolean(propertyName string) (bool, error)
GetBoolean converts the value associated to propertyName into a boolean.
func (OracleData) GetDecimal ¶
func (d OracleData) GetDecimal(propertyName string) (num.Decimal, error)
GetDecimal converts the value associated to propertyName into a decimal.
func (OracleData) GetInteger ¶
func (d OracleData) GetInteger(propertyName string) (*num.Int, error)
GetInteger converts the value associated to propertyName into an integer.
func (OracleData) GetString ¶
func (d OracleData) GetString(propertyName string) (string, error)
GetString returns the value associated to propertyName.
func (OracleData) GetTimestamp ¶
func (d OracleData) GetTimestamp(propertyName string) (int64, error)
GetTimestamp converts the value associated to propertyName into a timestamp.
type OracleSpec ¶
type OracleSpec struct { // OriginalSpec is the protobuf description of OracleSpec OriginalSpec *types.OracleSpec // contains filtered or unexported fields }
func NewOracleSpec ¶
func NewOracleSpec(originalSpec types.ExternalDataSourceSpec) (*OracleSpec, error)
NewOracleSpec builds an OracleSpec from a types.OracleSpec in a form that suits the processing of the filters. OracleSpec allows the existence of one and only one.
func (OracleSpec) EnsureBoundableProperty ¶
func (s OracleSpec) EnsureBoundableProperty(property string, propType datapb.PropertyKey_Type) error
func (*OracleSpec) MatchData ¶
func (s *OracleSpec) MatchData(data OracleData) (bool, error)
MatchData indicates if a given OracleData matches the spec or not.
func (*OracleSpec) MatchSigners ¶ added in v0.61.0
func (s *OracleSpec) MatchSigners(data OracleData) bool
MatchSigners tries to match the public keys from the provided OracleData object with the ones present in the Spec.
type OracleSpecID ¶
type OracleSpecID string
type OracleSpecPredicate ¶
type OracleSpecPredicate func(spec OracleSpec) (bool, error)
OracleSpecPredicate describes the predicate used to filter the subscribers. When returning true, all the subscribers associated to the matching OracleSpec are collected. The order between specs and subscribers is preserved.
type OracleSubscriptionPredicate ¶
type OracleSubscriptionPredicate func(spec OracleSpec) bool
OracleSubscriptionPredicate describes the predicate used to check if any of the currently existing subscriptions expects the public keys inside the incoming OracleSpec object.
type SubscriptionID ¶
type SubscriptionID uint64
SubscriptionID is a unique identifier referencing the subscription of an OnMatchedOracleData to an OracleSpec.
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.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |