keeper

package
v0.2.2 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: 13 Imported by: 0

Documentation

Index

Constants

View Source
const MaxCacheLength = 500

Variables

View Source
var (
	// Keys for store prefixes
	ParamKey                         = []byte{0x00} // key for parameters relating to staking
	PoolKey                          = []byte{0x01} // key for the staking pools
	ValidatorsKey                    = []byte{0x02} // prefix for each key to a validator
	ValidatorsByConsAddrKey          = []byte{0x03} // prefix for each key to a validator index, by pubkey
	ValidatorsBondedIndexKey         = []byte{0x04} // prefix for each key to a validator index, for bonded validators
	ValidatorsByPowerIndexKey        = []byte{0x05} // prefix for each key to a validator index, sorted by power
	IntraTxCounterKey                = []byte{0x06} // key for intra-block tx index
	DelegationKey                    = []byte{0x07} // key for a delegation
	UnbondingDelegationKey           = []byte{0x08} // key for an unbonding-delegation
	UnbondingDelegationByValIndexKey = []byte{0x09} // prefix for each key for an unbonding-delegation, by validator operator
	RedelegationKey                  = []byte{0x0A} // key for a redelegation
	RedelegationByValSrcIndexKey     = []byte{0x0B} // prefix for each key for an redelegation, by source validator operator
	RedelegationByValDstIndexKey     = []byte{0x0C} // prefix for each key for an redelegation, by destination validator operator
	ValidatorDistKey                 = []byte{0x0D} // prefix for each key for validator distribution information
	ValidatorsTDMAddrKey             = []byte{0x0E} // prefix for mapping from TDM address to Shareledger address
	// Last* values are const during a block.
	LastValidatorPowerKey = []byte{0x11} // prefix for each key to a validator index, for bonded validators
	LastTotalPowerKey     = []byte{0x12} // prefix for the total power

)

nolint

Functions

func GetDelegationKey

func GetDelegationKey(delAddr sdk.AccAddress, valAddr sdk.AccAddress) []byte

gets the key for delegator bond with validator VALUE: stake/types.Delegation

func GetDelegationsKey

func GetDelegationsKey(delAddr sdk.AccAddress) []byte

gets the prefix for a delegator for all validators

func GetLastValidatorPowerKey

func GetLastValidatorPowerKey(operator sdk.AccAddress) []byte

get the bonded validator index key for an operator address

func GetREDByValDstIndexKey

func GetREDByValDstIndexKey(delAddr sdk.AccAddress, valSrcAddr, valDstAddr sdk.AccAddress) []byte

gets the index-key for a redelegation, stored by destination-validator-index VALUE: none (key rearrangement used)

func GetREDByValSrcIndexKey

func GetREDByValSrcIndexKey(delAddr sdk.AccAddress, valSrcAddr, valDstAddr sdk.AccAddress) []byte

gets the index-key for a redelegation, stored by source-validator-index VALUE: none (key rearrangement used)

func GetREDKey

func GetREDKey(delAddr sdk.AccAddress, valSrcAddr, valDstAddr sdk.AccAddress) []byte

gets the key for a redelegation VALUE: stake/types.RedelegationKey

func GetREDKeyFromValDstIndexKey

func GetREDKeyFromValDstIndexKey(IndexKey []byte) []byte

rearranges the ValDstIndexKey to get the REDKey

func GetREDKeyFromValSrcIndexKey

func GetREDKeyFromValSrcIndexKey(IndexKey []byte) []byte

rearranges the ValSrcIndexKey to get the REDKey

func GetREDsByDelToValDstIndexKey

func GetREDsByDelToValDstIndexKey(delAddr sdk.AccAddress, valDstAddr sdk.AccAddress) []byte

gets the prefix keyspace for all redelegations redelegating towards a destination validator from a particular delegator

func GetREDsFromValSrcIndexKey

func GetREDsFromValSrcIndexKey(valSrcAddr sdk.AccAddress) []byte

gets the prefix keyspace for all redelegations redelegating away from a source validator

