UNPKG

lisk-framework

Version:

Lisk blockchain application platform

33 lines 1.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RewardMethod = void 0; const base_method_1 = require("../base_method"); const calculate_reward_1 = require("./calculate_reward"); const constants_1 = require("./constants"); class RewardMethod extends base_method_1.BaseMethod { init(args) { this._config = args.config; } addDependencies(randomMethod) { this._randomMethod = randomMethod; } async getBlockReward(context, header, assets) { const defaultReward = (0, calculate_reward_1.calculateDefaultReward)(this._config, header.height); if (defaultReward === BigInt(0)) { return [defaultReward, constants_1.REWARD_NO_REDUCTION]; } const isValidSeedReveal = await this._randomMethod.isSeedRevealValid(context, header.generatorAddress, assets); if (!isValidSeedReveal) { return [BigInt(0), constants_1.REWARD_REDUCTION_SEED_REVEAL]; } if (!header.impliesMaxPrevotes) { return [ defaultReward / BigInt(this._config.rewardReductionFactorBFT), constants_1.REWARD_REDUCTION_MAX_PREVOTES, ]; } return [defaultReward, constants_1.REWARD_NO_REDUCTION]; } } exports.RewardMethod = RewardMethod; //# sourceMappingURL=method.js.map