keeper

package
v0.0.0-...-3ea6778 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2020 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultParamspace = types.ModuleName
)

Default parameter namespace

Variables

This section is empty.

Functions

func BeginBlocker

func BeginBlocker(ctx sdk.Ctx, req abci.RequestBeginBlock, k Keeper)

1) allocate tokens to block producer 2) mint any custom awards for each validator 3) set new proposer 4) check block sigs and byzantine evidence to slash

func EndBlocker

func EndBlocker(ctx sdk.Ctx, k Keeper) []abci.ValidatorUpdate

Called every block, update validator set

func ModuleAccountInvariants

func ModuleAccountInvariants(k Keeper) sdk.Invariant

ModuleAccountInvariants checks that the staked ModuleAccounts pools reflects the tokens actively staked and not staked

func NewQuerier

func NewQuerier(k Keeper) sdk.Querier

creates a querier for staking REST endpoints

func NonNegativePowerInvariant

func NonNegativePowerInvariant(k Keeper) sdk.Invariant

NonNegativePowerInvariant checks that all stored validators have >= 0 power.

func ParamKeyTable

func ParamKeyTable() sdk.KeyTable

ParamTable for staking module

func RegisterInvariants

func RegisterInvariants(ir sdk.InvariantRegistry, k Keeper)

RegisterInvariants registers all staking invariants

Types

type Keeper

type Keeper struct {
	Paramstore sdk.Subspace
	// contains filtered or unexported fields
}

keeper of the staking store

func NewKeeper

func NewKeeper(cdc *codec.Codec, key sdk.StoreKey, coinKeeper bank.Keeper, supplyKeeper types.SupplyKeeper,
	paramstore sdk.Subspace, codespace sdk.CodespaceType) Keeper

NewKeeper creates a new staking Keeper instance

func (Keeper) AddPubKeyRelation

func (k Keeper) AddPubKeyRelation(ctx sdk.Ctx, pubkey posCrypto.PublicKey)

func (Keeper) AfterValidatorBeginUnstaking

func (k Keeper) AfterValidatorBeginUnstaking(ctx sdk.Ctx, valAddr sdk.Address)

func (Keeper) AfterValidatorRegistered

func (k Keeper) AfterValidatorRegistered(ctx sdk.Ctx, valAddr sdk.Address)

func (Keeper) AfterValidatorRemoved

func (k Keeper) AfterValidatorRemoved(ctx sdk.Ctx, valAddr sdk.Address)

func (Keeper) AfterValidatorSlashed

func (k Keeper) AfterValidatorSlashed(ctx sdk.Ctx, valAddr sdk.Address, fraction sdk.Dec)

func (Keeper) AfterValidatorStaked

func (k Keeper) AfterValidatorStaked(ctx sdk.Ctx, valAddr sdk.Address)

func (Keeper) AfterValidatorUnstaked

func (k Keeper) AfterValidatorUnstaked(ctx sdk.Ctx, valAddr sdk.Address)

func (Keeper) AllValidators

func (k Keeper) AllValidators(ctx sdk.Ctx) (validators []exported.ValidatorI)

func (Keeper) AwardCoinsTo

func (k Keeper) AwardCoinsTo(ctx sdk.Ctx, amount sdk.Int, address sdk.Address)

award coins to an address (will be called at the beginning of the next block)

func (Keeper) BeforeValidatorBeginUnstaking

func (k Keeper) BeforeValidatorBeginUnstaking(ctx sdk.Ctx, valAddr sdk.Address)

func (Keeper) BeforeValidatorRegistered

func (k Keeper) BeforeValidatorRegistered(ctx sdk.Ctx, valAddr sdk.Address)

func (Keeper) BeforeValidatorRemoved

func (k Keeper) BeforeValidatorRemoved(ctx sdk.Ctx, valAddr sdk.Address)

func (Keeper) BeforeValidatorSlashed

