Documentation ¶
Index ¶
- Constants
- func New(database db.Database, back *icstage.Snapshot, reward *icreward.Snapshot, ...) *calculator
- func NewIISS3Reward(ctx Context) (*iiss3Reward, error)
- func NewIISS4Reward(c Context) (*iiss4Reward, error)
- type Context
- type PRep
- func (p *PRep) AccumulatedPower() *big.Int
- func (p *PRep) AccumulatedVoted() *big.Int
- func (p *PRep) ApplyVote(vType VoteType, amount *big.Int, period int, bondRequirement icmodule.Rate)
- func (p *PRep) Bigger(p1 *PRep) bool
- func (p *PRep) CalculateReward(totalPRepReward, totalAccumulatedPower, minBond, minWage *big.Int)
- func (p *PRep) Clone() *PRep
- func (p *PRep) Equal(p1 *PRep) bool
- func (p *PRep) Format(f fmt.State, c rune)
- func (p *PRep) GetReward() *big.Int
- func (p *PRep) GetVotedValue() *big.Int
- func (p *PRep) InitAccumulated(termPeriod int64)
- func (p *PRep) IsElectable() bool
- func (p *PRep) IsRewardable(electedPRepCount int) bool
- func (p *PRep) Owner() module.Address
- func (p *PRep) SetRank(rank int)
- func (p *PRep) SetStatus(status icmodule.EnableStatus)
- func (p *PRep) Status() icmodule.EnableStatus
- func (p *PRep) ToVoted() *icreward.Voted
- func (p *PRep) UpdatePower(bondRequirement icmodule.Rate) *big.Int
- func (p *PRep) VoterReward() *big.Int
- type PRepInfo
- func (p *PRepInfo) Add(target module.Address, status icmodule.EnableStatus, ...) *PRep
- func (p *PRepInfo) ApplyVote(vType VoteType, votes icstage.VoteList, offset int)
- func (p *PRepInfo) CalculateReward(totalReward, totalMinWage, minBond *big.Int) error
- func (p *PRepInfo) ElectedPRepCount() int
- func (p *PRepInfo) GetPRep(key string) *PRep
- func (p *PRepInfo) GetTermPeriod() int64
- func (p *PRepInfo) InitAccumulated()
- func (p *PRepInfo) OffsetLimit() int
- func (p *PRepInfo) PReps() map[string]*PRep
- func (p *PRepInfo) SetStatus(target module.Address, status icmodule.EnableStatus)
- func (p *PRepInfo) Sort()
- func (p *PRepInfo) UpdateTotalAccumulatedPower()
- func (p *PRepInfo) UpdateVoted(writer RewardWriter) error
- type RewardCalculator
- type RewardReader
- type RewardType
- type RewardWriter
- type Stats
- type VoteEvent
- type VoteEvents
- func (v *VoteEvents) AddEvent(vType VoteType, from module.Address, votes icstage.VoteList, offset int)
- func (v *VoteEvents) Events() map[string][]*VoteEvent
- func (v *VoteEvents) Get(from module.Address) []*VoteEvent
- func (v *VoteEvents) IsCalculated(key string) bool
- func (v *VoteEvents) SetCalculated(from module.Address)
- func (v *VoteEvents) UpdateVoting(reader RewardReader, writer RewardWriter) error
- type VoteType
- type Voter
Constants ¶
View Source
const InitBlockHeight = -1
Variables ¶
This section is empty.
Functions ¶
func NewIISS3Reward ¶
func NewIISS4Reward ¶
Types ¶
type PRep ¶
type PRep struct {
// contains filtered or unexported fields
}
func (*PRep) AccumulatedPower ¶
func (*PRep) AccumulatedVoted ¶
func (*PRep) ApplyVote ¶
func (p *PRep) ApplyVote(vType VoteType, amount *big.Int, period int, bondRequirement icmodule.Rate)
ApplyVote applies vote value to PRep. Updates bonded, delegated, power, accumulatedBonded, accumulatedVoted and accumulatedPower
func (*PRep) CalculateReward ¶
func (*PRep) GetVotedValue ¶
func (*PRep) InitAccumulated ¶
func (*PRep) IsElectable ¶
func (*PRep) IsRewardable ¶
func (*PRep) SetStatus ¶
func (p *PRep) SetStatus(status icmodule.EnableStatus)
func (*PRep) Status ¶
func (p *PRep) Status() icmodule.EnableStatus
func (*PRep) VoterReward ¶
type PRepInfo ¶
type PRepInfo struct {
// contains filtered or unexported fields
}
PRepInfo stores information for PRep reward calculation.
func NewPRepInfo ¶
func (*PRepInfo) CalculateReward ¶
CalculateReward calculates commission, wage and voter reward of the PRep.
func (*PRepInfo) ElectedPRepCount ¶
func (*PRepInfo) GetTermPeriod ¶
func (*PRepInfo) InitAccumulated ¶
func (p *PRepInfo) InitAccumulated()
InitAccumulated update accumulated values of elected PReps
func (*PRepInfo) OffsetLimit ¶
func (*PRepInfo) SetStatus ¶
func (p *PRepInfo) SetStatus(target module.Address, status icmodule.EnableStatus)
func (*PRepInfo) UpdateTotalAccumulatedPower ¶
func (p *PRepInfo) UpdateTotalAccumulatedPower()
UpdateTotalAccumulatedPower updates totalAccumulatedPower of PRepInfo with accumulatedPower of elected preps
func (*PRepInfo) UpdateVoted ¶
func (p *PRepInfo) UpdateVoted(writer RewardWriter) error
UpdateVoted writes updated Voted to database
type RewardCalculator ¶
type RewardCalculator interface {
Calculate() error
}
type RewardReader ¶
type RewardReader interface { GetDelegating(addr module.Address) (*icreward.Delegating, error) GetBonding(addr module.Address) (*icreward.Bonding, error) }
RewardReader reads from icreward.Snapshot
type RewardType ¶
type RewardType int
const ( RTBlockProduce RewardType = iota RTPRep RTVoter )
func (RewardType) String ¶
func (r RewardType) String() string
type RewardWriter ¶
type RewardWriter interface { SetVoted(addr module.Address, voted *icreward.Voted) error SetDelegating(addr module.Address, delegating *icreward.Delegating) error SetBonding(addr module.Address, bonding *icreward.Bonding) error }
RewardWriter writes to icreward.State
type Stats ¶
type Stats struct {
// contains filtered or unexported fields
}
func (*Stats) GetCount ¶ added in v1.4.1
func (s *Stats) GetCount(t RewardType) int64
func (*Stats) IncreaseReward ¶
func (s *Stats) IncreaseReward(t RewardType, amount *big.Int)
type VoteEvent ¶
type VoteEvent struct {
// contains filtered or unexported fields
}
func NewVoteEvent ¶
type VoteEvents ¶
type VoteEvents struct {
// contains filtered or unexported fields
}
func NewVoteEvents ¶
func NewVoteEvents() *VoteEvents
func (*VoteEvents) Events ¶
func (v *VoteEvents) Events() map[string][]*VoteEvent
func (*VoteEvents) IsCalculated ¶
func (v *VoteEvents) IsCalculated(key string) bool
func (*VoteEvents) SetCalculated ¶
func (v *VoteEvents) SetCalculated(from module.Address)
func (*VoteEvents) UpdateVoting ¶
func (v *VoteEvents) UpdateVoting(reader RewardReader, writer RewardWriter) error
UpdateVoting writes updated Bonding and Delegating to database
type Voter ¶
type Voter struct {
// contains filtered or unexported fields
}
func (*Voter) ApplyEvent ¶
Click to show internal directories.
Click to hide internal directories.