keeper

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2020 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

nolint:deadcode unused noalias

Index

Constants

This section is empty.

Variables

View Source
var (
	PubKeys = []crypto.PubKey{
		secp256k1.GenPrivKey().PubKey(),
		secp256k1.GenPrivKey().PubKey(),
		secp256k1.GenPrivKey().PubKey(),
	}

	Addrs = []sdk.AccAddress{
		sdk.AccAddress(PubKeys[0].Address()),
		sdk.AccAddress(PubKeys[1].Address()),
		sdk.AccAddress(PubKeys[2].Address()),
	}

	ValAddrs = []sdk.ValAddress{
		sdk.ValAddress(PubKeys[0].Address()),
		sdk.ValAddress(PubKeys[1].Address()),
		sdk.ValAddress(PubKeys[2].Address()),
	}

	InitTokens = sdk.TokensFromConsensusPower(200)
	InitCoins  = sdk.NewCoins(sdk.NewCoin(core.MicroLunaDenom, InitTokens))

	OracleDecPrecision = 8
)

Functions

func NewQuerier

func NewQuerier(keeper Keeper) sdk.Querier

NewQuerier is the module level router for state queries

func NewTestMsgCreateValidator

func NewTestMsgCreateValidator(address sdk.ValAddress, pubKey crypto.PubKey, amt sdk.Int) staking.MsgCreateValidator

func NewTestMsgDelegate

func NewTestMsgDelegate(delAddr sdk.AccAddress, valAddr sdk.ValAddress, delAmount sdk.Int) staking.MsgDelegate

func ParamKeyTable

func ParamKeyTable() params.KeyTable

ParamKeyTable for staking module

Types

type Keeper

type Keeper struct {
	StakingKeeper types.StakingKeeper
	// contains filtered or unexported fields
}

Keeper of the oracle store

func NewKeeper

func NewKeeper(cdc *codec.Codec, storeKey sdk.StoreKey,
	paramspace params.Subspace, distrKeeper types.DistributionKeeper,
	stakingKeeper types.StakingKeeper, supplyKeeper types.SupplyKeeper,
	distrName string, codespace sdk.CodespaceType) Keeper

NewKeeper constructs a new keeper for oracle

func (Keeper) AddExchangeRatePrevote

func (k Keeper) AddExchangeRatePrevote(ctx sdk.Context, prevote types.ExchangeRatePrevote)

AddExchangeRatePrevote adds an oracle prevote to the store

func (Keeper) AddExchangeRateVote

func (k Keeper) AddExchangeRateVote(ctx sdk.Context, vote types.ExchangeRateVote)

AddExchangeRateVote adds an oracle vote to the store

func (Keeper) Codespace

func (k Keeper) Codespace() sdk.CodespaceType

Codespace returns a codespace of keeper

func (Keeper) DeleteExchangeRatePrevote

func (k Keeper) DeleteExchangeRatePrevote(ctx sdk.Context, prevote types.ExchangeRatePrevote)

DeleteExchangeRatePrevote deletes an oracle prevote from the store

func (Keeper) DeleteExchangeRateVote

func (k Keeper) DeleteExchangeRateVote(ctx sdk.Context, vote types.ExchangeRateVote)

DeleteExchangeRateVote deletes an oracle vote from the store

func (Keeper) DeleteLunaExchangeRate

func (k Keeper) DeleteLunaExchangeRate(ctx sdk.Context, denom string)

DeleteLunaExchangeRate deletes the consensus exchange rate of Luna denominated in the denom asset from the store.

func (Keeper) DeleteMissCounter added in v0.3.5

func (k Keeper) DeleteMissCounter(ctx sdk.Context, operator sdk.ValAddress)

DeleteMissCounter removes miss counter for the validator

func (Keeper) GetExchangeRatePrevote

func (k Keeper) GetExchangeRatePrevote(ctx sdk.Context, denom string, voter sdk.ValAddress) (prevote types.ExchangeRatePrevote, err sdk.Error)

GetExchangeRatePrevote retrieves an oracle prevote from the store

func (Keeper) GetLunaExchangeRate

func (k Keeper) GetLunaExchangeRate(ctx sdk.Context, denom string) (exchangeRate sdk.Dec, err sdk.Error)

GetLunaExchangeRate gets the consensus exchange rate of Luna denominated in the denom asset from the store.

func (Keeper) GetMissCounter

func (k Keeper) GetMissCounter(ctx sdk.Context, operator sdk.ValAddress) (missCounter int64)

GetMissCounter retrives the # of vote periods missed in this oracle slash window

func (Keeper) GetOracleDelegate

func (k Keeper) GetOracleDelegate(ctx sdk.Context, operator sdk.ValAddress) (delegate sdk.AccAddress)

GetOracleDelegate gets the account address that the validator operator delegated oracle vote rights to

func (Keeper) GetParams

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

GetParams returns the total set of oracle parameters.

func (Keeper) GetRewardPool

func (k Keeper) GetRewardPool(ctx sdk.Context) sdk.Coins

