{"modulePath":"github.com/GoPlugin/pluginV2Lib/libocr","version":"v0.0.0-20230622090102-3f0f60f3c385","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package median\n\n## Variables\n\n```go\nvar File_offchainreporting2_median_config_proto protoreflect.FileDescriptor\n```\n\n```go\nvar File_offchainreporting2_median_observation_proto protoreflect.FileDescriptor\n```\n\n## Functions\n\n```go\nfunc DecodeValue(s []byte) (*big.Int, error)\n```\nDecodes a value using 24-byte big endian two's complement representation. This function never panics.\n\n```go\nfunc Deviates(thresholdPPB uint64, old *big.Int, new *big.Int) bool\n```\n\n```go\nfunc EncodeValue(i *big.Int) ([]byte, error)\n```\nEncodes a value using 24-byte big endian two's complement representation. This function never panics.\n\n```go\nfunc MaxValue() *big.Int\n```\n2\\*\\*191-1\n\n```go\nfunc MinValue() *big.Int\n```\n\\-2\\*\\*191\n\n## Types\n\n```go\ntype DataSource interface {\n\t// Observe queries the data source. Returns a value or an error. Once the\n\t// context is expires, Observe may still do cheap computations and return a\n\t// result, but should return as quickly as possible.\n\t//\n\t// More details: In the current implementation, the context passed to\n\t// Observe will time out after MaxDurationObservation. However, Observe\n\t// should *not* make any assumptions about context timeout behavior. Once\n\t// the context times out, Observe should prioritize returning as quickly as\n\t// possible, but may still perform fast computations to return a result\n\t// rather than error. For example, if Observe medianizes a number of data\n\t// sources, some of which already returned a result to Observe prior to the\n\t// context's expiry, Observe might still compute their median, and return it\n\t// instead of an error.\n\t//\n\t// Important: Observe should not perform any potentially time-consuming\n\t// actions like database access, once the context passed has expired.\n\tObserve(context.Context, types.ReportTimestamp) (*big.Int, error)\n}\n```\nDataSource implementations must be thread-safe. Observe may be called by many different threads concurrently.\n\n```go\ntype MedianContract interface {\n\tLatestTransmissionDetails(\n\t\tctx context.Context,\n\t) (\n\t\tconfigDigest types.ConfigDigest,\n\t\tepoch uint32,\n\t\tround uint8,\n\t\tlatestAnswer *big.Int,\n\t\tlatestTimestamp time.Time,\n\t\terr error,\n\t)\n\n\t// LatestRoundRequested returns the configDigest, epoch, and round from the latest\n\t// RoundRequested event emitted by the contract. LatestRoundRequested may or may not\n\t// return a result if the latest such event was emitted in a block b such that\n\t// b.timestamp \u003c tip.timestamp - lookback.\n\t//\n\t// If no event is found, LatestRoundRequested should return zero values, not an error.\n\t// An error should only be returned if an actual error occurred during execution,\n\t// e.g. because there was an error querying the blockchain or the database.\n\t//\n\t// As an optimization, this function may also return zero values, if no\n\t// RoundRequested event has been emitted after the latest NewTransmission event.\n\tLatestRoundRequested(\n\t\tctx context.Context,\n\t\tlookback time.Duration,\n\t) (\n\t\tconfigDigest types.ConfigDigest,\n\t\tepoch uint32,\n\t\tround uint8,\n\t\terr error,\n\t)\n}\n```\n\n```go\ntype NumericalMedianConfigProto struct {\n\tAlphaReportInfinite bool   `protobuf:\"varint,1,opt,name=alpha_report_infinite,json=alphaReportInfinite,proto3\" json:\"alpha_report_infinite,omitempty\"`\n\tAlphaReportPpb      uint64 `protobuf:\"varint,2,opt,name=alpha_report_ppb,json=alphaReportPpb,proto3\" json:\"alpha_report_ppb,omitempty\"`\n\tAlphaAcceptInfinite bool   `protobuf:\"varint,3,opt,name=alpha_accept_infinite,json=alphaAcceptInfinite,proto3\" json:\"alpha_accept_infinite,omitempty\"`\n\tAlphaAcceptPpb      uint64 `protobuf:\"varint,4,opt,name=alpha_accept_ppb,json=alphaAcceptPpb,proto3\" json:\"alpha_accept_ppb,omitempty\"`\n\tDeltaCNanoseconds   uint64 `protobuf:\"varint,5,opt,name=delta_c_nanoseconds,json=deltaCNanoseconds,proto3\" json:\"delta_c_nanoseconds,omitempty\"`\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (*NumericalMedianConfigProto) Descriptor() ([]byte, []int)\n```\nDeprecated: Use NumericalMedianConfigProto.ProtoReflect.Descriptor instead.\n\n```go\nfunc (x *NumericalMedianConfigProto) GetAlphaAcceptInfinite() bool\n```\n\n```go\nfunc (x *NumericalMedianConfigProto) GetAlphaAcceptPpb() uint64\n```\n\n```go\nfunc (x *NumericalMedianConfigProto) GetAlphaReportInfinite() bool\n```\n\n```go\nfunc (x *NumericalMedianConfigProto) GetAlphaReportPpb() uint64\n```\n\n```go\nfunc (x *NumericalMedianConfigProto) GetDeltaCNanoseconds() uint64\n```\n\n```go\nfunc (*NumericalMedianConfigProto) ProtoMessage()\n```\n\n```go\nfunc (x *NumericalMedianConfigProto) ProtoReflect() protoreflect.Message\n```\n\n```go\nfunc (x *NumericalMedianConfigProto) Reset()\n```\n\n```go\nfunc (x *NumericalMedianConfigProto) String() string\n```\n\n```go\ntype NumericalMedianFactory struct {\n\tContractTransmitter       MedianContract\n\tDataSource                DataSource\n\tJuelsPerFeeCoinDataSource DataSource\n\tLogger                    commontypes.Logger\n\tOnchainConfigCodec        OnchainConfigCodec\n\tReportCodec               ReportCodec\n}\n```\n\n```go\nfunc (fac NumericalMedianFactory) NewReportingPlugin(configuration types.ReportingPluginConfig) (types.ReportingPlugin, types.ReportingPluginInfo, error)\n```\n\n```go\ntype NumericalMedianObservationProto struct {\n\tTimestamp       uint32 `protobuf:\"varint,1,opt,name=timestamp,proto3\" json:\"timestamp,omitempty\"`\n\tValue           []byte `protobuf:\"bytes,2,opt,name=value,proto3\" json:\"value,omitempty\"`\n\tJuelsPerFeeCoin []byte `protobuf:\"bytes,3,opt,name=juelsPerFeeCoin,proto3\" json:\"juelsPerFeeCoin,omitempty\"`\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (*NumericalMedianObservationProto) Descriptor() ([]byte, []int)\n```\nDeprecated: Use NumericalMedianObservationProto.ProtoReflect.Descriptor instead.\n\n```go\nfunc (x *NumericalMedianObservationProto) GetJuelsPerFeeCoin() []byte\n```\n\n```go\nfunc (x *NumericalMedianObservationProto) GetTimestamp() uint32\n```\n\n```go\nfunc (x *NumericalMedianObservationProto) GetValue() []byte\n```\n\n```go\nfunc (*NumericalMedianObservationProto) ProtoMessage()\n```\n\n```go\nfunc (x *NumericalMedianObservationProto) ProtoReflect() protoreflect.Message\n```\n\n```go\nfunc (x *NumericalMedianObservationProto) Reset()\n```\n\n```go\nfunc (x *NumericalMedianObservationProto) String() string\n```\n\n```go\ntype OffchainConfig struct {\n\t// If AlphaReportInfinite is true, the deviation check parametrized by\n\t// AlphaReportPPB will never be satisfied.\n\tAlphaReportInfinite bool\n\t// AlphaReportPPB determines the relative deviation between the median (i.e.\n\t// answer) in the contract and the current median of observations (offchain)\n\t// at which a report should be issued. That is, a report is issued if\n\t// abs((offchainMedian - contractMedian)/contractMedian) \u003e= alphaReport.\n\tAlphaReportPPB uint64 // PPB is parts-per-billion\n\t// If AlphaAcceptInfinite is true, the deviation check parametrized by\n\t// AlphaAcceptPPB will never be satisfied.\n\tAlphaAcceptInfinite bool\n\t// AlphaAcceptPPB determines the relative deviation between the median in a\n\t// newly generated report considered for transmission and the median of the\n\t// currently pending report. That is, a report is accepted for transmission\n\t// if abs((newMedian - pendingMedian)/pendingMedian) \u003e= alphaAccept. If no\n\t// report is pending, this variable has no effect.\n\tAlphaAcceptPPB uint64 // PPB is parts-per-billion\n\t// DeltaC is the maximum age of the latest report in the contract. If the\n\t// maximum age is exceeded, a new report will be created by the report\n\t// generation protocol.\n\tDeltaC time.Duration\n}\n```\n\n```go\nfunc DecodeOffchainConfig(b []byte) (OffchainConfig, error)\n```\n\n```go\nfunc (c OffchainConfig) Encode() []byte\n```\n\n```go\ntype OnchainConfig struct {\n\tMin *big.Int\n\tMax *big.Int\n}\n```\n\n```go\ntype OnchainConfigCodec interface {\n\tEncode(OnchainConfig) ([]byte, error)\n\tDecode([]byte) (OnchainConfig, error)\n}\n```\n\n```go\ntype ParsedAttributedObservation struct {\n\tTimestamp       uint32\n\tValue           *big.Int\n\tJuelsPerFeeCoin *big.Int\n\tObserver        commontypes.OracleID\n}\n```\n\n```go\ntype ReportCodec interface {\n\t// Implementers may assume that there is at most one\n\t// ParsedAttributedObservation per observer, and that all observers are\n\t// valid. However, observation values, timestamps, etc... should all be\n\t// treated as untrusted.\n\tBuildReport([]ParsedAttributedObservation) (types.Report, error)\n\n\t// Gets the \"median\" (the n//2-th ranked element to be more precise where n\n\t// is the length of the list) observation from the report. The input to this\n\t// function should be an output of BuildReport in the benign case.\n\t// Nevertheless, make sure to treat the input to this function as untrusted.\n\tMedianFromReport(types.Report) (*big.Int, error)\n\n\t// Returns the maximum length of a report based on n, the number of oracles.\n\t// The output of BuildReport must respect this maximum length.\n\tMaxReportLength(n int) (int, error)\n}\n```\nAll functions on ReportCodec should be pure and thread-safe. Be careful validating and parsing any data passed.\n\n```go\ntype StandardOnchainConfigCodec struct{}\n```\nStandardOnchainConfigCodec provides a standard implementation of OnchainConfigCodec. This is the implementation used by the EVM and Solana integrations.\n\nAn encoded onchain config is expected to be in the format \\\u003cversion\u003e\\\u003cmin\u003e\\\u003cmax\u003e where version is a uint8 and min and max are in the format returned by EncodeValue.\n\n```go\nfunc (StandardOnchainConfigCodec) Decode(b []byte) (OnchainConfig, error)\n```\n\n```go\nfunc (StandardOnchainConfigCodec) Encode(c OnchainConfig) ([]byte, error)\n```\n\n","path":"github.com/GoPlugin/pluginV2Lib/libocr/offchainreporting2/reportingplugin/median","name":"median","synopsis":"","isRedistributable":true}