func (k Keeper) BeforeValidatorSlashed(ctx sdk.Ctx, valAddr sdk.Address, fraction sdk.Dec)

func (Keeper) BeforeValidatorStaked

func (k Keeper) BeforeValidatorStaked(ctx sdk.Ctx, valAddr sdk.Address)

func (Keeper) BeforeValidatorUnstaked

func (k Keeper) BeforeValidatorUnstaked(ctx sdk.Ctx, valAddr sdk.Address)

func (Keeper) BeginUnstakingValidator

func (k Keeper) BeginUnstakingValidator(ctx sdk.Ctx, validator types.Validator) sdk.Error

store ops when validator begins to unstake -> starts the unstaking timer

func (Keeper) BurnValidator

func (k Keeper) BurnValidator(ctx sdk.Ctx, address sdk.Address, severityPercentage sdk.Dec)

func (Keeper) Codespace

func (k Keeper) Codespace() sdk.CodespaceType

return the codespace

func (Keeper) DeletePrevStateValPower

func (k Keeper) DeletePrevStateValPower(ctx sdk.Ctx, addr sdk.Address)

Delete the power of a SINGLE staked validator from the previous state

func (Keeper) DowntimeJailDuration

func (k Keeper) DowntimeJailDuration(ctx sdk.Ctx) (res time.Duration)

Downtime jail duration

func (Keeper) FinishUnstakingValidator

func (k Keeper) FinishUnstakingValidator(ctx sdk.Ctx, validator types.Validator) sdk.Error

store ops to unstake a validator -> called after unstaking time is up

func (Keeper) ForceValidatorUnstake

func (k Keeper) ForceValidatorUnstake(ctx sdk.Ctx, validator types.Validator) sdk.Error

force unstake (called when slashed below the minimum)

func (Keeper) GetAllValidators

func (k Keeper) GetAllValidators(ctx sdk.Ctx) (validators []types.Validator)

get the set of all validators with no limits from the main store

func (Keeper) GetBalance

func (k Keeper) GetBalance(ctx sdk.Ctx, addr sdk.Address) sdk.Int

func (Keeper) GetBlockHeight

func (k Keeper) GetBlockHeight(ctx sdk.Ctx) int64

func (Keeper) GetBlockTime

func (k Keeper) GetBlockTime(ctx sdk.Ctx) time.Time

func (Keeper) GetLatestBlockID

func (k Keeper) GetLatestBlockID(ctx sdk.Ctx) abci.BlockID

func (Keeper) GetParams

func (k Keeper) GetParams(ctx sdk.Ctx) types.Params

Get all parameteras as types.Params

func (Keeper) GetPreviousProposer

func (k Keeper) GetPreviousProposer(ctx sdk.Ctx) (address sdk.Address)

get the proposer public key for this block

func (Keeper) GetStakedPool

func (k Keeper) GetStakedPool(ctx sdk.Ctx) (stakedPool exported.ModuleAccountI)

GetStakedPool returns the staked tokens pool's module account

func (Keeper) GetStakedTokens

func (k Keeper) GetStakedTokens(ctx sdk.Ctx) sdk.Int

GetStakedTokens total staking tokens supply which is staked

func (Keeper) GetUnstakedTokens

func (k Keeper) GetUnstakedTokens(ctx sdk.Ctx) (unstakedTokens sdk.Int)

GetUnstakedTokens returns the amount of not staked tokens

func (Keeper) GetValidator

func (k Keeper) GetValidator(ctx sdk.Ctx, addr sdk.Address) (validator types.Validator, found bool)

get a single validator from the main store

func (Keeper) GetValidatorSigningInfo

func (k Keeper) GetValidatorSigningInfo(ctx sdk.Ctx, address sdk.Address) (info types.ValidatorSigningInfo, found bool)

stored by consensus address

func (Keeper) GetValidators

func (k Keeper) GetValidators(ctx sdk.Ctx, maxRetrieve uint16) (validators []types.Validator)

