oracle

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2019 License: Apache-2.0 Imports: 11 Imported by: 5

Documentation

Index

Constants

View Source
const (
	DefaultCodespace sdk.CodespaceType = "oracle"

	CodeNotValidator sdk.CodeType = 1
	CodeUnknownDenom sdk.CodeType = 2
	CodeInvalidPrice sdk.CodeType = 3
)

Oracle errors reserve 1101-1199

View Source
const (
	// Precision of Oracle vote
	OracleDecPrec = 2

	// RouterKey is they name of the oracle module
	RouterKey = "oracle"
)
View Source
const (
	QueryPrice  = "price"
	QueryVotes  = "votes"
	QueryActive = "active"
	QueryParams = "params"
)

query endpoints supported by the governance Querier

View Source
const (
	// default paramspace for params keeper
	DefaultParamspace = "oracle"
)
View Source
const StoreKey = "oracle"

StoreKey is string representation of the store key for oracle

Variables

View Source
var (
	PrefixVote        = []byte("vote")
	PrefixPrice       = []byte("price")
	PrefixDropCounter = []byte("drop")
	KeyDelimiter      = []byte(":")

	ParamStoreKeyParams = []byte("params")
)

nolint

Functions

func EndBlocker

func EndBlocker(ctx sdk.Context, k Keeper) (prices map[string]sdk.Dec, rewardees map[string]sdk.Int, resTags sdk.Tags)

EndBlocker is called at the end of every block

func ErrInvalidPrice added in v0.0.5

func ErrInvalidPrice(codespace sdk.CodespaceType, price sdk.Dec) sdk.Error

ErrInvalidPrice called when the price submitted is not valid

func ErrNotValidator

func ErrNotValidator(codespace sdk.CodespaceType, address sdk.AccAddress) sdk.Error

ErrNotValidator called when the signer of a Msg is not a validator

func ErrUnknownDenomination added in v0.0.4

func ErrUnknownDenomination(codespace sdk.CodespaceType, denom string) sdk.Error

ErrUnknownDenomination called when the signer of a Msg is not a validator

func InitGenesis added in v0.0.4

func InitGenesis(ctx sdk.Context, keeper Keeper, data GenesisState)

new oracle genesis

func KeyDropCounter added in v0.0.5

func KeyDropCounter(denom string) []byte

KeyDropCounter is in format of PrefixDropCounter||denom

func KeyPrice added in v0.0.5

func KeyPrice(denom string) []byte

KeyPrice is in format of PrefixPrice||denom

func KeyVote added in v0.0.5

func KeyVote(denom string, voter sdk.AccAddress) []byte

KeyVote Key is in format of PrefixVote||denom||voter.AccAddress

func NewHandler

func NewHandler(k Keeper) sdk.Handler

NewHandler returns a handler for "oracle" type messages.

func NewQuerier added in v0.0.5

func NewQuerier(keeper Keeper) sdk.Querier

NewQuerier is the module level router for state queries

func ParamKeyTable added in v0.0.5

func ParamKeyTable() params.KeyTable

ParamKeyTable for oracle module

func RegisterCodec added in v0.0.5

func RegisterCodec(cdc *codec.Codec)

Register concrete types on codec codec

func ValidateGenesis added in v0.0.4

func ValidateGenesis(data GenesisState) error

ValidateGenesis validates the provided oracle genesis state to ensure the expected invariants holds. (i.e. params in correct bounds, no duplicate validators)

Types

type GenesisState added in v0.0.4

type GenesisState struct {
	Params Params `json:"params"` // oracle params
}

GenesisState - all oracle state that must be provided at genesis

func DefaultGenesisState added in v0.0.4

func DefaultGenesisState() GenesisState

get raw genesis raw message for testing

func ExportGenesis added in v0.0.4

func ExportGenesis(ctx sdk.Context, keeper Keeper) GenesisState

ExportGenesis returns a GenesisState for a given context and keeper. The GenesisState will contain the pool, and validator/delegator distribution info's

func NewGenesisState added in v0.0.4

func NewGenesisState(params Params) GenesisState

type Keeper

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

Keeper of the oracle store

func NewKeeper

func NewKeeper(key sdk.StoreKey, cdc *codec.Codec, valset sdk.ValidatorSet, paramspace params.Subspace) Keeper