func GetREDsKey

func GetREDsKey(delAddr sdk.AccAddress) []byte

gets the prefix keyspace for redelegations from a delegator

func GetREDsToValDstIndexKey

func GetREDsToValDstIndexKey(valDstAddr sdk.AccAddress) []byte

gets the prefix keyspace for all redelegations redelegating towards a destination validator

func GetTdmAddressKey added in v0.2.1

func GetTdmAddressKey(tdmAddress []byte) []byte

func GetUBDByValIndexKey

func GetUBDByValIndexKey(delAddr sdk.AccAddress, valAddr sdk.AccAddress) []byte

gets the index-key for an unbonding delegation, stored by validator-index VALUE: none (key rearrangement used)

func GetUBDKey

func GetUBDKey(delAddr sdk.AccAddress, valAddr sdk.AccAddress) []byte

gets the key for an unbonding delegation by delegator and validator addr VALUE: stake/types.UnbondingDelegation

func GetUBDsByValIndexKey

func GetUBDsByValIndexKey(valAddr sdk.AccAddress) []byte

gets the prefix keyspace for the indexes of unbonding delegations for a validator

func GetUBDsKey

func GetUBDsKey(delAddr sdk.AccAddress) []byte

gets the prefix for all unbonding delegations from a delegator

func GetValidatorByConsAddrKey

func GetValidatorByConsAddrKey(addr sdk.AccAddress) []byte

gets the key for the validator with pubkey VALUE: validator operator address ([]byte)

func GetValidatorDistKey

func GetValidatorDistKey(operatorAddr sdk.AccAddress) []byte

func GetValidatorKey

func GetValidatorKey(operatorAddr sdk.AccAddress) []byte

gets the key for the validator with address VALUE: stake/types.Validator

func GetValidatorsByPowerIndexKey

func GetValidatorsByPowerIndexKey(validator posTypes.Validator, pool posTypes.Pool) []byte

get the validator by power index. Power index is the key used in the power-store, and represents the relative power ranking of the validator. VALUE: validator operator address ([]byte)

Types

type Keeper

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

func NewKeeper

func NewKeeper(posKey sdk.StoreKey, bk bank.Keeper, cdc *amino.Codec) Keeper

func (Keeper) AddValidatorTokensAndShares

func (k Keeper) AddValidatorTokensAndShares(ctx sdk.Context, validator posTypes.Validator,
	tokensToAdd types.Dec) (valOut posTypes.Validator, addedShares types.Dec)

Update the tokens of an existing validator, update the validators power index key

func (Keeper) BeginRedelegation

func (k Keeper) BeginRedelegation(ctx sdk.Context, delAddr sdk.AccAddress,
	valSrcAddr, valDstAddr sdk.AccAddress, sharesAmount types.Dec) sdk.Error

func (Keeper) BeginUnbonding

func (k Keeper) BeginUnbonding(ctx sdk.Context,
	delAddr sdk.AccAddress, valAddr sdk.AccAddress, sharesAmount types.Dec) sdk.Error

func (Keeper) Codespace

func (k Keeper) Codespace() sdk.CodespaceType

return the codespace

func (Keeper) CompleteRedelegation

func (k Keeper) CompleteRedelegation(ctx sdk.Context, delAddr sdk.AccAddress,
	valSrcAddr, valDstAddr sdk.AccAddress) sdk.Error

complete unbonding an ongoing redelegation

func (Keeper) CompleteUnbonding

func (k Keeper) CompleteUnbonding(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.AccAddress) sdk.Error

complete unbonding an unbonding record

func (Keeper) Delegate

func (k Keeper) Delegate(ctx sdk.Context, delAddr sdk.AccAddress, bondAmt types.Coin,
	validator posTypes.Validator, subtractAccount bool) (newShares types.Dec, err sdk.Error)

Perform a delegation, set/update everything necessary within the store.

func (Keeper) DeleteLastValidatorPower

