mapper

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2019 License: Apache-2.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DelegationInvariant

func DelegationInvariant(module string) qtypes.Invariant

委托数据检查

func Query

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

func RedelegationInvariant

func RedelegationInvariant(module string) qtypes.Invariant

转委托数据检查

func UnbondingInvariant

func UnbondingInvariant(module string) qtypes.Invariant

解除委托数据检查

Types

type DelegationQueryResult

type DelegationQueryResult struct {
	DelegatorAddr            btypes.AccAddress `json:"delegator_address"`
	ValidatorAddr            btypes.ValAddress `json:"validator_address"`
	ValidatorConsensusPubKey string            `json:"validator_cons_pub_key"`
	Amount                   btypes.BigInt     `json:"delegate_amount"`
	IsCompound               bool              `json:"is_compound"`
}

func NewDelegationQueryResult

func NewDelegationQueryResult(deleAddr btypes.AccAddress, ownerAddr btypes.ValAddress, bench32ConPubKey string, amount btypes.BigInt, compound bool) DelegationQueryResult

type Mapper

type Mapper struct {
	*mapper.BaseMapper
	// contains filtered or unexported fields
}

func GetMapper

func GetMapper(ctx context.Context) *Mapper

func NewMapper

func NewMapper() *Mapper

func (*Mapper) AddRedelegation

func (mapper *Mapper) AddRedelegation(redelegation types.RedelegationInfo)

新增转委托,若存在则累加tokens数量

func (*Mapper) AddRedelegations

func (mapper *Mapper) AddRedelegations(reDelegations []types.RedelegationInfo)

添加转委托信息

func (*Mapper) AddUnbondingDelegation

func (mapper *Mapper) AddUnbondingDelegation(unbonding types.UnbondingDelegationInfo)

新增解除委托信息,若存在累加tokens数量

func (*Mapper) AddUnbondingDelegations

func (mapper *Mapper) AddUnbondingDelegations(unbondingsAdd []types.UnbondingDelegationInfo)

添加解除委托信息

func (*Mapper) AfterDelegationCreated

func (mapper *Mapper) AfterDelegationCreated(ctx context.Context, val btypes.ValAddress, del btypes.AccAddress)

func (*Mapper) AfterValidatorCreated

func (mapper *Mapper) AfterValidatorCreated(ctx context.Context, val btypes.ValAddress)

func (*Mapper) AfterValidatorSlashed

func (mapper *Mapper) AfterValidatorSlashed(ctx context.Context, slashedTokes btypes.BigInt)

func (*Mapper) BeforeDelegationModified

func (mapper *Mapper) BeforeDelegationModified(ctx context.Context, val btypes.ValAddress, del btypes.AccAddress, updateTokes btypes.BigInt)

func (*Mapper) BeforeValidatorRemoved

func (mapper *Mapper) BeforeValidatorRemoved(ctx context.Context, val btypes.ValAddress)

func (*Mapper) ChangeValidatorBondTokens

func (mapper *Mapper) ChangeValidatorBondTokens(validator types.Validator, updatedTokens btypes.BigInt)

更新验证节点绑定tokens,按原tokens从按voting power排序的队列中删除,保存最新验证节点信息

func (*Mapper) ClearValidatorVoteInfoInWindow

func (mapper *Mapper) ClearValidatorVoteInfoInWindow(valAddr btypes.ValAddress)

删除验证节点所有窗口高度投票数据

func (*Mapper) Copy

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

func (*Mapper) CreateValidator

func (mapper *Mapper) CreateValidator(validator types.Validator)

保存验证节点最新信息

func (*Mapper) DelDelegationInfo

func (mapper *Mapper) DelDelegationInfo(delAddr btypes.AccAddress, valAddr btypes.ValAddress)

删除委托信息

func (*Mapper) DelValidatorVoteInfo

func (mapper *Mapper) DelValidatorVoteInfo(valAddr btypes.ValAddress)

删除验证节点投票信息

func (*Mapper) Delegate

func (mapper *Mapper) Delegate(ctx context.Context, info types.DelegationInfo, reDelegate bool)

委托

func (*Mapper) Exists

func (mapper *Mapper) Exists(valAddress btypes.ValAddress) bool

验证节点是否存在,根据验证节点地址查询

func (*Mapper) ExistsWithConsensusAddr added in v0.0.8

func (mapper *Mapper) ExistsWithConsensusAddr(consensusAddr btypes.ConsAddress) bool

