private void ApplyMinerRewards(Block block, IBlockTracer tracer) { if (_logger.IsTrace) { _logger.Trace("Applying miner rewards:"); } var rewards = _rewardCalculator.CalculateRewards(block); for (int i = 0; i < rewards.Length; i++) { BlockReward reward = rewards[i]; ITxTracer txTracer = null; if (tracer.IsTracingRewards) { txTracer = tracer.StartNewTxTrace(null); } ApplyMinerReward(block, reward, tracer.IsTracingRewards ? tracer : NullBlockTracer.Instance); if (tracer.IsTracingRewards) { tracer.EndTxTrace(); tracer.ReportReward(reward.Address, reward.RewardType.ToLowerString(), (UInt256)reward.Value); if (txTracer?.IsTracingState ?? false) { _stateProvider.Commit(_specProvider.GetSpec(block.Number), txTracer); } } } }
private void ApplyMinerRewards(Block block) { if (_logger.IsDebugEnabled) { _logger.Debug("Applying miner rewards:"); } BlockReward[] rewards = _rewardCalculator.CalculateRewards(block); for (int i = 0; i < rewards.Length; i++) { if (_logger.IsDebugEnabled) { _logger.Debug($" {((decimal)rewards[i].Value / (decimal)Unit.Ether):N3}{Unit.EthSymbol} for account at {rewards[i].Address}"); } if (!_stateProvider.AccountExists(rewards[i].Address)) { _stateProvider.CreateAccount(rewards[i].Address, rewards[i].Value); } else { _stateProvider.UpdateBalance(rewards[i].Address, rewards[i].Value, _specProvider.GetSpec(block.Number)); } } _stateProvider.Commit(_specProvider.GetSpec(block.Number)); }
// TODO: block processor pipeline private void ApplyMinerRewards(Block block, IBlockTracer tracer, IReleaseSpec spec) { if (_logger.IsTrace) { _logger.Trace("Applying miner rewards:"); } BlockReward[] rewards = _rewardCalculator.CalculateRewards(block); for (int i = 0; i < rewards.Length; i++) { BlockReward reward = rewards[i]; ITxTracer txTracer = NullTxTracer.Instance; if (tracer.IsTracingRewards) { // we need this tracer to be able to track any potential miner account creation txTracer = tracer.StartNewTxTrace(null); } ApplyMinerReward(block, reward, spec); if (tracer.IsTracingRewards) { tracer.EndTxTrace(); tracer.ReportReward(reward.Address, reward.RewardType.ToLowerString(), reward.Value); if (txTracer.IsTracingState) { _stateProvider.Commit(spec, txTracer); } } } }
private void ApplyMinerRewards(Block block, IBlockTracer tracer) { if (_logger.IsTrace) { _logger.Trace("Applying miner rewards:"); } var rewards = _rewardCalculator.CalculateRewards(block); for (int i = 0; i < rewards.Length; i++) { BlockReward reward = rewards[i]; ITxTracer txTracer = null; if (tracer.IsTracingRewards) { // we need this tracer to be able to track any potential miner account creation txTracer = tracer.StartNewTxTrace(null); } ApplyMinerReward(block, reward); if (tracer.IsTracingRewards) { tracer.EndTxTrace(); tracer.ReportReward(reward.Address, reward.RewardType.ToLowerString(), reward.Value); if (txTracer?.IsTracingState ?? false) { _stateProvider.Commit(_specProvider.GetSpec(block.Number), txTracer); } } } }
public BlockReward[] CalculateRewards(Block block) { if (_poSSwitcher.IsPostMerge(block.Header)) { return(NoBlockRewards.Instance.CalculateRewards(block)); } return(_beforeTheMerge.CalculateRewards(block)); }