func (k Keeper) DeleteLastValidatorPower(ctx sdk.Context, operator sdk.AccAddress)

Delete the last validator power.

func (Keeper) DeleteValidatorByPowerIndex

func (k Keeper) DeleteValidatorByPowerIndex(ctx sdk.Context, validator posTypes.Validator, pool posTypes.Pool)

validator index

func (Keeper) GetAllDelegations

func (k Keeper) GetAllDelegations(ctx sdk.Context) (delegations []posTypes.Delegation)

return all delegations during POS withdrawlReward

func (Keeper) GetDelegation

func (k Keeper) GetDelegation(ctx sdk.Context,
	delAddr sdk.AccAddress, valAddr sdk.AccAddress) (
	delegation posTypes.Delegation, found bool)

return a specific delegation

func (Keeper) GetIntraTxCounter

func (k Keeper) GetIntraTxCounter(ctx sdk.Context) int16

get the current in-block validator operation counter

func (Keeper) GetParams

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

load/save the global staking params

func (Keeper) GetPool

func (k Keeper) GetPool(ctx sdk.Context) (pool posTypes.Pool)

load/save the pool

func (Keeper) GetRedelegation

func (k Keeper) GetRedelegation(ctx sdk.Context,
	delAddr sdk.AccAddress, valSrcAddr, valDstAddr sdk.AccAddress) (red posTypes.Redelegation, found bool)

return a redelegation

func (Keeper) GetRedelegations

func (k Keeper) GetRedelegations(ctx sdk.Context, delegator sdk.AccAddress,
	maxRetrieve uint16) (redelegations []posTypes.Redelegation)

return a given amount of all the delegator redelegations

func (Keeper) GetUnbondingDelegation

func (k Keeper) GetUnbondingDelegation(ctx sdk.Context,
	delAddr sdk.AccAddress, valAddr sdk.AccAddress) (ubd posTypes.UnbondingDelegation, found bool)

return a unbonding delegation

func (Keeper) GetUnbondingDelegations

func (k Keeper) GetUnbondingDelegations(ctx sdk.Context, delegator sdk.AccAddress,
	maxRetrieve uint16) (unbondingDelegations []posTypes.UnbondingDelegation)

return a given amount of all the delegator unbonding-delegations

func (Keeper) GetValidator

func (k Keeper) GetValidator(ctx sdk.Context, addr sdk.AccAddress) (validator posTypes.Validator, found bool)

get a single validator

func (Keeper) GetValidatorByTDMAddress added in v0.2.1

func (k Keeper) GetValidatorByTDMAddress(
	ctx sdk.Context, tdmAddress []byte,
) (
	validator posTypes.Validator, found bool,
)

GetValidatorByTDMAddress - get validator by Tendermint Address

func (Keeper) GetValidatorDistInfo

func (k Keeper) GetValidatorDistInfo(
	ctx sdk.Context, addr sdk.AccAddress,
) (
	vdi posTypes.ValidatorDistInfo, found bool,
)

func (Keeper) GetValidatorSetUpdates

func (k Keeper) GetValidatorSetUpdates(ctx sdk.Context) []abci.ValidatorUpdate

func (Keeper) GetValidators

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

return a given amount of all the validators

func (Keeper) HasReceivingRedelegation

func (k Keeper) HasReceivingRedelegation(ctx sdk.Context,
	delAddr sdk.AccAddress, valDstAddr sdk.AccAddress) bool

check if validator is receiving a redelegation

func (Keeper) InitIntraTxCounter

func (k Keeper) InitIntraTxCounter(ctx sdk.Context)

get the current in-block validator operation counter

func (Keeper) RemoveDelegation

func (k Keeper) RemoveDelegation(ctx sdk.Context, delegation posTypes.Delegation)

remove a delegation from store

func (Keeper) RemoveRedelegation

func (k Keeper) RemoveRedelegation(ctx sdk.Context, red posTypes.Redelegation)

remove a redelegation object and associated index

func (Keeper) RemoveUnbondingDelegation

