mapper

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2019 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildDistributionStoreQueryPath

func BuildDistributionStoreQueryPath() []byte

func FeepoolInvariant

func FeepoolInvariant(module string) qtypes.Invariant

func PreDistributionInvariant

func PreDistributionInvariant(module string) qtypes.Invariant

func Query

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

func ValidatorFeePoolInvariant

func ValidatorFeePoolInvariant(module string) qtypes.Invariant

Types

type DelegatorIncomeInfoQueryResult

type DelegatorIncomeInfoQueryResult struct {
	OwnerAddr             btypes.Address `json:"owner_address"`
	ValidatorPubKey       crypto.PubKey  `json:"validator_pub_key"`
	PreviousPeriod        uint64         `json:"previous_validator_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"`
}

type Mapper

type Mapper struct {
	*mapper.BaseMapper
}
Distribution Mapper 收益分配相关Mapper:

keys:

Validator:
 1. 历史计费点汇总收益信息: validatorHistoryPeriodSummaryPrefixKey
 2. 当前计费点收益信息: validatorCurrentPeriodSummaryPrefixKey
Delegator:
 1. Delegator收益计算信息: delegatorEarningsStartInfoPrefixKey
 2. Delegator某高度下是否发放收益信息: delegatorPeriodIncomePrefixKey: 仅在对delegator发放收益时删除

func GetMapper

func GetMapper(ctx context.Context) *Mapper

func NewMapper

func NewMapper() *Mapper

func (*Mapper) AddPreDistributionQOS

func (mapper *Mapper) AddPreDistributionQOS(amount btypes.BigInt)

func (*Mapper) AddToCommunityFeePool

func (mapper *Mapper) AddToCommunityFeePool(fee btypes.BigInt)

func (*Mapper) AddValidatorEcoFeePool

func (mapper *Mapper) AddValidatorEcoFeePool(validatorAddr btypes.Address, proposerReward, commissionReward, preDistributionReward btypes.BigInt)

func (*Mapper) CalculateDelegatorPeriodRewards

func (mapper *Mapper) CalculateDelegatorPeriodRewards(valAddr, deleAddr btypes.Address, endPeriod, blockHeight uint64) (btypes.BigInt, error)

计算delegator在计费点区间的收益

func (*Mapper) CalculateRewardsBetweenPeriod

func (mapper *Mapper) CalculateRewardsBetweenPeriod(valAddr btypes.Address, startPeriod, endPeriod, bondTokens uint64) btypes.BigInt

计算bondTokens在validator的两个计费点区间的收益

func (*Mapper) ClearPreDistributionQOS

func (mapper *Mapper) ClearPreDistributionQOS()

func (*Mapper) ClearValidatorHistoryPeroid

func (mapper *Mapper) ClearValidatorHistoryPeroid(valAddr btypes.Address, minPeroid uint64)

删除validator历史计费点信息,额外保留2个历史数据

func (*Mapper) Copy

func (mapper *Mapper) Copy() mapper.IMapper

func (*Mapper) DelDelegatorEarningStartInfo

func (mapper *Mapper) DelDelegatorEarningStartInfo(valAddr, deleAddr btypes.Address)

func (*Mapper) DeleteDelegatorIncomeInfo

func (mapper *Mapper) DeleteDelegatorIncomeInfo(valAddr, deleAddr btypes.Address)

删除delegator收益计算信息 todo: 某高度下发放收益信息没有删除

func (*Mapper) DeleteDelegatorsEarningStartInfo

func (mapper *Mapper) DeleteDelegatorsEarningStartInfo()

func (*Mapper) DeleteDelegatorsIncomeHeight

func (mapper *Mapper) DeleteDelegatorsIncomeHeight()

func (*Mapper) DeleteValidatorEcoFeePool

func (mapper *Mapper) DeleteValidatorEcoFeePool(validatorAddr btypes.Address)

func (*Mapper) DeleteValidatorPeriodSummaryInfo

func (mapper *Mapper) DeleteValidatorPeriodSummaryInfo(valAddr btypes.Address)

清空validator收益分配相关信息

func (*Mapper) GetCommunityFeePool

func (mapper *Mapper) GetCommunityFeePool() btypes.BigInt

func (*Mapper) GetDelegatorEarningStartInfo

func (mapper *Mapper) GetDelegatorEarningStartInfo(valAddr, deleAddr btypes.Address) (info types.DelegatorEarningsStartInfo, exists bool)

func (*Mapper) GetLastBlockProposer

func (mapper *Mapper) GetLastBlockProposer() btypes.Address

func (*Mapper) GetParams

func (mapper *Mapper) GetParams(ctx context.Context) (p types.Params)

func (*Mapper) GetPreDistributionQOS

func (mapper *Mapper) GetPreDistributionQOS() btypes.BigInt

func (*Mapper) GetValidatorCurrentPeriodSummary

func (mapper *Mapper) GetValidatorCurrentPeriodSummary(valAddr btypes.Address) (vcps types.ValidatorCurrentPeriodSummary, exists bool)

func (*Mapper) GetValidatorEcoFeePool

func (mapper *Mapper) GetValidatorEcoFeePool(validatorAddr btypes.Address) (pool types.ValidatorEcoFeePool)

func (*Mapper) GetValidatorHistoryPeriodSummary