return a given amount of all the validators

func (Keeper) IterateAndExecuteOverMissedArray

func (k Keeper) IterateAndExecuteOverMissedArray(ctx sdk.Ctx,
	address sdk.Address, handler func(index int64, missed bool) (stop bool))

Stored by *validator* address (not operator address)

func (Keeper) IterateAndExecuteOverPrevStateVals

func (k Keeper) IterateAndExecuteOverPrevStateVals(
	ctx sdk.Ctx, fn func(index int64, validator exported.ValidatorI) (stop bool))

iterate through the active validator set and perform the provided function

func (Keeper) IterateAndExecuteOverPrevStateValsByPower

func (k Keeper) IterateAndExecuteOverPrevStateValsByPower(
	ctx sdk.Ctx, handler func(address sdk.Address, power int64) (stop bool))

Iterate over prevState validator powers and perform a function on each validator.

func (Keeper) IterateAndExecuteOverStakedVals

func (k Keeper) IterateAndExecuteOverStakedVals(
	ctx sdk.Ctx, fn func(index int64, validator exported.ValidatorI) (stop bool))

iterate through the staked validator set and perform the provided function

func (Keeper) IterateAndExecuteOverValSigningInfo

func (k Keeper) IterateAndExecuteOverValSigningInfo(ctx sdk.Ctx,
	handler func(address sdk.Address, info types.ValidatorSigningInfo) (stop bool))

func (Keeper) IterateAndExecuteOverVals

func (k Keeper) IterateAndExecuteOverVals(
	ctx sdk.Ctx, fn func(index int64, validator exported.ValidatorI) (stop bool))

iterate through the validator set and perform the provided function

func (Keeper) JailValidator

func (k Keeper) JailValidator(ctx sdk.Ctx, addr sdk.Address)

send a validator to jail

func (Keeper) Logger

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

Logger returns a module-specific logger.

func (Keeper) MaxEvidenceAge

func (k Keeper) MaxEvidenceAge(ctx sdk.Ctx) (res time.Duration)

MaxEvidenceAge - max age for evidence

func (Keeper) MaxValidators

func (k Keeper) MaxValidators(ctx sdk.Ctx) (res uint64)

MaxValidators - Maximum number of validators

func (Keeper) MinSignedPerWindow

func (k Keeper) MinSignedPerWindow(ctx sdk.Ctx) (res int64)

Downtime slashing threshold

func (Keeper) MinimumStake

func (k Keeper) MinimumStake(ctx sdk.Ctx) (res int64)

func (Keeper) PrevStateValidatorPower

func (k Keeper) PrevStateValidatorPower(ctx sdk.Ctx, addr sdk.Address) (power int64)

get the power of a SINGLE staked validator from the previous state

func (Keeper) PrevStateValidatorsPower

func (k Keeper) PrevStateValidatorsPower(ctx sdk.Ctx) (power sdk.Int)

Load the prevState total validator power.

func (Keeper) ProposerRewardPercentage

func (k Keeper) ProposerRewardPercentage(ctx sdk.Ctx) (res int8)

func (Keeper) RegisterValidator

func (k Keeper) RegisterValidator(ctx sdk.Ctx, validator types.Validator)

register the validator in the necessary stores in the world state

func (Keeper) SendCoins

func (k Keeper) SendCoins(ctx sdk.Ctx, fromAddress sdk.Address, toAddress sdk.Address, amount sdk.Int) sdk.Error

func (*Keeper) SetHooks

func (k *Keeper) SetHooks(sh types.POSHooks) *Keeper

Set the validator hooks

func (Keeper) SetMissedBlockArray

func (k Keeper) SetMissedBlockArray(ctx sdk.Ctx, address sdk.Address, index int64, missed bool)

func (Keeper) SetParams

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

set the params

func (Keeper) SetPrevStateValPower

