Search in sources :

Example 1 with IRewardsCalculator

use of org.aion.zero.impl.core.IRewardsCalculator in project aion by aionnetwork.

the class AionChainHolder method calculateReward.

@Override
public BigInteger calculateReward(Block block) {
    Objects.requireNonNull(block);
    if (chain.getAionHub().isForkSignatureSwapActive(block.getNumber())) {
        boolean isMiningBlock = block.getHeader().getSealType().equals(Seal.PROOF_OF_WORK);
        IRewardsCalculator calculator = ((AionBlockchainImpl) chain.getBlockchain()).getChainConfiguration().getRewardsCalculatorAfterSignatureSchemeSwap(isMiningBlock);
        if (isMiningBlock) {
            Block parent = chain.getBlockchain().getBlockByHash(block.getParentHash());
            Objects.requireNonNull(parent);
            return calculator.calculateReward(block.getTimestamp() - parent.getTimestamp());
        } else {
            return calculator.calculateReward(block.getNumber());
        }
    } else {
        return ((AionBlockchainImpl) chain.getBlockchain()).getChainConfiguration().getRewardsCalculatorBeforeSignatureSchemeSwap(chain.getAionHub().isForkUnityActive(block.getNumber())).calculateReward(block.getNumber());
    }
}
Also used : IRewardsCalculator(org.aion.zero.impl.core.IRewardsCalculator) StakingBlock(org.aion.zero.impl.types.StakingBlock) MiningBlock(org.aion.zero.impl.types.MiningBlock) Block(org.aion.zero.impl.types.Block) AionBlockchainImpl(org.aion.zero.impl.blockchain.AionBlockchainImpl)

Aggregations

AionBlockchainImpl (org.aion.zero.impl.blockchain.AionBlockchainImpl)1 IRewardsCalculator (org.aion.zero.impl.core.IRewardsCalculator)1 Block (org.aion.zero.impl.types.Block)1 MiningBlock (org.aion.zero.impl.types.MiningBlock)1 StakingBlock (org.aion.zero.impl.types.StakingBlock)1