Documentation ¶
Index ¶
- Constants
- Variables
- type DelegPendingRewards
- type DelegRewardStore
- func (drs *DelegRewardStore) AddRewardsBalance(delegator keys.Address, amount *balance.Amount) error
- func (drs *DelegRewardStore) GetPendingRewards(delegator keys.Address, height, blocks int64) (pdRewards *DelegPendingRewards, err error)
- func (drs *DelegRewardStore) GetRewardsBalance(delegator keys.Address) (amt *balance.Amount, err error)
- func (drs *DelegRewardStore) GetState() *storage.State
- func (drs *DelegRewardStore) GetTotalRewards() (amt *balance.Amount, err error)
- func (drs *DelegRewardStore) IterateActiveRewards(fn func(addr *keys.Address, amt *balance.Amount) bool) bool
- func (drs *DelegRewardStore) IterateAllPD(fn func(height int64, delegator keys.Address, amt *balance.Amount) bool) bool
- func (drs *DelegRewardStore) IteratePD(height int64, fn func(delegator keys.Address, amt *balance.Amount) bool) (stopped bool)
- func (drs *DelegRewardStore) LoadState(state *RewardState) error
- func (drs *DelegRewardStore) MinusRewardsBalance(delegator keys.Address, amount *balance.Amount) error
- func (drs *DelegRewardStore) SaveState() (*RewardState, bool)
- func (drs *DelegRewardStore) SetPendingRewards(delegator keys.Address, amount *balance.Amount, height int64) error
- func (drs *DelegRewardStore) WithState(state *storage.State) *DelegRewardStore
- func (drs *DelegRewardStore) Withdraw(delegator keys.Address, amount *balance.Amount, matureHeight int64) error
- type DelegationPrefixType
- type DelegationRewardCtx
- type DelegationRewardResponse
- type Delegator
- type MasterStore
- type Options
- type PendingDelegator
- type PendingReward
- type PendingRewards
- type Reward
- type RewardState
- type State
- type Store
- func (st *Store) Exists(addr *keys.Address) bool
- func (st *Store) Get(address keys.Address) (coin *balance.Coin, err error)
- func (st *Store) GetPendingAmount(addr keys.Address, height int64) (coin *balance.Coin, err error)
- func (st *Store) GetState() *storage.State
- func (st *Store) IterateActiveAmounts(fn func(addr *keys.Address, coin *balance.Coin) bool) bool
- func (st *Store) IterateAllPendingAmounts(fn func(height int64, addr *keys.Address, coin *balance.Coin) bool) bool
- func (st *Store) IteratePendingAmounts(height int64, fn func(addr *keys.Address, coin *balance.Coin) bool) bool
- func (st *Store) LoadDelegators(state State) error
- func (st *Store) PendingExists(addr keys.Address, height int64) bool
- func (st *Store) Set(address keys.Address, coin *balance.Coin) (err error)
- func (st *Store) SetPendingAmount(addr keys.Address, height int64, coin *balance.Coin) error
- func (st *Store) WithPrefix(prefix DelegationPrefixType) *Store
- func (st *Store) WithState(state *storage.State) *Store
Constants ¶
const ( //MatureType DelegationPrefixType = 0x103 PendingType DelegationPrefixType = 0x102 ActiveType DelegationPrefixType = 0x101 DELEGATION_POOL_KEY = "00000000000000000001" COMMISSION_PERCENTAGE = 25 BLOCK_PROPOSER_COMMISSION = 20 //TODO this is hardcoded for now, will be changed in the future RewardsMaturityTime = 4 )
const ( //MatureKey = "m" PendingKey = "p" ActiveKey = "a" )
Variables ¶
var ( ErrFinalizingDelgRewards = codes.ProtocolError{codes.NetDelgErrFinalizingDelgRewards, "failed to finalize delegation rewards"} ErrAddingWithdrawAmountToBalance = codes.ProtocolError{codes.NetDelgErrAddingWithdrawAmountToBalance, "failed to add withdrawn amount to delegator's balance"} ErrGettingActiveDelgAmount = codes.ProtocolError{codes.NetDelgErrGettingActiveDelgAmount, "failed to get active network delegation amount"} ErrDeductingActiveDelgAmount = codes.ProtocolError{codes.NetDelgErrDeductingActiveDelgAmount, "failed to deduct active network delegation amount"} ErrSettingActiveDelgAmount = codes.ProtocolError{codes.NetDelgErrSettingActiveDelgAmount, "failed to set active network delegation amount"} ErrGettingDelgOption = codes.ProtocolError{codes.NetDelgErrGettingDelgOption, "failed to get network delegation option from governance store"} ErrSettingPendingDelgAmount = codes.ProtocolError{codes.NetDelgErrSettingPendingDelgAmount, "failed to set pending network delegation amount"} ErrGettingPendingDelgAmount = codes.ProtocolError{codes.NetDelgErrGettingPendingDelgAmount, "failed to get pending network delegation amount"} ErrInitiateWithdrawal = codes.ProtocolError{codes.NetDelgErrWithdraw, "failed to initiate rewards withdrawal"} ErrReinvestRewards = codes.ProtocolError{codes.NetDelgErrReinvest, "failed to reinvest rewards"} )
Functions ¶
This section is empty.
Types ¶
type DelegPendingRewards ¶
type DelegPendingRewards struct { Address keys.Address `json:"address"` Rewards []*PendingRewards `json:"rewards"` }
type DelegRewardStore ¶
type DelegRewardStore struct {
// contains filtered or unexported fields
}
func NewDelegRewardStore ¶
func NewDelegRewardStore(prefix string, state *storage.State) *DelegRewardStore
func (*DelegRewardStore) AddRewardsBalance ¶
func (drs *DelegRewardStore) AddRewardsBalance(delegator keys.Address, amount *balance.Amount) error
Add rewards balance
func (*DelegRewardStore) GetPendingRewards ¶
func (drs *DelegRewardStore) GetPendingRewards(delegator keys.Address, height, blocks int64) (pdRewards *DelegPendingRewards, err error)
Get pending withdrawn rewards
func (*DelegRewardStore) GetRewardsBalance ¶
func (drs *DelegRewardStore) GetRewardsBalance(delegator keys.Address) (amt *balance.Amount, err error)
Get rewards balance
func (*DelegRewardStore) GetState ¶
func (drs *DelegRewardStore) GetState() *storage.State
func (*DelegRewardStore) GetTotalRewards ¶
func (drs *DelegRewardStore) GetTotalRewards() (amt *balance.Amount, err error)
Get total rewards
func (*DelegRewardStore) IterateActiveRewards ¶
func (*DelegRewardStore) IterateAllPD ¶
func (*DelegRewardStore) IteratePD ¶
func (drs *DelegRewardStore) IteratePD(height int64, fn func(delegator keys.Address, amt *balance.Amount) bool) (stopped bool)
iterate pending rewards by height
func (*DelegRewardStore) LoadState ¶
func (drs *DelegRewardStore) LoadState(state *RewardState) error
__________________________________ Load Delegation Reward Store -------------------------------------
func (*DelegRewardStore) MinusRewardsBalance ¶
func (drs *DelegRewardStore) MinusRewardsBalance(delegator keys.Address, amount *balance.Amount) error
Deducts an 'amount' of rewards from rewards balance
func (*DelegRewardStore) SaveState ¶
func (drs *DelegRewardStore) SaveState() (*RewardState, bool)
---------------------------------- Save Delegation Reward Store -------------------------------------
func (*DelegRewardStore) SetPendingRewards ¶
func (drs *DelegRewardStore) SetPendingRewards(delegator keys.Address, amount *balance.Amount, height int64) error
Set pending rewards for a certain height
func (*DelegRewardStore) WithState ¶
func (drs *DelegRewardStore) WithState(state *storage.State) *DelegRewardStore
type DelegationPrefixType ¶
type DelegationPrefixType int
func (DelegationPrefixType) GetJSONPrefix ¶
func (prefix DelegationPrefixType) GetJSONPrefix() string
type DelegationRewardCtx ¶
type Delegator ¶
type Delegator struct { Address *keys.Address `json:"address"` Amount *balance.Coin `json:"amount"` }
------------------------ State Types ------------------------------
type MasterStore ¶
type MasterStore struct { Deleg *Store Rewards *DelegRewardStore }
func NewMasterStore ¶
func NewMasterStore(pfxDeleg, pfxRewards string, state *storage.State) *MasterStore
func (*MasterStore) WithState ¶
func (master *MasterStore) WithState(state *storage.State) *MasterStore
type PendingDelegator ¶
type PendingReward ¶
type PendingRewards ¶
type RewardState ¶
type RewardState struct { BalanceList []Reward `json:"balance_list"` MatureList []Reward `json:"mature_list"` PendingList []PendingReward `json:"pending_list"` }
type State ¶
type State struct { ActiveList []Delegator `json:"active_list"` MatureList []Delegator `json:"mature_list"` PendingList []PendingDelegator `json:"pending_list"` }
type Store ¶
func (*Store) GetPendingAmount ¶
check existence of pending amount on specific height
func (*Store) IterateActiveAmounts ¶
func (*Store) IterateAllPendingAmounts ¶
func (st *Store) IterateAllPendingAmounts(fn func(height int64, addr *keys.Address, coin *balance.Coin) bool) bool
iterate all pending amounts
func (*Store) IteratePendingAmounts ¶
func (st *Store) IteratePendingAmounts(height int64, fn func(addr *keys.Address, coin *balance.Coin) bool) bool
iterate addresses for height
func (*Store) LoadDelegators ¶
func (*Store) PendingExists ¶
check existence of pending amount on specific height
func (*Store) SetPendingAmount ¶
Set pending amount with height and address
func (*Store) WithPrefix ¶
func (st *Store) WithPrefix(prefix DelegationPrefixType) *Store