func (k Keeper) SetPrevStateValPower(ctx sdk.Ctx, addr sdk.Address, power int64)

set the power of a SINGLE staked validator from the previous state

func (Keeper) SetPrevStateValidatorsPower

func (k Keeper) SetPrevStateValidatorsPower(ctx sdk.Ctx, power sdk.Int)

Set the prevState total validator power (used in moving the curr to prev)

func (Keeper) SetPreviousProposer

func (k Keeper) SetPreviousProposer(ctx sdk.Ctx, address sdk.Address)

set the proposer public key for this block

func (Keeper) SetStakedValidator

func (k Keeper) SetStakedValidator(ctx sdk.Ctx, validator types.Validator)

set staked validator

func (Keeper) SetUnstakingValidator

func (k Keeper) SetUnstakingValidator(ctx sdk.Ctx, val types.Validator)

Insert a validator address to the appropriate position in the unstaking queue

func (Keeper) SetValidator

func (k Keeper) SetValidator(ctx sdk.Ctx, validator types.Validator)

set a validator in the main store

func (Keeper) SetValidatorSigningInfo

func (k Keeper) SetValidatorSigningInfo(ctx sdk.Ctx, address sdk.Address, info types.ValidatorSigningInfo)

func (Keeper) SignedBlocksWindow

func (k Keeper) SignedBlocksWindow(ctx sdk.Ctx) (res int64)

SignedBlocksWindow - sliding window for downtime slashing

func (Keeper) SlashFractionDoubleSign

func (k Keeper) SlashFractionDoubleSign(ctx sdk.Ctx) (res sdk.Dec)

SlashFractionDoubleSign

func (Keeper) SlashFractionDowntime

func (k Keeper) SlashFractionDowntime(ctx sdk.Ctx) (res sdk.Dec)

SlashFractionDowntime

func (Keeper) StakeDenom

func (k Keeper) StakeDenom(ctx sdk.Ctx) (res string)

StakeDenom - Stakeable coin denomination

func (Keeper) StakeValidator

func (k Keeper) StakeValidator(ctx sdk.Ctx, validator types.Validator, amount sdk.Int)

store ops when a validator stakes

func (Keeper) StakedRatio

func (k Keeper) StakedRatio(ctx sdk.Ctx) sdk.Dec

StakedRatio the fraction of the staking tokens which are currently staked

func (Keeper) TotalTokens

func (k Keeper) TotalTokens(ctx sdk.Ctx) sdk.Int

TotalTokens staking tokens from the total supply

func (Keeper) UnStakingTime

func (k Keeper) UnStakingTime(ctx sdk.Ctx) (res time.Duration)

UnstakingTime

func (Keeper) UnjailValidator

func (k Keeper) UnjailValidator(ctx sdk.Ctx, addr sdk.Address)

remove a validator from jail

func (Keeper) UpdateTendermintValidators

func (k Keeper) UpdateTendermintValidators(ctx sdk.Ctx) (updates []abci.ValidatorUpdate)

Apply and return accumulated updates to the staked validator set It gets called once after genesis, another time maybe after genesis transactions, then once at every EndBlock.

func (Keeper) ValidateValidatorBeginUnstaking

func (k Keeper) ValidateValidatorBeginUnstaking(ctx sdk.Ctx, validator types.Validator) sdk.Error

func (Keeper) ValidateValidatorFinishUnstaking

func (k Keeper) ValidateValidatorFinishUnstaking(ctx sdk.Ctx, validator types.Validator) sdk.Error

func (Keeper) ValidateValidatorStaking

func (k Keeper) ValidateValidatorStaking(ctx sdk.Ctx, validator types.Validator, amount sdk.Int) sdk.Error

validate check called before staking

func (Keeper) Validator

func (k Keeper) Validator(ctx sdk.Ctx, address sdk.Address) exported.ValidatorI

wrapper for GetValidator call

Jump to

Keyboard shortcuts

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