network_delegation

package
v0.16.1 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2020 License: Apache-2.0 Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
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
)
View Source
const (
	//MatureKey  = "m"
	PendingKey = "p"
	ActiveKey  = "a"
)

Variables

View Source
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 (drs *DelegRewardStore) IterateActiveRewards(fn func(addr *keys.Address, amt *balance.Amount) bool) bool

func (*DelegRewardStore) IterateAllPD

func (drs *DelegRewardStore) IterateAllPD(fn func(height int64, delegator keys.Address, amt *balance.Amount) bool) bool

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

func (*DelegRewardStore) Withdraw

func (drs *DelegRewardStore) Withdraw(delegator keys.Address, amount *balance.Amount, matureHeight int64) error

Initiate a withdrawal of an 'amount' of rewards

type DelegationPrefixType

type DelegationPrefixType int

func (DelegationPrefixType) GetJSONPrefix

func (prefix DelegationPrefixType) GetJSONPrefix() string

type DelegationRewardCtx

type DelegationRewardCtx struct {
	TotalRewards    *balance.Amount
	DelegationPower *big.Int
	TotalPower      *big.Int
	Height          int64
	ProposerAddress keys.Address
}

type DelegationRewardResponse

type DelegationRewardResponse struct {
	DelegationRewards *balance.Amount
	ProposerReward    *balance.Amount
	Commission        *balance.Amount
}

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 Options

type Options struct {
	RewardsMaturityTime int64 `json:"rewardsMaturityTime"`
}

type PendingDelegator

type PendingDelegator struct {
	Address *keys.Address `json:"address"`
	Amount  *balance.Coin `json:"amount"`
	Height  int64         `json:"height"`
}

type PendingReward

type PendingReward struct {
	Amount  *balance.Amount
	Address keys.Address
	Height  int64
}

type PendingRewards

type PendingRewards struct {
	Height int64          `json:"height"`
	Amount balance.Amount `json:"amount"`
}

type Reward

type Reward struct {
	Amount  *balance.Amount
	Address keys.Address
}

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

type Store struct {
	State *storage.State
	// contains filtered or unexported fields
}

func NewStore

func NewStore(prefix string, state *storage.State) *Store

func (*Store) Exists

func (st *Store) Exists(addr *keys.Address) bool

func (*Store) Get

func (st *Store) Get(address keys.Address) (coin *balance.Coin, err error)

Get coin from address

func (*Store) GetPendingAmount

func (st *Store) GetPendingAmount(addr keys.Address, height int64) (coin *balance.Coin, err error)

check existence of pending amount on specific height

func (*Store) GetState

func (st *Store) GetState() *storage.State

func (*Store) IterateActiveAmounts

func (st *Store) IterateActiveAmounts(fn func(addr *keys.Address, coin *balance.Coin) bool) bool

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 (st *Store) LoadDelegators(state State) error

func (*Store) PendingExists

func (st *Store) PendingExists(addr keys.Address, height int64) bool

check existence of pending amount on specific height

func (*Store) Set

func (st *Store) Set(address keys.Address, coin *balance.Coin) (err error)

Set coin to specific address

func (*Store) SetPendingAmount

func (st *Store) SetPendingAmount(addr keys.Address, height int64, coin *balance.Coin) error

Set pending amount with height and address

func (*Store) WithPrefix

func (st *Store) WithPrefix(prefix DelegationPrefixType) *Store

func (*Store) WithState

func (st *Store) WithState(state *storage.State) *Store

Jump to

Keyboard shortcuts

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