stake

package
v0.0.5 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	DefaultCodeSpace btypes.CodespaceType = "stake"

	CodeInvalidInput            btypes.CodeType = 501 // 输入有误
	CodeOwnerNotExists          btypes.CodeType = 502 // Owner账户不存在
	CodeOwnerNoEnoughToken      btypes.CodeType = 503 // Owner账户Tokens不足
	CodeValidatorExists         btypes.CodeType = 504 // Validator已存在
	CodeOwnerHasValidator       btypes.CodeType = 505 // Owner已绑定有Validator
	CodeValidatorNotExists      btypes.CodeType = 506 // Validator不存在
	CodeValidatorIsActive       btypes.CodeType = 507 // Validator处于激活状态
	CodeValidatorIsInactive     btypes.CodeType = 508 // Validator处于非激活状态
	CodeValidatorInactiveIncome btypes.CodeType = 509 // Validator处于非激活状态时收益非法
)

stake errors reserve 500 ~ 599.

View Source
const (
	MaxNameLen        = 300
	MaxDescriptionLen = 1000
)

Variables

This section is empty.

Functions

func BeginBlocker

func BeginBlocker(ctx context.Context, req abci.RequestBeginBlock)

1. 统计validator投票信息, 将不活跃的validator转成Inactive状态

func CloseExpireInactiveValidator

func CloseExpireInactiveValidator(ctx context.Context, survivalSecs uint32)

func EndBlocker

func EndBlocker(ctx context.Context) (res abci.ResponseEndBlock)

1. 将所有Inactive到一定期限的validator删除 2. 统计新的validator

func EndBlockerByReturnUnbondTokens

func EndBlockerByReturnUnbondTokens(ctx context.Context)

unbond的token返还至delegator账户中

func ErrCodeValidatorInactiveIncome

func ErrCodeValidatorInactiveIncome(codeSpace btypes.CodespaceType, msg string) btypes.Error

func ErrInvalidInput

func ErrInvalidInput(codeSpace btypes.CodespaceType, msg string) btypes.Error

func ErrOwnerHasValidator

func ErrOwnerHasValidator(codeSpace btypes.CodespaceType, msg string) btypes.Error

func ErrOwnerNoEnoughToken

func ErrOwnerNoEnoughToken(codeSpace btypes.CodespaceType, msg string) btypes.Error

func ErrOwnerNotExists

func ErrOwnerNotExists(codeSpace btypes.CodespaceType, msg string) btypes.Error

func ErrValidatorExists

func ErrValidatorExists(codeSpace btypes.CodespaceType, msg string) btypes.Error

func ErrValidatorIsActive

func ErrValidatorIsActive(codeSpace btypes.CodespaceType, msg string) btypes.Error

func ErrValidatorIsInactive

func ErrValidatorIsInactive(codeSpace btypes.CodespaceType, msg string) btypes.Error

func ErrValidatorNotExists

func ErrValidatorNotExists(codeSpace btypes.CodespaceType, msg string) btypes.Error

func GetUpdatedValidators

func GetUpdatedValidators(ctx context.Context, maxValidatorCount uint64) []abci.ValidatorUpdate

func InitGenesis

func InitGenesis(ctx context.Context, data GenesisState)

func Query

func Query(ctx context.Context, route []string, req abci.RequestQuery) (res []byte, err btypes.Error)

func RegisterCodec

func RegisterCodec(cdc *amino.Codec)

func ReturnAllUnbondTokens

func ReturnAllUnbondTokens(ctx context.Context)

func ValidateGenesis

func ValidateGenesis(genesisAccounts []*types.QOSAccount, data GenesisState) error

Types

type DelegationInfoState

type DelegationInfoState struct {
	DelegatorAddr   btypes.Address `json:"delegator_addr"`
	ValidatorPubKey crypto.PubKey  `json:"validator_pub_key"`
	Amount          uint64         `json:"delegate_amount"`
	IsCompound      bool           `json:"is_compound"`
}

type DelegationQueryResult

type DelegationQueryResult struct {
	DelegatorAddr   btypes.Address `json:"delegator_address"`
	OwnerAddr       btypes.Address `json:"owner_address"`
	ValidatorPubKey crypto.PubKey  `json:"validator_pub_key"`
	Amount          uint64         `json:"delegate_amount"`
	IsCompound      bool           `json:"is_compound"`
}

func NewDelegationQueryResult

func NewDelegationQueryResult(deleAddr, ownerAddr btypes.Address, valPubkey crypto.PubKey, amount uint64, compound bool) DelegationQueryResult

type DelegatorUnbondState

type DelegatorUnbondState struct {
	DeleAddress btypes.Address `json:"delegator_address"`
	Height      uint64         `json:"height"`
	Amount      uint64         `json:"tokens"`
}

type GenesisState