func (mapper *Mapper) GetValidatorHistoryPeriodSummary(valAddr btypes.Address, period uint64) (frac qtypes.Fraction)

func (*Mapper) GetValidatorMinPeriodFromDelegators

func (mapper *Mapper) GetValidatorMinPeriodFromDelegators(valAddr btypes.Address) uint64

func (*Mapper) IncrementValidatorPeriod

func (mapper *Mapper) IncrementValidatorPeriod(validator stake.Validator) uint64

增加validator收益计费点 1. 保存历史计费点收益汇总信息 2. 更新当前计费点收益信息,返回上一计费点数值

func (*Mapper) InitDelegatorIncomeInfo

func (mapper *Mapper) InitDelegatorIncomeInfo(ctx context.Context, valAddr, deleAddr btypes.Address, bondTokens, currHeight uint64)

首次Delegate: 1. first delegate 2. unbond all , then delegate

func (*Mapper) InitValidatorPeriodSummaryInfo

func (mapper *Mapper) InitValidatorPeriodSummaryInfo(valAddr btypes.Address) types.ValidatorCurrentPeriodSummary

初始化validator历史计费点汇总收益,当前计费点收益信息.

func (*Mapper) IteratorDelegatorEarningStartInfo

func (mapper *Mapper) IteratorDelegatorEarningStartInfo(fn func(btypes.Address, btypes.Address, types.DelegatorEarningsStartInfo))

func (*Mapper) IteratorDelegatorsIncomeHeight

func (mapper *Mapper) IteratorDelegatorsIncomeHeight(fn func(btypes.Address, btypes.Address, uint64))

func (*Mapper) IteratorValidatorEcoFeePools

func (mapper *Mapper) IteratorValidatorEcoFeePools(fn func(validatorAddr btypes.Address, pool types.ValidatorEcoFeePool))

func (*Mapper) IteratorValidatorsCurrentPeriod

func (mapper *Mapper) IteratorValidatorsCurrentPeriod(fn func(btypes.Address, types.ValidatorCurrentPeriodSummary))

func (*Mapper) IteratorValidatorsHistoryPeriod

func (mapper *Mapper) IteratorValidatorsHistoryPeriod(fn func(valAddr btypes.Address, period uint64, frac qtypes.Fraction))

func (*Mapper) MinusValidatorEcoFeePool

func (mapper *Mapper) MinusValidatorEcoFeePool(validatorAddr btypes.Address, bonusReward btypes.BigInt)

func (*Mapper) ModifyDelegatorTokens

func (mapper *Mapper) ModifyDelegatorTokens(validator stake.Validator, deleAddr btypes.Address, updatedToken, blockHeight uint64) error

修改delegator绑定的token: 1. 增加validator的计费点 2. 计算delegator在两次计费点间的收益 3. 追加该收益到delegator 收益计算信息中

func (*Mapper) SaveValidatorEcoFeePool

func (mapper *Mapper) SaveValidatorEcoFeePool(validatorAddr btypes.Address, pool types.ValidatorEcoFeePool)

func (*Mapper) SetCommunityFeePool

func (mapper *Mapper) SetCommunityFeePool(communityFee btypes.BigInt)

func (*Mapper) SetLastBlockProposer

func (mapper *Mapper) SetLastBlockProposer(proposer btypes.Address)

func (*Mapper) SetParams

func (mapper *Mapper) SetParams(ctx context.Context, p types.Params)

func (*Mapper) SetPreDistributionQOS

func (mapper *Mapper) SetPreDistributionQOS(amount btypes.BigInt)

type StakingHooks

type StakingHooks struct{}

func NewStakingHooks

func NewStakingHooks() *StakingHooks

func (*StakingHooks) AfterDelegationCreated

func (hooks *StakingHooks) AfterDelegationCreated(ctx context.Context, val btypes.Address, del btypes.Address)

创建delegation时初始化分配信息

func (*StakingHooks) AfterValidatorCreated

func (hooks *StakingHooks) AfterValidatorCreated(ctx context.Context, val btypes.Address)

创建validator时初始化分配信息

func (*StakingHooks) AfterValidatorSlashed

func (hooks *StakingHooks) AfterValidatorSlashed(ctx context.Context, slashedTokens uint64)

validator惩罚后操作

func (*StakingHooks) BeforeDelegationModified

func (hooks *StakingHooks) BeforeDelegationModified(ctx context.Context, val btypes.Address, del btypes.Address, updateAmount uint64)

更新绑定tokens时分配处理逻辑

func (*StakingHooks) BeforeValidatorRemoved

func (hooks *StakingHooks) BeforeValidatorRemoved(ctx context.Context, val btypes.Address)

删除validator时分配处理逻辑

func (*StakingHooks) HookMapper

func (hooks *StakingHooks) HookMapper() string

type ValidatorPeriodInfoQueryResult

type ValidatorPeriodInfoQueryResult struct {
	OwnerAddr          btypes.Address  `json:"owner_address"`
	ValidatorPubKey    crypto.PubKey   `json:"validator_pub_key"`
	Fees               btypes.BigInt   `json:"fees"`
	CurrentTokens      uint64          `json:"current_tokens"`
	CurrentPeriod      uint64          `json:"current_period"`
	LastPeriod         uint64          `json:"last_period"`
	LastPeriodFraction qtypes.Fraction `json:"last_period_fraction"`
}

Jump to

Keyboard shortcuts

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