staking

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2020 License: GPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultValue = []byte{0x01} // Value to store in CacheCheckpoint and CacheCheckpointACK & ValidatorSetChange Flag

	ValidatorsKey             = []byte{0x21} // prefix for each key to a validator
	ValidatorMapKey           = []byte{0x22} // prefix for each key for validator map
	CurrentValidatorSetKey    = []byte{0x23} // Key to store current validator set
	PrevDividendAccountMapKey = []byte{0x41} // store for dividend accounts before checkpoint ack.
	DividendAccountMapKey     = []byte{0x42} // prefix for each key for Dividend Account Map
	StakingSequenceKey        = []byte{0x24} // prefix for each key for staking sequence map
)

Functions

func ExportGenesis

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

ExportGenesis returns a GenesisState for a given context and keeper.

func GetDividendAccountMapKey

func GetDividendAccountMapKey(id []byte) []byte

GetDividendAccountMapKey returns dividend account map

func GetPrevDividendAccountMapKey

func GetPrevDividendAccountMapKey(id []byte) []byte

GetPrevDividendAccountMapKey returns prev dividend account map

func GetStakingSequenceKey

func GetStakingSequenceKey(sequence string) []byte

GetStakingSequenceKey returns staking sequence key

func GetValidatorKey

func GetValidatorKey(address []byte) []byte

GetValidatorKey drafts the validator key for addresses

func GetValidatorMapKey

func GetValidatorMapKey(address []byte) []byte

GetValidatorMapKey returns validator map

func HandleMsgSignerUpdate

func HandleMsgSignerUpdate(ctx sdk.Context, msg types.MsgSignerUpdate, k Keeper, contractCaller helper.IContractCaller) sdk.Result

HandleMsgSignerUpdate handles signer update message

func HandleMsgStakeUpdate

func HandleMsgStakeUpdate(ctx sdk.Context, msg types.MsgStakeUpdate, k Keeper, contractCaller helper.IContractCaller) sdk.Result

HandleMsgStakeUpdate handles stake update message

func HandleMsgValidatorExit

func HandleMsgValidatorExit(ctx sdk.Context, msg types.MsgValidatorExit, k Keeper, contractCaller helper.IContractCaller) sdk.Result

HandleMsgValidatorExit handle msg validator exit

func HandleMsgValidatorJoin

func HandleMsgValidatorJoin(ctx sdk.Context, msg types.MsgValidatorJoin, k Keeper, contractCaller helper.IContractCaller) sdk.Result

HandleMsgValidatorJoin msg validator join

func InitGenesis

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

InitGenesis sets distribution information for genesis.

func NewHandler

func NewHandler(k Keeper, contractCaller helper.IContractCaller) sdk.Handler

NewHandler new handler

func NewQuerier

func NewQuerier(keeper Keeper) sdk.Querier

NewQuerier returns querier for staking Rest endpoints

Types

type AppModule

type AppModule struct {
	AppModuleBasic
	// contains filtered or unexported fields
}

AppModule implements an application module for the supply module.

func NewAppModule

func NewAppModule(keeper Keeper, contractCaller helper.IContractCaller) AppModule

NewAppModule creates a new AppModule object

func (AppModule) BeginBlock

func (AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock)

BeginBlock returns the begin blocker for the auth module.

func (AppModule) EndBlock

EndBlock returns the end blocker for the auth module. It returns no validator updates.

func (AppModule) ExportGenesis

