Documentation ¶
Index ¶
- Constants
- Variables
- func BuildAccountLockGoverningTx(chainTag byte, bestNum uint32, curEpoch uint32) *tx.Transaction
- func BuildAuctionControlTx(height, epoch uint64, chainTag byte, bestNum uint32, s *state.State, ...) *tx.Transaction
- func BuildAutobidData(autobid *meter.RewardInfo) (ret []byte)
- func BuildAutobidTx(autobidList []*meter.RewardInfo, chainTag byte, bestNum uint32) *tx.Transaction
- func BuildAutobidTxs(autobidList []*meter.RewardInfo, chainTag byte, bestNum uint32) tx.Transactions
- func BuildMinerRewardTxs(rewards []powpool.PowReward, chainTag byte, bestNum uint32) tx.Transactions
- func BuildStakingGoverningTx(distList []*meter.RewardInfo, curEpoch uint32, chainTag byte, bestNum uint32) *tx.Transaction
- func BuildStakingGoverningV2Tx(rewardInfoV2s []*meter.RewardInfoV2, curEpoch uint32, chainTag byte, ...) *tx.Transaction
- func BuildStatisticsTx(entries []*StatEntry, chainTag byte, bestNum uint32, curEpoch uint32) *tx.Transaction
- func ComputeDoubleSigner(common *types.ConsensusCommon, blocks []*block.Block, curEpoch uint32) ([]*doubleSignerInfo, error)
- func ComputeEpochBaseReward(validatorBaseReward *big.Int) *big.Int
- func ComputeEpochReleaseWithInflation(sequence uint64, lastAuction *meter.AuctionCB) (*big.Int, error)
- func ComputeEpochTotalReward(benefitRatio *big.Int, nDays int, nAuctionPerDay int, ...) (*big.Int, error)
- func ComputeMissingLeader(validators []*types.Validator, actualMembers []types.CommitteeMember, ...) ([]*missingLeaderInfo, error)
- func ComputeMissingProposer(validators []*types.Validator, actualMembers []types.CommitteeMember, ...) ([]*missingProposerInfo, error)
- func ComputeMissingVoter(validators []*types.Validator, actualMembers []types.CommitteeMember, ...) ([]*missingVoterInfo, error)
- func FloatToBigInt(val float64) *big.Int
- func GetValidatorBaseRewards(state *state.State) *big.Int
- func GetValidatorBenefitRatio(state *state.State) *big.Int
- type RewardMap
- func ComputeRewardMap(baseReward, totalRewards *big.Int, delegates []*types.Delegate, v3 bool) (RewardMap, error)
- func ComputeRewardMapV2(baseReward, totalRewards *big.Int, delegates []*types.Delegate, ...) (RewardMap, error)
- func ComputeRewardMapV3(baseReward, totalRewards *big.Int, delegates []*types.Delegate, ...) (RewardMap, error)
- type StatEntry
Constants ¶
const ( // protect kblock size MaxNAutobidTx = meter.MaxNClausePerAutobidTx * 10 )
const (
N = 24 // history buffer size
)
Variables ¶
Functions ¶
func BuildAccountLockGoverningTx ¶
func BuildAccountLockGoverningTx(chainTag byte, bestNum uint32, curEpoch uint32) *tx.Transaction
func BuildAuctionControlTx ¶
func BuildAutobidData ¶
func BuildAutobidData(autobid *meter.RewardInfo) (ret []byte)
func BuildAutobidTx ¶
func BuildAutobidTx(autobidList []*meter.RewardInfo, chainTag byte, bestNum uint32) *tx.Transaction
func BuildAutobidTxs ¶
func BuildAutobidTxs(autobidList []*meter.RewardInfo, chainTag byte, bestNum uint32) tx.Transactions
func BuildMinerRewardTxs ¶
func BuildStakingGoverningTx ¶
func BuildStakingGoverningTx(distList []*meter.RewardInfo, curEpoch uint32, chainTag byte, bestNum uint32) *tx.Transaction
for distribute validator rewards, recalc the delegates list ...
func BuildStakingGoverningV2Tx ¶
func BuildStakingGoverningV2Tx(rewardInfoV2s []*meter.RewardInfoV2, curEpoch uint32, chainTag byte, bestNum uint32) *tx.Transaction
for distribute validator rewards, recalc the delegates list ...
func BuildStatisticsTx ¶
func BuildStatisticsTx(entries []*StatEntry, chainTag byte, bestNum uint32, curEpoch uint32) *tx.Transaction
create statistics transaction
func ComputeDoubleSigner ¶
func ComputeEpochReleaseWithInflation ¶
func ComputeEpochReleaseWithInflation(sequence uint64, lastAuction *meter.AuctionCB) (*big.Int, error)
calEpochReleaseWithInflation returns the release of MTRG for current epoch, it returns a 0 if curEpoch is less than startEpoch epochRelease = lastEpochRelease + lastEpochRelease * deltaRate whereas, deltaRate = inflationRate / 365 / nAuctionPerDay
func ComputeEpochTotalReward ¶
func ComputeMissingLeader ¶
func ComputeMissingProposer ¶
func ComputeMissingVoter ¶
func FloatToBigInt ¶
Types ¶
type RewardMap ¶
type RewardMap map[meter.Address]*meter.RewardInfoV2
func ComputeRewardMap ¶
func ComputeRewardMap(baseReward, totalRewards *big.Int, delegates []*types.Delegate, v3 bool) (RewardMap, error)
Epoch Reward includes these parts:
|------ extra_reward -----| |------| |------------| |---------------| | base | + | commission | + | actual_reward | = each_reward |------| |------------| |---------------|
such that: sum(extra_reward) = total_rewards - base * delegate_size commission = sum(extra_reward) * voting_power_ratio * commission_rate actual_reward = sum(extra_reward) * voting_power_ratio - commission delgate_reward = base + commission + actual_reward * delgate_share_ratio voter_reward = actual_reward * voter_share_ratio
Steps: 1. distributes the base reward (meter.ValidatorBaseReward) for each validator. If there is remainning 2. get the propotion reward for each validator based on the votingpower 3. each validator takes commission first 4. finally, distributor takes their propotions of rest
func ComputeRewardMapV2 ¶
func ComputeRewardMapV3 ¶
func (RewardMap) GetAutobidList ¶
func (rmap RewardMap) GetAutobidList() []*meter.RewardInfo
func (RewardMap) GetDistList ¶
func (rmap RewardMap) GetDistList() []*meter.RewardInfo
type StatEntry ¶
type StatEntry struct { Address meter.Address Name string PubKey string Infraction meter.Infraction }
func ComputeStatistics ¶
func ComputeStatistics(lastKBlockHeight, height uint32, chain *chain.Chain, curCommittee *types.ValidatorSet, curActualCommittee []types.CommitteeMember, csCommon *types.ConsensusCommon, calcStatsTx bool, curEpoch uint32) ([]*StatEntry, error)