oracle

package
v0.0.0-...-211528f Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2024 License: MIT Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrResponseTooLarge = errors.New("too big response")

ErrResponseTooLarge is returned when a response exceeds the max allowed size.

View Source
var ErrRestrictedRedirect = errors.New("oracle request redirection error")

ErrRestrictedRedirect is returned when redirection to forbidden address occurs during Oracle response creation.

Functions

This section is empty.

Types

type Broadcaster

type Broadcaster interface {
	SendResponse(priv *keys.PrivateKey, resp *transaction.OracleResponse, txSig []byte)
	Run()
	Shutdown()
}

Broadcaster broadcasts oracle responses.

type Config

type Config struct {
	Log             *zap.Logger
	Network         netmode.Magic
	MainCfg         config.OracleConfiguration
	Client          HTTPClient
	Chain           Ledger
	ResponseHandler Broadcaster
	OnTransaction   TxCallback
}

Config contains oracle module parameters.

type HTTPClient

type HTTPClient interface {
	Do(*http.Request) (*http.Response, error)
}

HTTPClient is an interface capable of doing oracle requests.

type Ledger

type Ledger interface {
	BlockHeight() uint32
	FeePerByte() int64
	GetBaseExecFee() int64
	GetConfig() config.Blockchain
	GetMaxVerificationGAS() int64
	GetTestVM(t trigger.Type, tx *transaction.Transaction, b *block.Block) (*interop.Context, error)
	GetTransaction(util.Uint256) (*transaction.Transaction, uint32, error)
}

Ledger is an interface to Blockchain sufficient for Oracle.

type Oracle

type Oracle struct {
	Config
	// contains filtered or unexported fields
}

Oracle represents an oracle module capable of talking with the external world.

func NewOracle

func NewOracle(cfg Config) (*Oracle, error)

NewOracle returns new oracle instance.

func (*Oracle) AddRequests

func (o *Oracle) AddRequests(reqs map[uint64]*state.OracleRequest)

AddRequests saves all requests in-fly for further processing.

func (*Oracle) AddResponse

func (o *Oracle) AddResponse(pub *keys.PublicKey, reqID uint64, txSig []byte)

AddResponse handles an oracle response (transaction signature for some identified request) signed by the given key. sig is a response transaction signature.

func (*Oracle) CreateResponseTx

func (o *Oracle) CreateResponseTx(gasForResponse int64, vub uint32, resp *transaction.OracleResponse) (*transaction.Transaction, error)

CreateResponseTx creates an unsigned oracle response transaction.

func (*Oracle) IsAuthorized

func (o *Oracle) IsAuthorized() bool

IsAuthorized returns whether Oracle service currently is authorized to collect signatures. It returns true iff designated Oracle node's account provided to the Oracle service in decrypted state.

func (*Oracle) Name

func (o *Oracle) Name() string

Name returns service name.

func (*Oracle) ProcessRequestsInternal

func (o *Oracle) ProcessRequestsInternal(reqs map[uint64]*state.OracleRequest)

ProcessRequestsInternal processes the provided requests synchronously.

func (*Oracle) RemoveRequests

func (o *Oracle) RemoveRequests(ids []uint64)

RemoveRequests removes all data associated with requests which have been processed by oracle contract.

func (*Oracle) Shutdown

func (o *Oracle) Shutdown()

Shutdown shutdowns Oracle. It can only be called once, subsequent calls to Shutdown on the same instance are no-op. The instance that was stopped can not be started again by calling Start (use a new instance if needed).

func (*Oracle) Start

func (o *Oracle) Start()

Start runs the oracle service in a separate goroutine. The Oracle only starts once, subsequent calls to Start are no-op.

func (*Oracle) UpdateNativeContract

func (o *Oracle) UpdateNativeContract(script, resp []byte, h util.Uint160, verifyOffset int)

UpdateNativeContract updates native oracle contract info for tx verification.

func (*Oracle) UpdateOracleNodes

func (o *Oracle) UpdateOracleNodes(oracleNodes keys.PublicKeys)

UpdateOracleNodes updates oracle nodes list.

type TxCallback

type TxCallback = func(tx *transaction.Transaction) error

TxCallback executes on new transactions when they are ready to be pooled.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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