func (am AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage

ExportGenesis returns the exported genesis state as raw bytes for the auth module.

func (AppModule) InitGenesis

func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.ValidatorUpdate

InitGenesis performs genesis initialization for the auth module. It returns no validator updates.

func (AppModule) Name

func (AppModule) Name() string

Name returns the module's name.

func (AppModule) NewHandler

func (am AppModule) NewHandler() sdk.Handler

NewHandler returns an sdk.Handler for the module.

func (AppModule) NewQuerierHandler

func (am AppModule) NewQuerierHandler() sdk.Querier

NewQuerierHandler returns the auth module sdk.Querier.

func (AppModule) QuerierRoute

func (AppModule) QuerierRoute() string

QuerierRoute returns the staking module's querier route name.

func (AppModule) RegisterInvariants

func (AppModule) RegisterInvariants(_ sdk.InvariantRegistry)

RegisterInvariants performs a no-op.

func (AppModule) Route

func (AppModule) Route() string

Route returns the message routing key for the module.

type AppModuleBasic

type AppModuleBasic struct{}

AppModuleBasic defines the basic application module used by the auth module.

func (AppModuleBasic) DefaultGenesis

func (AppModuleBasic) DefaultGenesis() json.RawMessage

DefaultGenesis returns default genesis state as raw bytes for the auth module.

func (AppModuleBasic) GetQueryCmd

func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command

GetQueryCmd returns the root query command for the auth module.

func (AppModuleBasic) GetTxCmd

func (AppModuleBasic) GetTxCmd(cdc *codec.Codec) *cobra.Command

GetTxCmd returns the root tx command for the auth module.

func (AppModuleBasic) Name

func (AppModuleBasic) Name() string

Name returns the auth module's name.

func (AppModuleBasic) RegisterCodec

func (AppModuleBasic) RegisterCodec(cdc *codec.Codec)

RegisterCodec registers the auth module's types for the given codec.

func (AppModuleBasic) RegisterRESTRoutes

func (AppModuleBasic) RegisterRESTRoutes(ctx context.CLIContext, rtr *mux.Router)

RegisterRESTRoutes registers the REST routes for the auth module.

func (AppModuleBasic) ValidateGenesis

func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error

ValidateGenesis performs genesis state validation for the auth module.

func (AppModuleBasic) VerifyGenesis

func (AppModuleBasic) VerifyGenesis(bz map[string]json.RawMessage) error

VerifyGenesis performs verification on auth module state.

type Keeper

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

Keeper stores all related data

func NewKeeper

func NewKeeper(
	cdc *codec.Codec,
	storeKey sdk.StoreKey,
	paramSpace subspace.Subspace,
	codespace sdk.CodespaceType,
	chainKeeper chainmanager.Keeper,
	moduleCommunicator ModuleCommunicator,
) Keeper

NewKeeper create new keeper

func (*Keeper) AddDividendAccount

func (k *Keeper) AddDividendAccount(ctx sdk.Context, dividendAccount hmTypes.DividendAccount) error

AddDividendAccount adds DividendAccount index with DividendID

func (*Keeper) AddFeeToDividendAccount

func (k *Keeper) AddFeeToDividendAccount(ctx sdk.Context, valID hmTypes.ValidatorID, fee *big.Int) sdk.Error

AddFeeToDividendAccount adds fee to dividend account for withdrawal

func (*Keeper) AddValidator

func (k *Keeper) AddValidator(ctx sdk.Context, validator hmTypes.Validator) error

AddValidator adds validator indexed with address

func (*Keeper) CheckIfDividendAccountExists

func (k *Keeper) CheckIfDividendAccountExists(ctx sdk.Context, dividendID hmTypes.DividendAccountID) (ok bool)

CheckIfDividendAccountExists will return true if dividend account exists

func (Keeper) Codespace

func (k Keeper) Codespace() sdk.CodespaceType

Codespace returns the codespace

func (*Keeper) GetActiveValidatorInfo

func (k *Keeper) GetActiveValidatorInfo(ctx sdk.Context, address []byte) (validator hmTypes.Validator, err error)

GetActiveValidatorInfo returns active validator

func (*Keeper) GetAllDividendAccounts

func (k *Keeper) GetAllDividendAccounts(ctx sdk.Context) (dividendAccounts []hmTypes.DividendAccount)

GetAllDividendAccounts returns all DividendAccountss

func (*Keeper) GetAllValidators

func (k *Keeper) GetAllValidators(ctx sdk.Context) (validators []*hmTypes.Validator)

GetAllValidators returns all validators

func (*Keeper) GetCurrentProposer

func (k *Keeper) GetCurrentProposer(ctx sdk.Context) *hmTypes.Validator

GetCurrentProposer returns current proposer

func (*Keeper) GetCurrentValidators

func (k *Keeper) GetCurrentValidators(ctx sdk.Context) (validators []hmTypes.Validator)

GetCurrentValidators returns all validators who are in validator set

func (*Keeper) GetDividendAccountByID

func (k *Keeper) GetDividendAccountByID(ctx sdk.Context, dividendID hmTypes.DividendAccountID) (dividendAccount hmTypes.DividendAccount, err error)

GetDividendAccountByID will return DividendAccount of valID

func (*Keeper) GetLastUpdated

func (k *Keeper) GetLastUpdated(ctx sdk.Context, valID hmTypes.ValidatorID) (updatedAt string, found bool)

GetLastUpdated get last updated at for validator

func (*Keeper) GetNextProposer

func (k *Keeper) GetNextProposer(ctx sdk.Context) *hmTypes.Validator

GetNextProposer returns next proposer

func (*Keeper) GetSignerFromValidatorID

func (k *Keeper) GetSignerFromValidatorID(ctx sdk.Context, valID hmTypes.ValidatorID) (common.Address, bool)

GetSignerFromValidatorID get signer address from validator ID

func (*Keeper) GetSpanEligibleValidators

func (k *Keeper) GetSpanEligibleValidators(ctx sdk.Context) (validators []hmTypes.Validator)

GetSpanEligibleValidators returns current validators who are not getting deactivated in between next span

func (*Keeper) GetStakingSequences

func (k *Keeper) GetStakingSequences(ctx sdk.Context) (sequences []string)

GetStakingSequences checks if Staking already exists

func (*Keeper) GetValidatorFromValID

func (k *Keeper) GetValidatorFromValID(ctx sdk.Context, valID hmTypes.ValidatorID) (validator hmTypes.Validator, ok bool)

GetValidatorFromValID returns signer from validator ID

func (*Keeper) GetValidatorInfo

func (k *Keeper) GetValidatorInfo(ctx sdk.Context, address []byte) (validator hmTypes.Validator, err error)

GetValidatorInfo returns validator

func (*Keeper) GetValidatorSet

func (k *Keeper) GetValidatorSet(ctx sdk.Context) (validatorSet hmTypes.ValidatorSet)

GetValidatorSet returns current Validator Set from store

func (*Keeper) HasStakingSequence

func (k *Keeper) HasStakingSequence(ctx sdk.Context, sequence string) bool

HasStakingSequence checks if staking sequence already exists

func (*Keeper) IncrementAccum

func (k *Keeper) IncrementAccum(ctx sdk.Context, times int)

IncrementAccum increments accum for validator set by n times and replace validator set in store

func (*Keeper) IsCurrentValidatorByAddress

func (k *Keeper) IsCurrentValidatorByAddress(ctx sdk.Context, address []byte) bool

IsCurrentValidatorByAddress check if validator is in current validator set by signer address

func (*Keeper) IterateCurrentValidatorsAndApplyFn

func (k *Keeper) IterateCurrentValidatorsAndApplyFn(ctx sdk.Context, f func(validator *hmTypes.Validator) bool)

IterateCurrentValidatorsAndApplyFn iterate through current validators

func (*Keeper) IterateDividendAccountsByPrefixAndApplyFn

func (k *Keeper) IterateDividendAccountsByPrefixAndApplyFn(ctx sdk.Context, prefix []byte, f func(dividendAccount hmTypes.DividendAccount) error)

IterateDividendAccountsByPrefixAndApplyFn iterate dividendAccounts and apply the given function.

func (*Keeper) IterateStakingSequencesAndApplyFn

func (k *Keeper) IterateStakingSequencesAndApplyFn(ctx sdk.Context, f func(sequence string) error)

IterateStakingSequencesAndApplyFn interate validators and apply the given function.

func (*Keeper) IterateValidatorsAndApplyFn

func (k *Keeper) IterateValidatorsAndApplyFn(ctx sdk.Context, f func(validator hmTypes.Validator) error)

IterateValidatorsAndApplyFn interate validators and apply the given function.

func (Keeper) Logger

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

Logger returns a module-specific logger

func (*Keeper) SetStakingSequence

func (k *Keeper) SetStakingSequence(ctx sdk.Context, sequence string)

SetStakingSequence sets staking sequence

func (*Keeper) SetValidatorIDToSignerAddr

func (k *Keeper) SetValidatorIDToSignerAddr(ctx sdk.Context, valID hmTypes.ValidatorID, signerAddr hmTypes.HeimdallAddress)

SetValidatorIDToSignerAddr sets mapping for validator ID to signer address

func (*Keeper) UpdateSigner

func (k *Keeper) UpdateSigner(ctx sdk.Context, newSigner hmTypes.HeimdallAddress, newPubkey hmTypes.PubKey, prevSigner hmTypes.HeimdallAddress) error

UpdateSigner updates validator with signer and pubkey + validator => signer map

func (*Keeper) UpdateValidatorSetInStore

func (k *Keeper) UpdateValidatorSetInStore(ctx sdk.Context, newValidatorSet hmTypes.ValidatorSet) error

UpdateValidatorSetInStore adds validator set to store

type ModuleCommunicator

type ModuleCommunicator interface {
	GetACKCount(ctx sdk.Context) uint64
	SetCoins(ctx sdk.Context, addr hmTypes.HeimdallAddress, amt hmTypes.Coins) sdk.Error
	GetCoins(ctx sdk.Context, addr hmTypes.HeimdallAddress) hmTypes.Coins
	SendCoins(ctx sdk.Context, from hmTypes.HeimdallAddress, to hmTypes.HeimdallAddress, amt hmTypes.Coins) sdk.Error
}

ModuleCommunicator manages different module interaction

Directories

Path Synopsis
client
cli

Jump to

Keyboard shortcuts

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