nimbus-eth1/nimbus/core/executor/calculate_reward.nim
Jordan Hrycaj 89ae9621c4
Silence compiler gossip after nim upgrade (#1454)
* Silence some compiler gossip -- part 1, tx_pool

details:
  Mostly removing redundant imports and `Defect` tracer after switch
  to nim 1.6

* Silence some compiler gossip -- part 2, clique

details:
  Mostly removing redundant imports and `Defect` tracer after switch
  to nim 1.6

* Silence some compiler gossip -- part 3, misc core

details:
  Mostly removing redundant imports and `Defect` tracer after switch
  to nim 1.6

* Silence some compiler gossip -- part 4, sync

details:
  Mostly removing redundant imports and `Defect` tracer after switch
  to nim 1.6

* Clique update

why:
  Missing exception annotation
2023-01-30 22:10:23 +00:00

42 lines
1.3 KiB
Nim

# Nimbus
# Copyright (c) 2018 Status Research & Development GmbH
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
# http://www.apache.org/licenses/LICENSE-2.0)
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or
# http://opensource.org/licenses/MIT)
# at your option. This file may not be copied, modified, or distributed except
# according to those terms.
import
../../db/accounts_cache,
../../common/common,
../../vm_state,
../../vm_types
{.push raises: [].}
proc calculateReward*(vmState: BaseVMState; account: EthAddress;
number: BlockNumber; uncles: openArray[BlockHeader]) =
let blockReward = vmState.com.blockReward()
var mainReward = blockReward
for uncle in uncles:
var uncleReward = uncle.blockNumber.u256 + 8.u256
uncleReward -= number
uncleReward = uncleReward * blockReward
uncleReward = uncleReward div 8.u256
vmState.mutateStateDB:
db.addBalance(uncle.coinbase, uncleReward)
mainReward += blockReward div 32.u256
vmState.mutateStateDB:
db.addBalance(account, mainReward)
proc calculateReward*(vmState: BaseVMState;
header: BlockHeader; body: BlockBody) =
vmState.calculateReward(header.coinbase, header.blockNumber, body.uncles)
# End