types

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: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MintMapperName = "mint"
	MintParamsKey  = "mintparams"
)
View Source
const (
	ValidatorMapperName  = "validator"
	VoteInfoMapperName   = "voteInfo"
	DelegationMapperName = "delegation"

	//------query-------
	Stake       = "stake"
	Delegation  = "delegation"
	Delegations = "delegations"
	Owner       = "owner"
	Delegator   = "delegator"

	Distribution        = "distribution"
	ValidatorPeriodInfo = "validatorPeriodInfo"
	DelegatorIncomeInfo = "delegatorIncomeInfo"
)
View Source
const (
	//Active 可获得挖矿奖励状态
	Active int8 = iota

	//Inactive
	Inactive

	//Inactive Code
	Revoke        InactiveCode = iota // 2
	MissVoteBlock                     // 3
	MaxValidator                      // 4
)
View Source
const (
	AddrLen = 20
)
View Source
const (
	DistributionMapperName = "distribution"
)

Variables

View Source
var (
	DelegationByDelValKey            = []byte{0x31} // key: delegator add + validator owner add, value: delegationInfo
	DelegationByValDelKey            = []byte{0x32} // key: validator owner add + delegator add, value: nil
	DelegatorUnbondingQOSatHeightKey = []byte{0x41} // key: height + delegator add, value: the amount of qos going to be unbonded on this height

)

Functions

func BuildBlockDistributionKey

func BuildBlockDistributionKey() []byte

func BuildCommunityFeePoolKey

func BuildCommunityFeePoolKey() []byte

func BuildCurrentValidatorsAddressKey

func BuildCurrentValidatorsAddressKey() []byte

func BuildDelegationByDelValKey

func BuildDelegationByDelValKey(delAdd btypes.Address, valAdd btypes.Address) []byte

func BuildDelegationByValDelKey

func BuildDelegationByValDelKey(valAdd btypes.Address, delAdd btypes.Address) []byte

func BuildDelegatorEarningStartInfoKey

func BuildDelegatorEarningStartInfoKey(validatorAddr btypes.Address, delegatorAddress btypes.Address) []byte

func BuildDelegatorPeriodIncomeKey

func BuildDelegatorPeriodIncomeKey(validatorAddr, delegatorAddress btypes.Address, height uint64) []byte

func BuildDelegatorPeriodIncomePrefixKey

func BuildDelegatorPeriodIncomePrefixKey(height uint64) []byte

func BuildDistributeParamsKey

func BuildDistributeParamsKey() []byte

func BuildFirstBlockTimeKey

func BuildFirstBlockTimeKey() []byte

func BuildGetDelegationCustomQueryPath

func BuildGetDelegationCustomQueryPath(deleAddr, owner btypes.Address) string

func BuildInactiveValidatorKey

func BuildInactiveValidatorKey(sec uint64, valAddress btypes.Address) []byte

func BuildInactiveValidatorKeyByTime

func BuildInactiveValidatorKeyByTime(inactiveTime time.Time, valAddress btypes.Address) []byte

func BuildLastProposerKey

func BuildLastProposerKey() []byte

func BuildMintParamsKey

func BuildMintParamsKey() []byte

func BuildOwnerWithValidatorKey

func BuildOwnerWithValidatorKey(ownerAddress btypes.Address) []byte

func BuildQueryDelegationsByDelegatorCustomQueryPath

func BuildQueryDelegationsByDelegatorCustomQueryPath(deleAddr btypes.Address) string

func BuildQueryDelegationsByOwnerCustomQueryPath

func BuildQueryDelegationsByOwnerCustomQueryPath(owner btypes.Address) string

func BuildQueryDelegatorIncomeInfoCustomQueryPath

func BuildQueryDelegatorIncomeInfoCustomQueryPath(delegator, owner btypes.Address) string

func BuildQueryValidatorPeriodInfoCustomQueryPath

func BuildQueryValidatorPeriodInfoCustomQueryPath(owner btypes.Address) string

func BuildStakeParamsKey

func BuildStakeParamsKey() []byte

func BuildUnbondingDelegationByHeightDelKey

func BuildUnbondingDelegationByHeightDelKey(height uint64, delAdd btypes.Address) []byte

func BuildUnbondingDelegationByHeightPrefix