func (k Keeper) RemoveUnbondingDelegation(ctx sdk.Context, ubd posTypes.UnbondingDelegation)

remove the unbonding delegation object and associated index

func (Keeper) RemoveValidator

func (k Keeper) RemoveValidator(ctx sdk.Context, address sdk.AccAddress)

remove the validator record and associated indexes

func (Keeper) RemoveValidatorTokensAndShares

func (k Keeper) RemoveValidatorTokensAndShares(ctx sdk.Context, validator posTypes.Validator,
	sharesToRemove types.Dec) (valOut posTypes.Validator, removedTokens types.Dec)

Update the tokens of an existing validator, update the validators power index key

func (Keeper) SetAddressByTDMAddress added in v0.2.1

func (k Keeper) SetAddressByTDMAddress(
	ctx sdk.Context, tdmAddress []byte, address sdk.AccAddress,
)

SetAddressByTDMAddress - set ShareledgerAddress by TDMAddress to later retrieve during POS processing

func (Keeper) SetDelegation

func (k Keeper) SetDelegation(ctx sdk.Context, delegation posTypes.Delegation)

set the delegation

func (Keeper) SetIntraTxCounter

func (k Keeper) SetIntraTxCounter(ctx sdk.Context, counter int16)

set the current in-block validator operation counter

func (Keeper) SetLastTotalPower

func (k Keeper) SetLastTotalPower(ctx sdk.Context, power sdk.Int)

Set the last total validator power.

func (Keeper) SetLastValidatorPower

func (k Keeper) SetLastValidatorPower(ctx sdk.Context, operator sdk.AccAddress, power sdk.Int)

Set the last validator power.

func (Keeper) SetNewValidatorByPowerIndex

func (k Keeper) SetNewValidatorByPowerIndex(ctx sdk.Context, validator posTypes.Validator)

validator index

func (Keeper) SetParams

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

set the params

func (Keeper) SetPool

func (k Keeper) SetPool(ctx sdk.Context, pool posTypes.Pool)

set the pool

func (Keeper) SetRedelegation

func (k Keeper) SetRedelegation(ctx sdk.Context, red posTypes.Redelegation)

set a redelegation and associated index

func (Keeper) SetUnbondingDelegation

func (k Keeper) SetUnbondingDelegation(ctx sdk.Context, ubd posTypes.UnbondingDelegation)

set the unbonding delegation and associated index

func (Keeper) SetValidator

func (k Keeper) SetValidator(ctx sdk.Context, validator posTypes.Validator)

set the main record holding validator details

func (Keeper) SetValidatorByPowerIndex

func (k Keeper) SetValidatorByPowerIndex(ctx sdk.Context, validator posTypes.Validator, pool posTypes.Pool)

validator index

func (Keeper) SetValidatorDistInfo

func (k Keeper) SetValidatorDistInfo(
	ctx sdk.Context, vdi posTypes.ValidatorDistInfo,
)

func (Keeper) UpdateBlockReward

func (k Keeper) UpdateBlockReward(
	ctx sdk.Context,
	validatorAddr sdk.AccAddress,
	commissionRate types.Dec,
	rewardPerBlock types.Coin,
) (
	posTypes.ValidatorDistInfo, sdk.Error,
)

UpdateBlockReward is called everytime this validator is selected as forger

func (Keeper) UpdateDelAccum

func (k Keeper) UpdateDelAccum(
	ctx sdk.Context,
	validatorAddr sdk.AccAddress,
	currentHeight int64,
) (
	posTypes.ValidatorDistInfo, sdk.Error,
)

UpdateDelAccum - Update Delegation Accum of a certain delegator is called everytime reward delegation settlement

func (Keeper) WithdrawDelReward

func (k Keeper) WithdrawDelReward(
	ctx sdk.Context,
	validatorAddr sdk.AccAddress,
	delegatorAddr sdk.AccAddress,
) (posTypes.ValidatorDistInfo, types.Coin, sdk.Error)

Jump to

Keyboard shortcuts

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