NewKeeper constructs a new keeper

func (Keeper) GetParams added in v0.0.4

func (k Keeper) GetParams(ctx sdk.Context) Params

GetParams get oralce params from the global param store

func (Keeper) GetPrice added in v0.0.5

func (k Keeper) GetPrice(ctx sdk.Context, denom string) (price sdk.Dec, err sdk.Error)

func (Keeper) SetParams added in v0.0.4

func (k Keeper) SetParams(ctx sdk.Context, params Params)

SetParams set oracle params from the global param store

type Params added in v0.0.4

type Params struct {
	VotePeriod    sdk.Int `json:"vote_period"`    // voting period; tallys and reward claim period
	VoteThreshold sdk.Dec `json:"vote_threshold"` // minimum stake power threshold to clear vote
	DropThreshold sdk.Int `json:"drop_threshold"` // tolerated drops before blacklist
}

Params oracle parameters

func DefaultParams added in v0.0.4

func DefaultParams() Params

DefaultParams creates default oracle module parameters

func NewParams added in v0.0.4

func NewParams(votePeriod sdk.Int, voteThreshold sdk.Dec, dropThreshold sdk.Int) Params

NewParams creates a new param instance

func (Params) String added in v0.0.5

func (params Params) String() string

type PriceBallot added in v0.0.5

type PriceBallot []PriceVote

func (PriceBallot) Len added in v0.0.5

func (pb PriceBallot) Len() int

Len implements sort.Interface

func (PriceBallot) Less added in v0.0.5

func (pb PriceBallot) Less(i, j int) bool

Less reports whether the element with index i should sort before the element with index j.

func (PriceBallot) String added in v0.0.5

func (pb PriceBallot) String() (out string)

String implements fmt.Stringer interface

func (PriceBallot) Swap added in v0.0.5

func (pb PriceBallot) Swap(i, j int)

type PriceFeedMsg

type PriceFeedMsg struct {
	Denom  string
	Price  sdk.Dec // in Luna
	Feeder sdk.AccAddress
}

PriceFeedMsg - struct for voting on payloads. Note that the Price is denominated in Luna. All validators must vote on Terra prices.

func NewPriceFeedMsg

func NewPriceFeedMsg(denom string, price sdk.Dec, feederAddress sdk.AccAddress) PriceFeedMsg

NewPriceFeedMsg creates a PriceFeedMsg instance

func (PriceFeedMsg) GetSignBytes

func (msg PriceFeedMsg) GetSignBytes() []byte

GetSignBytes implements sdk.Msg

func (PriceFeedMsg) GetSigners

func (msg PriceFeedMsg) GetSigners() []sdk.AccAddress

GetSigners implements sdk.Msg

func (PriceFeedMsg) Route

func (msg PriceFeedMsg) Route() string

Route Implements Msg

func (PriceFeedMsg) String

func (msg PriceFeedMsg) String() string

String Implements sdk.Msg

func (PriceFeedMsg) Type

func (msg PriceFeedMsg) Type() string

Type implements sdk.Msg

func (PriceFeedMsg) ValidateBasic

func (msg PriceFeedMsg) ValidateBasic() sdk.Error

ValidateBasic Implements sdk.Msg

type PriceVote

type PriceVote struct {
	Price sdk.Dec        `json:"price"` // Price of Luna in target fiat currency
	Denom string         `json:"denom"` // Ticker name of target fiat currency
	Power sdk.Int        `json:"power"` // Total bonded tokens of validator
	Voter sdk.AccAddress `json:"voter"` // account address of validator
}

PriceVote - struct to store a validator's vote on the price

func NewPriceVote

func NewPriceVote(price sdk.Dec, denom string, power sdk.Int, voter sdk.AccAddress) PriceVote

NewPriceVote creates a PriceVote instance

func (PriceVote) String added in v0.0.5

func (pv PriceVote) String() string

type QueryVoteParams added in v0.0.5

type QueryVoteParams struct {
	Voter sdk.AccAddress
	Denom string
}

Params for query 'custom/oracle/votes'

func NewQueryVoteParams added in v0.0.5

func NewQueryVoteParams(voter sdk.AccAddress, denom string) QueryVoteParams

creates a new instance of QueryVoteParams

Directories

Path Synopsis
cli

Jump to

Keyboard shortcuts

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