Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Keeper ¶
type Keeper interface { GetAllCurrencyPairs(ctx sdk.Context) []oracletypes.CurrencyPair SetPriceForCurrencyPair(ctx sdk.Context, cp oracletypes.CurrencyPair, qp oracletypes.QuotePrice) error }
Keeper defines the interface that must be fulfilled by the oracle keeper. This interface is utilized by the PreBlock handler to write oracle data to state for the supported assets.
type PreBlockHandler ¶
type PreBlockHandler struct {
// contains filtered or unexported fields
}
PreBlockHandler is responsible for aggregating oracle data from each validator and writing the oracle data into the store before any transactions are executed/finalized for a given block.
func NewOraclePreBlockHandler ¶
func NewOraclePreBlockHandler( logger log.Logger, aggregateFn aggregator.AggregateFnFromContext[string, map[oracletypes.CurrencyPair]*big.Int], oracleKeeper Keeper, validatorConsAddress sdk.ConsAddress, metrics servicemetrics.Metrics, strategy currencypair.CurrencyPairStrategy, veCodec codec.VoteExtensionCodec, ecCodec codec.ExtendedCommitCodec, ) *PreBlockHandler
NewOraclePreBlockHandler returns a new PreBlockHandler. The handler is responsible for writing oracle data included in vote extensions to state.
func (*PreBlockHandler) AggregateOracleVotes ¶
func (h *PreBlockHandler) AggregateOracleVotes( ctx sdk.Context, votes []Vote, ) (map[oracletypes.CurrencyPair]*big.Int, error)
AggregateOracleVotes ingresses vote information which contains all of the vote extensions each validator extended in the previous block. it is important to note that
- The vote extension may be nil, in which case the validator is not providing any oracle data for the current block. This could have occurred because the validator was offline, or its local oracle service was down.
- The vote extension may contain prices updates for only a subset of currency pairs. This could have occurred because the price providers for the validator were offline, or the price providers did not provide a price update for a given currency pair.
In order for a currency pair to be included in the final oracle price, the currency pair must be provided by a supermajority (2/3+) of validators. This is enforced by the price aggregator but can be replaced by the application.
func (*PreBlockHandler) PreBlocker ¶
func (h *PreBlockHandler) PreBlocker() sdk.PreBlocker
PreBlocker is called by the base app before the block is finalized. It is responsible for aggregating oracle data from each validator and writing the oracle data to the store.
func (*PreBlockHandler) WritePrices ¶
func (h *PreBlockHandler) WritePrices(ctx sdk.Context, prices map[oracletypes.CurrencyPair]*big.Int) error
WritePrices writes the oracle data to state. Note, this will only write prices that are already present in state.
type Vote ¶
type Vote struct { // ConsAddress is the validator that submitted the vote extension. ConsAddress sdk.ConsAddress // OracleVoteExtension OracleVoteExtension types.OracleVoteExtension }
Vote encapsulates the validator and oracle data contained within a vote extension.
func GetOracleVotes ¶
func GetOracleVotes( proposal [][]byte, veCodec compression.VoteExtensionCodec, extCommitCodec compression.ExtendedCommitCodec, ) ([]Vote, error)
GetOracleVotes returns all of the oracle vote extensions that were injected into the block. Note that all of the vote extensions included are necessarily valid at this point because the vote extensions were validated by the vote extension and proposal handlers.