- Invariant
- does not modify any on-disk state.
Definition at line 20 of file default_poprewards_calculator.hpp.
#include <default_poprewards_calculator.hpp>
|
| | DefaultPopRewardsCalculator (AltBlockTree &tree) |
| |
| bool | getPopPayout (const AltBlockTree::hash_t &tip, PopPayouts &rewards, ValidationState &state) override |
| | Calculate POP rewards for miners. More...
|
| |
| bool | calculatePayouts (const BlockIndex< AltBlock > &endorsedBlock, PopPayouts &rewards, ValidationState &state) |
| | Calculate POP rewards for miners. More...
|
| |
| PopRewardsBigDecimal | scoreFromEndorsements (const BlockIndex< AltBlock > &endorsedBlock) |
| | Collect all endorsements for the endorsed block and calculate POP score. More...
|
| |
| uint32_t | getRoundForBlockNumber (uint32_t height) const |
| | Calculate payout round from the given block height. More...
|
| |
| PopRewardsBigDecimal | calculateBlockReward (uint32_t height, PopRewardsBigDecimal scoreForThisBlock, PopRewardsBigDecimal difficulty) const |
| | Calculate reward for the entire block from the block score, height of the VBK endorsement and current POP difficulty. More...
|
| |
| PopRewardsBigDecimal | calculateMinerReward (uint32_t vbkRelativeHeight, const PopRewardsBigDecimal &scoreForThisBlock, const PopRewardsBigDecimal &blockReward) const |
| | Calculate reward for the miner from the block score, height of the VBK endorsement and total block reward. More...
|
| |
| virtual bool | getPopPayout (const AltBlockTree::hash_t &tip, PopPayouts &rewards, ValidationState &state)=0 |
| | Calculate POP rewards for miners. More...
|
| |
◆ index_t
◆ DefaultPopRewardsCalculator()
| altintegration::DefaultPopRewardsCalculator::DefaultPopRewardsCalculator |
( |
AltBlockTree & |
tree | ) |
|
|
inline |
◆ calculateBlockReward()
| PopRewardsBigDecimal altintegration::DefaultPopRewardsCalculator::calculateBlockReward |
( |
uint32_t |
height, |
|
|
PopRewardsBigDecimal |
scoreForThisBlock, |
|
|
PopRewardsBigDecimal |
difficulty |
|
) |
| const |
- Parameters
-
| height | reward is calculated for the block at this height. |
| scoreForThisBlock | block score |
| difficulty | current POP difficulty |
- Returns
- PopRewardsBigDecimal resulting reward for the block
◆ calculateDifficulty()
| PopRewardsBigDecimal altintegration::DefaultPopRewardsCalculator::calculateDifficulty |
( |
const BlockIndex< AltBlock > & |
tip | ) |
|
|
protected |
Should provide at least rewardSettlementInterval blocks. Will use first blocks (usually difficultyAveragingInterval blocks) to calculate their scores and average them to get difficulty.
- Parameters
-
| tip | calculate difficulty using chain ending with this tip |
- Returns
- PopRewardsBigDecimal resulting difficulty
◆ calculateMinerReward()
| PopRewardsBigDecimal altintegration::DefaultPopRewardsCalculator::calculateMinerReward |
( |
uint32_t |
vbkRelativeHeight, |
|
|
const PopRewardsBigDecimal & |
scoreForThisBlock, |
|
|
const PopRewardsBigDecimal & |
blockReward |
|
) |
| const |
- Parameters
-
| vbkRelativeHeight | height of the VBK block with endorsement |
| scoreForThisBlock | block score |
| blockReward | total block reward |
- Returns
- PopRewardsBigDecimal resulting reward for each miner
◆ calculatePayouts()
Rewards are calculated for the endorsed block. Score is calculated from the endorsements (slow).
- Parameters
-
| endorsedBlock | endorsed altchain block which we are paying reward for. |
| [out] | rewards | PopPayouts map with miner address as a key and reward amount as a value. |
| [out] | state | validation state. |
- Returns
- true if rewards are calculated properly; false otherwise.
◆ calculatePayoutsInner()
| bool altintegration::DefaultPopRewardsCalculator::calculatePayoutsInner |
( |
const BlockIndex< AltBlock > & |
endorsedBlock, |
|
|
const PopRewardsBigDecimal & |
endorsedBlockScore, |
|
|
const PopRewardsBigDecimal & |
popDifficulty, |
|
|
PopPayouts & |
rewards, |
|
|
ValidationState & |
state |
|
) |
| |
|
protected |
Rewards are calculated for the endorsed block. Block score and POP difficulty are set as arguments to allow caching them.
- Parameters
-
| endorsedBlock | endorsed altchain block which we are paying reward for. |
| endorsedBlockScore | endorsed altchain block score - see scoreFromEndorsements() for reference. |
| popDifficulty | endorsed altchain block difficulty - see calculateDifficulty() for reference. |
| [out] | rewards | PopPayouts map with miner address as a key and reward amount as a value. |
| [out] | state | validation state. |
- Returns
- true if rewards are calculated properly; false otherwise.
◆ getPopPayout()
| bool altintegration::DefaultPopRewardsCalculator::getPopPayout |
( |
const AltBlockTree::hash_t & |
tip, |
|
|
PopPayouts & |
rewards, |
|
|
ValidationState & |
state |
|
) |
| |
|
overridevirtual |
Rewards are calculated for the endorsed block which is PopPayoutDelay blocks behind the tip.
- Parameters
-
| tip | last block of the active chain. Next block should contain POP payout calculated with this getPopPayout() call. |
| [out] | rewards | PopPayouts map with miner address as a key and reward amount as a value. |
| [out] | state | validation state. |
- Returns
- true if rewards are calculated properly; false otherwise.
Implements altintegration::PopRewardsCalculator.
◆ getRoundForBlockNumber()
| uint32_t altintegration::DefaultPopRewardsCalculator::getRoundForBlockNumber |
( |
uint32_t |
height | ) |
const |
- Parameters
-
- Returns
- uint32_t current round
◆ getScoreMultiplierFromRelativeBlock()
| PopRewardsBigDecimal altintegration::DefaultPopRewardsCalculator::getScoreMultiplierFromRelativeBlock |
( |
int |
relativeBlock | ) |
const |
|
protected |
- Parameters
-
| relativeBlock | height of the VBK block with endorsement |
- Returns
- PopRewardsBigDecimal multiplier to apply to the block reward
◆ scoreFromEndorsements()
| PopRewardsBigDecimal altintegration::DefaultPopRewardsCalculator::scoreFromEndorsements |
( |
const BlockIndex< AltBlock > & |
endorsedBlock | ) |
|
- Parameters
-
| endorsedBlock | calculate score for this block |
- Returns
- PopRewardsBigDecimal resulting score
◆ tree_
| AltBlockTree& altintegration::DefaultPopRewardsCalculator::tree_ |
|
protected |
The documentation for this struct was generated from the following file: