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());
}
}
Aggregations