GetRewardPool retrieves the balance of the oracle module account

func (Keeper) IterateExchangeRatePrevotes

func (k Keeper) IterateExchangeRatePrevotes(ctx sdk.Context, handler func(prevote types.ExchangeRatePrevote) (stop bool))

IterateExchangeRatePrevotes iterates rate over prevotes in the store

func (Keeper) IterateExchangeRateVotes

func (k Keeper) IterateExchangeRateVotes(ctx sdk.Context, handler func(vote types.ExchangeRateVote) (stop bool))

IterateExchangeRateVotes iterates over votes in the store

func (Keeper) IterateLunaExchangeRates

func (k Keeper) IterateLunaExchangeRates(ctx sdk.Context, handler func(denom string, exchangeRate sdk.Dec) (stop bool))

IterateLunaExchangeRates iterates over luna rates in the store

func (Keeper) IterateMissCounters

func (k Keeper) IterateMissCounters(ctx sdk.Context,
	handler func(operator sdk.ValAddress, missCounter int64) (stop bool))

IterateMissCounters iterates over the miss counters and performs a callback function.

func (Keeper) IterateOracleDelegates

func (k Keeper) IterateOracleDelegates(ctx sdk.Context,
	handler func(delegator sdk.ValAddress, delegate sdk.AccAddress) (stop bool))

IterateOracleDelegates iterates over the feed delegates and performs a callback function.

func (Keeper) Logger

func (k Keeper) Logger(ctx sdk.Context) log.Logger

Logger returns a module-specific logger.

func (Keeper) MinValidPerWindow

func (k Keeper) MinValidPerWindow(ctx sdk.Context) (res sdk.Dec)

MinValidPerWindow returns oracle slashing threshold

func (Keeper) OrganizeBallotByDenom

func (k Keeper) OrganizeBallotByDenom(ctx sdk.Context) (votes map[string]types.ExchangeRateBallot)

OrganizeBallotByDenom collects all oracle votes for the period, categorized by the votes' denom parameter

func (Keeper) RewardBallotWinners

func (k Keeper) RewardBallotWinners(ctx sdk.Context, ballotWinners map[string]types.Claim)

RewardBallotWinners implements at the end of every VotePeriod, we give out portion of seigniorage reward(reward-weight) to the oracle voters that voted faithfully.

func (Keeper) RewardBand

func (k Keeper) RewardBand(ctx sdk.Context) (res sdk.Dec)

RewardBand returns the ratio of allowable exchange rate error that a validator can be rewared

func (Keeper) RewardDistributionWindow

func (k Keeper) RewardDistributionWindow(ctx sdk.Context) (res int64)

RewardDistributionWindow returns the number of vote periods during which seigiornage reward comes in and then is distributed.

func (Keeper) SetLunaExchangeRate

func (k Keeper) SetLunaExchangeRate(ctx sdk.Context, denom string, exchangeRate sdk.Dec)

SetLunaExchangeRate sets the consensus exchange rate of Luna denominated in the denom asset to the store.

func (Keeper) SetMissCounter

func (k Keeper) SetMissCounter(ctx sdk.Context, operator sdk.ValAddress, missCounter int64)

SetMissCounter updates the # of vote periods missed in this oracle slash window

func (Keeper) SetOracleDelegate

func (k Keeper) SetOracleDelegate(ctx sdk.Context, operator sdk.ValAddress, delegatedFeeder sdk.AccAddress)

SetOracleDelegate sets the account address that the validator operator delegated oracle vote rights to

func (Keeper) SetParams

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

SetParams sets the total set of oracle parameters.

func (Keeper) SlashFraction

func (k Keeper) SlashFraction(ctx sdk.Context) (res sdk.Dec)

SlashFraction returns oracle voting penalty rate

func (Keeper) SlashWindow

func (k Keeper) SlashWindow(ctx sdk.Context) (res int64)

SlashWindow returns # of vote period for oracle slashing

func (Keeper) VotePeriod

func (k Keeper) VotePeriod(ctx sdk.Context) (res int64)

VotePeriod returns the number of blocks during which voting takes place.

func (Keeper) VoteThreshold

func (k Keeper) VoteThreshold(ctx sdk.Context) (res sdk.Dec)

VoteThreshold returns the minimum percentage of votes that must be received for a ballot to pass.

func (Keeper) Whitelist

func (k Keeper) Whitelist(ctx sdk.Context) (res types.DenomList)

Whitelist returns the denom list that can be acitivated

type TestInput

type TestInput struct {
	Ctx           sdk.Context
	Cdc           *codec.Codec
	AccKeeper     auth.AccountKeeper
	BankKeeper    bank.Keeper
	OracleKeeper  Keeper
	SupplyKeeper  supply.Keeper
	StakingKeeper staking.Keeper
	DistrKeeper   distr.Keeper
}

TestInput nolint

func CreateTestInput

func CreateTestInput(t *testing.T) TestInput

CreateTestInput nolint

Jump to

Keyboard shortcuts

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