rewards

package
v0.14.3 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	UnableToGetMaturedAmount = codes.ProtocolError{codes.RewardsUnableToGetMaturedAmount, "failed to get matured balance"}
	UnableToWithdraw         = codes.ProtocolError{codes.RewardsUnableToWithdraw, "Unable to withdraw"}
)

Functions

This section is empty.

Types

type Interval

type Interval struct {
	LastIndex  int64 `json:"lastIndex"`
	LastHeight int64 `json:"lastHeight"`
}

type Options

type Options struct {
	RewardInterval    int64          `json:"rewardInterval"`
	RewardPoolAddress string         `json:"rewardPoolAddress"`
	RewardCurrency    string         `json:"rewardCurrency"`
	CalculateInterval int64          `json:"calculateInterval"`
	AnnualSupply      balance.Amount `json:"annualSupply"`
	YearsOfSupply     int64          `json:"yearsOfSupply"`
}

type RewardCumulativeStore

type RewardCumulativeStore struct {
	// contains filtered or unexported fields
}

func NewRewardCumulativeStore

func NewRewardCumulativeStore(prefix string, state *storage.State) *RewardCumulativeStore

func (*RewardCumulativeStore) AddMaturedBalance

func (rws *RewardCumulativeStore) AddMaturedBalance(validator keys.Address, amount *balance.Amount) error

Add an 'amount' of matured rewards to rewards balance

func (*RewardCumulativeStore) CalcBlockRewards

func (rws *RewardCumulativeStore) CalcBlockRewards(blockHeight int64, bftTime time.Time)

Calculate combined rewards for all voting validators for given block

func (*RewardCumulativeStore) GetMaturedBalance

func (rws *RewardCumulativeStore) GetMaturedBalance(validator keys.Address) (amt *balance.Amount, err error)

Get matured rewards balance, the widrawable rewards, till now.

func (*RewardCumulativeStore) GetMaturedRewards

func (rws *RewardCumulativeStore) GetMaturedRewards(validator keys.Address) (amt *balance.Amount, err error)

Get total matured rewards till now, including withdrawn amount. This number is calculated on the fly

func (*RewardCumulativeStore) GetOptions

func (rws *RewardCumulativeStore) GetOptions() *Options

func (*RewardCumulativeStore) GetWithdrawnRewards

func (rws *RewardCumulativeStore) GetWithdrawnRewards(validator keys.Address) (amt *balance.Amount, err error)

Get total rewards withdrawn till now

func (*RewardCumulativeStore) SetOptions

func (rws *RewardCumulativeStore) SetOptions(options *Options)

func (*RewardCumulativeStore) WithState

func (rws *RewardCumulativeStore) WithState(state *storage.State) *RewardCumulativeStore

func (*RewardCumulativeStore) WithdrawRewards

func (rws *RewardCumulativeStore) WithdrawRewards(validator keys.Address, amount *balance.Amount) error

Withdraw an 'amount' of rewards from rewards balance

type RewardMasterStore

type RewardMasterStore struct {
	Reward   *RewardStore
	RewardCm *RewardCumulativeStore
}

func NewRewardMasterStore

func NewRewardMasterStore(rwz *RewardStore, rwzc *RewardCumulativeStore) *RewardMasterStore

func (*RewardMasterStore) GetOptions

func (rwz *RewardMasterStore) GetOptions() *Options

func (*RewardMasterStore) SetOptions

func (rwz *RewardMasterStore) SetOptions(options *Options)

func (*RewardMasterStore) WithState

func (rwz *RewardMasterStore) WithState(state *storage.State) *RewardMasterStore

type RewardStore

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

func NewRewardStore

func NewRewardStore(prefix string, intervalPrefix string, addrListPrefix string, state *storage.State) *RewardStore

func (*RewardStore) AddAddressToList

func (rs *RewardStore) AddAddressToList(address keys.Address)

func (*RewardStore) AddToAddress

func (rs *RewardStore) AddToAddress(address keys.Address, height int64, amount *balance.Amount) error

func (*RewardStore) Get

func (rs *RewardStore) Get(key storage.StoreKey) (amount *balance.Amount, err error)

func (*RewardStore) GetInterval

func (rs *RewardStore) GetInterval(height int64) *Interval

func (*RewardStore) GetLastTwoChunks

func (rs *RewardStore) GetLastTwoChunks(address keys.Address) (*balance.Amount, error)

func (*RewardStore) GetMaturedAmount

func (rs *RewardStore) GetMaturedAmount(address keys.Address, height int64) (*balance.Amount, error)

func (*RewardStore) GetOptions

func (rs *RewardStore) GetOptions() *Options

func (*RewardStore) GetWithHeight

func (rs *RewardStore) GetWithHeight(address keys.Address, height int64) (amount *balance.Amount, err error)

func (*RewardStore) Iterate

func (rs *RewardStore) Iterate(addr keys.Address, fn func(c string, amt balance.Amount) bool) bool

Iterate through all reward records for a given Address

func (*RewardStore) IterateAddrList

func (rs *RewardStore) IterateAddrList(fn func(key keys.Address) bool) bool

func (*RewardStore) SetInterval

func (rs *RewardStore) SetInterval(height int64) error

func (*RewardStore) SetOptions

func (rs *RewardStore) SetOptions(options *Options)

func (*RewardStore) SetWithHeight

func (rs *RewardStore) SetWithHeight(address keys.Address, height int64, amount *balance.Amount) error

func (*RewardStore) UpdateOptions

func (rs *RewardStore) UpdateOptions(height int64, options *Options) error

func (*RewardStore) WithState

func (rs *RewardStore) WithState(state *storage.State) *RewardStore

Jump to

Keyboard shortcuts

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