type GenesisState struct {
	Params                 ecotypes.StakeParams             `json:"params"`
	Validators             []ecotypes.Validator             `json:"validators"`            //validatorKey, validatorByOwnerKey,validatorByInactiveKey,validatorByVotePowerKey
	ValidatorsVoteInfo     []ValidatorVoteInfoState         `json:"val_votes_info"`        //validatorVoteInfoKey
	ValidatorsVoteInWindow []ValidatorVoteInWindowInfoState `json:"val_votes_in_window"`   //validatorVoteInfoInWindowKey
	DelegatorsInfo         []DelegationInfoState            `json:"delegators_info"`       //DelegationByDelValKey, DelegationByValDelKey
	DelegatorsUnbondInfo   []DelegatorUnbondState           `json:"delegator_unbond_info"` //DelegatorUnbondingQOSatHeightKey
	CurrentValidators      []ecotypes.Validator             `json:"current_validators"`    // currentValidatorsAddressKey
}

func DefaultGenesisState

func DefaultGenesisState() GenesisState

func ExportGenesis

func ExportGenesis(ctx context.Context, forZeroHeight bool) GenesisState

func NewGenesisState

func NewGenesisState(params ecotypes.StakeParams,
	validators []ecotypes.Validator,
	validatorsVoteInfo []ValidatorVoteInfoState,
	validatorsVoteInWindow []ValidatorVoteInWindowInfoState,
	delegatorsInfo []DelegationInfoState,
	delegatorsUnbondInfo []DelegatorUnbondState,
	currentValidators []ecotypes.Validator) GenesisState

type TxActiveValidator

type TxActiveValidator struct {
	Owner btypes.Address //操作者
}

func NewActiveValidatorTx

func NewActiveValidatorTx(owner btypes.Address) *TxActiveValidator

func (*TxActiveValidator) CalcGas

func (tx *TxActiveValidator) CalcGas() btypes.BigInt

func (*TxActiveValidator) Exec

func (tx *TxActiveValidator) Exec(ctx context.Context) (result btypes.Result, crossTxQcp *txs.TxQcp)

func (*TxActiveValidator) GetGasPayer

func (tx *TxActiveValidator) GetGasPayer() btypes.Address

func (*TxActiveValidator) GetSignData

func (tx *TxActiveValidator) GetSignData() (ret []byte)

func (*TxActiveValidator) GetSigner

func (tx *TxActiveValidator) GetSigner() []btypes.Address

func (*TxActiveValidator) ValidateData

func (tx *TxActiveValidator) ValidateData(ctx context.Context) (err error)

type TxCreateDelegation

type TxCreateDelegation struct {
	Delegator      btypes.Address //委托人
	ValidatorOwner btypes.Address //验证者Owner
	Amount         uint64         //委托QOS数量
	IsCompound     bool           //定期收益是否复投
}

func (*TxCreateDelegation) CalcGas

func (tx *TxCreateDelegation) CalcGas() btypes.BigInt

func (*TxCreateDelegation) Exec

func (tx *TxCreateDelegation) Exec(ctx context.Context) (result btypes.Result, crossTxQcp *txs.TxQcp)

创建或新增委托

func (*TxCreateDelegation) GetGasPayer

func (tx *TxCreateDelegation) GetGasPayer() btypes.Address

func (*TxCreateDelegation) GetSignData

func (tx *TxCreateDelegation) GetSignData() (ret []byte)

func (*TxCreateDelegation) GetSigner

func (tx *TxCreateDelegation) GetSigner() []btypes.Address

func (*TxCreateDelegation) ValidateData

func (tx *TxCreateDelegation) ValidateData(ctx context.Context) (err error)

type TxCreateReDelegation

type TxCreateReDelegation struct {
	Delegator          btypes.Address //委托人
	FromValidatorOwner btypes.Address //原委托验证人Owner
	ToValidatorOwner   btypes.Address //现委托验证人Owner
	Amount             uint64         //委托数量
	IsRedelegateAll    bool           //
	IsCompound         bool           //
}

func (*TxCreateReDelegation) CalcGas

func (tx *TxCreateReDelegation) CalcGas() btypes.BigInt

func (*TxCreateReDelegation) Exec

func (tx *TxCreateReDelegation) Exec(ctx context.Context) (result btypes.Result, crossTxQcp *txs.TxQcp)

delegate from one to another

func (*TxCreateReDelegation) GetGasPayer

func (tx *TxCreateReDelegation) GetGasPayer() btypes.Address

func (*TxCreateReDelegation) GetSignData

func (tx *TxCreateReDelegation) GetSignData() (ret []byte)

func (*TxCreateReDelegation) GetSigner

func (tx *TxCreateReDelegation) GetSigner() []btypes.Address

func (*TxCreateReDelegation) ValidateData

func (tx *TxCreateReDelegation) ValidateData(ctx context.Context) error

type TxCreateValidator