func BuildUnbondingDelegationByHeightPrefix(height uint64) []byte

func BuildValidatorByVotePower

func BuildValidatorByVotePower(votePower uint64, valAddress btypes.Address) []byte

func BuildValidatorCurrentPeriodSummaryKey

func BuildValidatorCurrentPeriodSummaryKey(validatorAddr btypes.Address) []byte

func BuildValidatorHistoryPeriodSummaryKey

func BuildValidatorHistoryPeriodSummaryKey(validatorAddr btypes.Address, period uint64) []byte

func BuildValidatorKey

func BuildValidatorKey(valAddress btypes.Address) []byte

func BuildValidatorStoreQueryPath

func BuildValidatorStoreQueryPath() []byte

func BuildValidatorVoteInfoInWindowKey

func BuildValidatorVoteInfoInWindowKey(index uint64, valAddress btypes.Address) []byte

func BuildValidatorVoteInfoInWindowPrefixKey

func BuildValidatorVoteInfoInWindowPrefixKey(valAddress btypes.Address) []byte

func BuildValidatorVoteInfoKey

func BuildValidatorVoteInfoKey(valAddress btypes.Address) []byte

func BuildVoteInfoStoreQueryPath

func BuildVoteInfoStoreQueryPath() []byte

func BulidValidatorPrefixKey

func BulidValidatorPrefixKey() []byte

func GetDelegationValDelKeyAddress

func GetDelegationValDelKeyAddress(key []byte) (valAddr btypes.Address, deleAddr btypes.Address)

func GetDelegatorEarningStartInfoAddr

func GetDelegatorEarningStartInfoAddr(key []byte) (valAddr, deleAddr btypes.Address)

func GetDelegatorEarningsStartInfoPrefixKey

func GetDelegatorEarningsStartInfoPrefixKey() []byte

func GetDelegatorPeriodIncomeHeightAddr

func GetDelegatorPeriodIncomeHeightAddr(key []byte) (valAddr btypes.Address, deleAddr btypes.Address, height uint64)

func GetDelegatorPeriodIncomePrefixKey

func GetDelegatorPeriodIncomePrefixKey() []byte

func GetUnbondingDelegationHeightAddress

func GetUnbondingDelegationHeightAddress(key []byte) (height uint64, deleAddr btypes.Address)

func GetValidatorByInactiveKey

func GetValidatorByInactiveKey() []byte

func GetValidatorByVotePowerKey

func GetValidatorByVotePowerKey() []byte

func GetValidatorCurrentPeriodSummaryAddr

func GetValidatorCurrentPeriodSummaryAddr(key []byte) btypes.Address

func GetValidatorCurrentPeriodSummaryPrefixKey

func GetValidatorCurrentPeriodSummaryPrefixKey() []byte

func GetValidatorHistoryPeriodSummaryAddrPeriod

func GetValidatorHistoryPeriodSummaryAddrPeriod(key []byte) (valAddr btypes.Address, period uint64)

func GetValidatorHistoryPeriodSummaryPrefixKey

func GetValidatorHistoryPeriodSummaryPrefixKey() []byte

func GetValidatorVoteInfoAddr

func GetValidatorVoteInfoAddr(key []byte) btypes.Address

func GetValidatorVoteInfoInWindowIndexAddr

func GetValidatorVoteInfoInWindowIndexAddr(key []byte) (uint64, btypes.Address)

func GetValidatorVoteInfoInWindowKey

func GetValidatorVoteInfoInWindowKey() []byte

func GetValidatorVoteInfoKey

func GetValidatorVoteInfoKey() []byte

Types

type DelegationInfo

type DelegationInfo struct {
	DelegatorAddr btypes.Address `json:"delegator_addr"`
	ValidatorAddr btypes.Address `json:"validator_addr"`
	Amount        uint64         `json:"delegate_amount"` // 委托数量。TODO 注意溢出处理
	IsCompound    bool           `json:"is_compound"`     // 是否复投
}

func NewDelegationInfo

func NewDelegationInfo(delAddr btypes.Address, valAddr btypes.Address, amount uint64, isCompound bool) DelegationInfo

type DelegatorEarningsStartInfo