验证节点是否存在,根据共识地址查询

func (*Mapper) GetActiveValidatorSet

func (mapper *Mapper) GetActiveValidatorSet(ascending bool) (validators []btypes.ValAddress)

获取当前验证节点列表

func (*Mapper) GetDelegationInfo

func (mapper *Mapper) GetDelegationInfo(delAddr btypes.AccAddress, valAddr btypes.ValAddress) (info types.DelegationInfo, exist bool)

获取委托信息

func (*Mapper) GetDelegationsByValidator

func (mapper *Mapper) GetDelegationsByValidator(valAddr btypes.ValAddress) (infos []types.DelegationInfo)

根据验证节点地址获取委托列表

func (*Mapper) GetParams

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

获取参数

func (*Mapper) GetRedelegation

func (mapper *Mapper) GetRedelegation(height int64, delAdd btypes.AccAddress, valAddr btypes.ValAddress) (reDelegation types.RedelegationInfo, exist bool)

获取转委托信息,完成时间+委托地址+验证节点地址

func (*Mapper) GetRedelegationsByDelegator

func (mapper *Mapper) GetRedelegationsByDelegator(delegator btypes.AccAddress) (redelegations []types.RedelegationInfo)

根据委托地址获取转委托信息

func (*Mapper) GetRedelegationsByFromValidator

func (mapper *Mapper) GetRedelegationsByFromValidator(validator btypes.ValAddress) (redelegations []types.RedelegationInfo)

根据验证节点地址遍历转委托信息

func (*Mapper) GetUnbondingDelegation

func (mapper *Mapper) GetUnbondingDelegation(height int64, delAddr btypes.AccAddress, valAddr btypes.ValAddress) (unbonding types.UnbondingDelegationInfo, exist bool)

获取解除委托信息,完成时间+委托地址+验证节点地址

func (*Mapper) GetUnbondingDelegationsByDelegator

func (mapper *Mapper) GetUnbondingDelegationsByDelegator(delegator btypes.AccAddress) (unbondings []types.UnbondingDelegationInfo)

根据委托账户获取解除委托信息列表

func (*Mapper) GetUnbondingDelegationsByValidator

func (mapper *Mapper) GetUnbondingDelegationsByValidator(validator btypes.ValAddress) (unbondings []types.UnbondingDelegationInfo)

根据验证节点地址获取解除委托信息

func (*Mapper) GetValidator

func (mapper *Mapper) GetValidator(valAddress btypes.ValAddress) (validator types.Validator, exists bool)

根据验证节点地址获取验证节点

func (*Mapper) GetValidatorByConsensusAddr added in v0.0.8

func (mapper *Mapper) GetValidatorByConsensusAddr(consensusAddr btypes.ConsAddress) (validator types.Validator, exists bool)

根据共识地址获取验证节点信息

func (*Mapper) GetValidatorVoteInfo

func (mapper *Mapper) GetValidatorVoteInfo(valAddr btypes.ValAddress) (info types.ValidatorVoteInfo, exists bool)

获取验证节点投票信息

func (*Mapper) GetVoteInfoInWindow

func (mapper *Mapper) GetVoteInfoInWindow(valAddr btypes.ValAddress, index int64) (vote bool)

某一窗口高度是否投过票

func (*Mapper) IterateDelegationsInfo

func (mapper *Mapper) IterateDelegationsInfo(deleAddr btypes.AccAddress, fn func(types.DelegationInfo))

遍历委托,当deleAddr为空时,遍历所有委托,否则遍历此deleAddr的所有委托

func (*Mapper) IterateDelegationsValDeleAddr

func (mapper *Mapper) IterateDelegationsValDeleAddr(valAddr btypes.ValAddress, fn func(btypes.ValAddress, btypes.AccAddress))

遍历委托,当valAddr为空时,遍历所有委托,否则遍历此valAddr下委托

func (*Mapper) IterateRedelegationsInfo

func (mapper *Mapper) IterateRedelegationsInfo(fn func([]types.RedelegationInfo))

遍历转委托信息

func (*Mapper) IterateUnbondingDelegations

func (mapper *Mapper) IterateUnbondingDelegations(fn func([]types.UnbondingDelegationInfo))

遍历解除委托

func (*Mapper) IterateValidators

func (mapper *Mapper) IterateValidators(fn func(types.Validator))

遍历验证节点

func (*Mapper) IterateVoteInWindowsInfos