type TxCreateValidator struct {
	Name        string
	Owner       btypes.Address //操作者, self delegator
	PubKey      crypto.PubKey  //validator公钥
	BondTokens  uint64         //绑定Token数量
	IsCompound  bool           //周期收益是否复投
	Description string
}

func NewCreateValidatorTx

func NewCreateValidatorTx(name string, owner btypes.Address, pubKey crypto.PubKey, bondTokens uint64, isCompound bool, description string) *TxCreateValidator

func (*TxCreateValidator) CalcGas

func (tx *TxCreateValidator) CalcGas() btypes.BigInt

func (*TxCreateValidator) Exec

func (tx *TxCreateValidator) Exec(ctx context.Context) (result btypes.Result, crossTxQcp *txs.TxQcp)

func (*TxCreateValidator) GetGasPayer

func (tx *TxCreateValidator) GetGasPayer() btypes.Address

func (*TxCreateValidator) GetSignData

func (tx *TxCreateValidator) GetSignData() (ret []byte)

func (*TxCreateValidator) GetSigner

func (tx *TxCreateValidator) GetSigner() []btypes.Address

func (*TxCreateValidator) ValidateData

func (tx *TxCreateValidator) ValidateData(ctx context.Context) (err error)

type TxModifyCompound

type TxModifyCompound struct {
	Delegator      btypes.Address //委托人
	ValidatorOwner btypes.Address //验证者Owner
	IsCompound     bool           //周期收益是否复投: 收益发放周期内多次修改,仅最后一次生效
}

func (*TxModifyCompound) CalcGas

func (tx *TxModifyCompound) CalcGas() btypes.BigInt

func (*TxModifyCompound) Exec

func (tx *TxModifyCompound) Exec(ctx context.Context) (result btypes.Result, crossTxQcp *txs.TxQcp)

修改收益单复利

func (*TxModifyCompound) GetGasPayer

func (tx *TxModifyCompound) GetGasPayer() btypes.Address

func (*TxModifyCompound) GetSignData

func (tx *TxModifyCompound) GetSignData() (ret []byte)

func (*TxModifyCompound) GetSigner

func (tx *TxModifyCompound) GetSigner() []btypes.Address

func (*TxModifyCompound) ValidateData

func (tx *TxModifyCompound) ValidateData(ctx context.Context) (err error)

type TxRevokeValidator

type TxRevokeValidator struct {
	Owner btypes.Address //操作者
}

func NewRevokeValidatorTx

func NewRevokeValidatorTx(owner btypes.Address) *TxRevokeValidator

func (*TxRevokeValidator) CalcGas

func (tx *TxRevokeValidator) CalcGas() btypes.BigInt

func (*TxRevokeValidator) Exec

func (tx *TxRevokeValidator) Exec(ctx context.Context) (result btypes.Result, crossTxQcp *txs.TxQcp)

func (*TxRevokeValidator) GetGasPayer

func (tx *TxRevokeValidator) GetGasPayer() btypes.Address

func (*TxRevokeValidator) GetSignData

func (tx *TxRevokeValidator) GetSignData() (ret []byte)

func (*TxRevokeValidator) GetSigner

func (tx *TxRevokeValidator) GetSigner() []btypes.Address

func (*TxRevokeValidator) ValidateData

func (tx *TxRevokeValidator) ValidateData(ctx context.Context) (err error)

type TxUnbondDelegation

type TxUnbondDelegation struct {
	Delegator      btypes.Address //委托人
	ValidatorOwner btypes.Address //验证者Owner
	UnbondAmount   uint64         //unbond数量
	IsUnbondAll    bool           //是否全部解绑, 为true时覆盖UnbondAmount
}

func (*TxUnbondDelegation) CalcGas

func (tx *TxUnbondDelegation) CalcGas() btypes.BigInt

func (*TxUnbondDelegation) Exec

func (tx *TxUnbondDelegation) Exec(ctx context.Context) (result btypes.Result, crossTxQcp *txs.TxQcp)

unbond delegator tokens

func (*TxUnbondDelegation) GetGasPayer

func (tx *TxUnbondDelegation) GetGasPayer() btypes.Address

func (*TxUnbondDelegation) GetSignData

func (tx *TxUnbondDelegation) GetSignData() (ret []byte)

func (*TxUnbondDelegation) GetSigner

func (tx *TxUnbondDelegation) GetSigner() []btypes.Address

func (*TxUnbondDelegation) ValidateData

func (tx *TxUnbondDelegation) ValidateData(ctx context.Context) error

type ValidatorVoteInWindowInfoState

type ValidatorVoteInWindowInfoState struct {
	ValidatorPubKey crypto.PubKey `json:"validator_pub_key"`
	Index           uint64        `json:"index"`
	Vote            bool          `json:"vote"`
}

type ValidatorVoteInfoState

type ValidatorVoteInfoState struct {
	ValidatorPubKey crypto.PubKey              `json:"validator_pub_key"`
	VoteInfo        ecotypes.ValidatorVoteInfo `json:"vote_info"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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