type DelegatorEarningsStartInfo struct {
	PreviousPeriod        uint64        `json:"previous_period"`
	BondToken             uint64        `json:"bond_token"`
	CurrentStartingHeight uint64        `json:"earns_starting_height"`
	FirstDelegateHeight   uint64        `json:"first_delegate_height"`
	HistoricalRewardFees  btypes.BigInt `json:"historical_rewards"`
	LastIncomeCalHeight   uint64        `json:"last_income_calHeight"`
	LastIncomeCalFees     btypes.BigInt `json:"last_income_calFees"`
}

DelegatorEarningsStartInfo delegator计算收益信息

type DistributionParams

type DistributionParams struct {
	ProposerRewardRate           qtypes.Fraction `json:"proposer_reward_rate"`
	CommunityRewardRate          qtypes.Fraction `json:"community_reward_rate"`
	ValidatorCommissionRate      qtypes.Fraction `json:"validator_commission_rate"`
	DelegatorsIncomePeriodHeight uint64          `json:"delegator_income_period_height"`
	GasPerUnitCost               uint64          `json:"gas_per_unit_cost"` // how much gas = 1 QOS
}

func DefaultDistributionParams

func DefaultDistributionParams() DistributionParams

type InactiveCode

type InactiveCode int8

type InflationPhrase

type InflationPhrase struct {
	EndTime       time.Time `json:"endtime"`
	TotalAmount   uint64    `json:"total_amount"`
	AppliedAmount uint64    `json:"applied_amount"`
}

type MintParams

type MintParams struct {
	Phrases []InflationPhrase `json:"inflation_phrases"`
}

func DefaultMintParams

func DefaultMintParams() MintParams

func NewMintParams

func NewMintParams(phrases []InflationPhrase) MintParams

type StakeParams

type StakeParams struct {
	MaxValidatorCnt             uint32 `json:"max_validator_cnt"`
	ValidatorVotingStatusLen    uint32 `json:"voting_status_len"`
	ValidatorVotingStatusLeast  uint32 `json:"voting_status_least"`
	ValidatorSurvivalSecs       uint32 `json:"survival_secs"`
	DelegatorUnbondReturnHeight uint32 `json:"unbond_return_height"`
}

func DefaultStakeParams

func DefaultStakeParams() StakeParams

func NewStakeParams

func NewStakeParams(maxValidatorCnt, validatorVotingStatusLen, validatorVotingStatusLeast, validatorSurvivalSecs, delegatorUnbondReturnHeight uint32) StakeParams

type Validator

type Validator struct {
	Name            string         `json:"name"`
	Owner           btypes.Address `json:"owner"`
	ValidatorPubKey crypto.PubKey  `json:"pub_key"`
	BondTokens      uint64         `json:"bond_tokens"` //不能超过int64最大值
	Description     string         `json:"description"`

	Status         int8         `json:"status"`
	InactiveCode   InactiveCode `json:"inactive_code"`
	InactiveTime   time.Time    `json:"inactive_time"`
	InactiveHeight uint64       `json:"inactive_height"`

	MinPeriod  uint64 `json:"min_period"`
	BondHeight uint64 `json:"bond_height"`
}

func (Validator) GetValidatorAddress

func (val Validator) GetValidatorAddress() btypes.Address

func (Validator) IsActive

func (val Validator) IsActive() bool

func (Validator) ToABCIValidator

func (val Validator) ToABCIValidator() (abciVal abci.Validator)

func (Validator) ToABCIValidatorUpdate

func (val Validator) ToABCIValidatorUpdate(isRemoved bool) (abciVal abci.ValidatorUpdate)

type ValidatorCurrentPeriodSummary

type ValidatorCurrentPeriodSummary struct {
	Fees   btypes.BigInt `json:"fees"`
	Period uint64        `json:"period"`
}

ValidatorCurrentPeriodSummary validator当前周期收益信息

type ValidatorVoteInfo

type ValidatorVoteInfo struct {
	StartHeight         uint64 `json:"startHeight"`
	IndexOffset         uint64 `json:"indexOffset"` //统计截止高度=StartHeight+IndexOffset-1
	MissedBlocksCounter uint64 `json:"missedBlocksCounter"`
}

func NewValidatorVoteInfo

func NewValidatorVoteInfo(startHeight, indexOffset, missedBlocksCounter uint64) ValidatorVoteInfo

Jump to

Keyboard shortcuts

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