func (mapper *Mapper) IterateVoteInWindowsInfos(fn func(int64, btypes.ValAddress, bool))

遍历验证节点投票窗口期内投票数据

func (*Mapper) IterateVoteInfos

func (mapper *Mapper) IterateVoteInfos(fn func(btypes.ValAddress, types.ValidatorVoteInfo))

遍历验证节点投票信息

func (*Mapper) IteratorInactiveValidator

func (mapper *Mapper) IteratorInactiveValidator(fromSecond, endSecond int64) store.Iterator

遍历inactive状态验证节点

func (*Mapper) IteratorInactiveValidatorByTime

func (mapper *Mapper) IteratorInactiveValidatorByTime(fromTime, endTime time.Time) store.Iterator

遍历inactive状态验证节点

func (*Mapper) IteratorValidatorByVoterPower

func (mapper *Mapper) IteratorValidatorByVoterPower(ascending bool) store.Iterator

遍历active状态验证节点, 按voting power排序

func (*Mapper) KickValidator

func (mapper *Mapper) KickValidator(valAddress btypes.ValAddress) (validator types.Validator, ok bool)

删除验证节点信息

func (*Mapper) MakeValidatorActive

func (mapper *Mapper) MakeValidatorActive(valAddress btypes.ValAddress, addTokens btypes.BigInt)

更新验证节点状态, inactive -> active

func (*Mapper) MakeValidatorInactive

func (mapper *Mapper) MakeValidatorInactive(valAddress btypes.ValAddress, inactiveHeight int64, inactiveTime time.Time, code types.InactiveCode)

更新验证节点状态, active -> inactive

func (*Mapper) ReDelegate

func (mapper *Mapper) ReDelegate(ctx context.Context, delegation types.DelegationInfo, info types.RedelegationInfo)

转委托,执行BeforeDelegationModified hooks方法,保存转委托信息

func (*Mapper) RemoveRedelegation

func (mapper *Mapper) RemoveRedelegation(height int64, delAddr btypes.AccAddress, valAddr btypes.ValAddress)

删除转委托信息

func (*Mapper) RemoveUnbondingDelegation

func (mapper *Mapper) RemoveUnbondingDelegation(height int64, delAddr btypes.AccAddress, valAddr btypes.ValAddress)

删除解除委托信息

func (*Mapper) ResetValidatorVoteInfo

func (mapper *Mapper) ResetValidatorVoteInfo(valAddr btypes.ValAddress, info types.ValidatorVoteInfo)

重置验证节点投票信息

func (*Mapper) SetDelegationInfo

func (mapper *Mapper) SetDelegationInfo(info types.DelegationInfo)

保存委托信息

func (*Mapper) SetHooks

func (mapper *Mapper) SetHooks(sh qtypes.Hooks)

func (*Mapper) SetParams

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

设置参数

func (*Mapper) SetRedelegation

func (mapper *Mapper) SetRedelegation(redelegation types.RedelegationInfo)

保存转委托信息

func (*Mapper) SetUnbondingDelegation

func (mapper *Mapper) SetUnbondingDelegation(unbonding types.UnbondingDelegationInfo)

保存解除委托信息

func (*Mapper) SetValidatorVoteInfo

func (mapper *Mapper) SetValidatorVoteInfo(valAddr btypes.ValAddress, info types.ValidatorVoteInfo)

保存验证节点投票信息

func (*Mapper) SetVoteInfoInWindow

func (mapper *Mapper) SetVoteInfoInWindow(valAddr btypes.ValAddress, index int64, vote bool)

设置某窗口高度投票信息

func (*Mapper) SlashRedelegations

func (mapper *Mapper) SlashRedelegations(valAddr btypes.ValAddress, infractionHeight int64, fraction qtypes.Dec, maxSlash btypes.BigInt) btypes.BigInt

从转委托中扣除惩罚

func (*Mapper) SlashUnbondings

func (mapper *Mapper) SlashUnbondings(valAddr btypes.ValAddress, infractionHeight int64, fraction qtypes.Dec, maxSlash btypes.BigInt) btypes.BigInt

从解除委托信息中扣除惩罚

func (*Mapper) UnbondTokens

func (mapper *Mapper) UnbondTokens(ctx context.Context, info types.DelegationInfo, tokens btypes.BigInt)

解除委托, 执行BeforeDelegationModified hooks方法,保存最新delegation

Jump to

Keyboard shortcuts

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