mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-02-02 23:35:31 +00:00
b623909c44
* Activate `LedgerRef` wrapper for `AccountsCache` details: `accounts_cache.nim` methods are indirectly processed by the wrapper methods from `ledger.nim`. This works for all sources except `test_state_db.nim` where the source `accounts_cache.nim` is included (rather than imported) in order to access objects privy to the very source. * Provide facility to switch to a preselected `LedgerRef` type details: Can be set as suggestion when initialising `CommonRef` * Update `CoreDb` test suite for better time tracking details: + Allow time logging by pre-defined block intervals + Print `CoreDb`/`Ledger`profiling results (if enabled)
42 lines
1.3 KiB
Nim
42 lines
1.3 KiB
Nim
# Nimbus
|
|
# Copyright (c) 2018-2023 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/ledger,
|
|
../../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
|