mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-02-26 02:45:29 +00:00
turn getAccountsForDeletion into interator
This commit is contained in:
parent
b6587bddfd
commit
a02cbdd91b
@ -12,18 +12,6 @@ proc processTransaction*(tx: Transaction, sender: EthAddress, vmState: BaseVMSta
|
||||
trace "Sender", sender
|
||||
trace "txHash", rlpHash = tx.rlpHash
|
||||
|
||||
# TODO: we have identical `fork` code in setupComputation.
|
||||
# at later stage, we need to get rid of it
|
||||
# and apply changes in eth_*, debug_* RPC,
|
||||
# macro assembler and premix tool set.
|
||||
# at every place where setupComputation and
|
||||
# processTransaction are used.
|
||||
let fork =
|
||||
if forkOverride.isSome:
|
||||
forkOverride.get
|
||||
else:
|
||||
vmState.blockNumber.toFork
|
||||
|
||||
let upfrontGasCost = tx.gasLimit.u256 * tx.gasPrice.u256
|
||||
var balance = vmState.readOnlyStateDb().getBalance(sender)
|
||||
if balance < upfrontGasCost:
|
||||
@ -46,7 +34,7 @@ proc processTransaction*(tx: Transaction, sender: EthAddress, vmState: BaseVMSta
|
||||
result = tx.gasLimit
|
||||
if execComputation(computation):
|
||||
result = computation.refundGas(tx, sender)
|
||||
|
||||
|
||||
if computation.isSuicided(vmState.blockHeader.coinbase):
|
||||
return 0
|
||||
|
||||
|
@ -236,14 +236,10 @@ proc addLogEntry*(c: var BaseComputation, log: Log) {.inline.} =
|
||||
|
||||
# many methods are basically TODO, but they still return valid values
|
||||
# in order to test some existing code
|
||||
func getAccountsForDeletion*(c: BaseComputation): seq[EthAddress] =
|
||||
# TODO
|
||||
if c.isError:
|
||||
result = @[]
|
||||
else:
|
||||
result = @[]
|
||||
iterator accountsForDeletion*(c: BaseComputation): EthAddress =
|
||||
if not c.isError:
|
||||
for account in c.accountsToDelete.keys:
|
||||
result.add(account)
|
||||
yield account
|
||||
|
||||
proc getGasRefund*(c: BaseComputation): GasInt =
|
||||
if c.isError:
|
||||
|
@ -70,7 +70,7 @@ proc execComputation*(computation: var BaseComputation): bool =
|
||||
result = computation.applyMessage(Call)
|
||||
|
||||
computation.vmState.mutateStateDB:
|
||||
for deletedAccount in computation.getAccountsForDeletion:
|
||||
for deletedAccount in computation.accountsForDeletion:
|
||||
db.deleteAccount deletedAccount
|
||||
|
||||
if result:
|
||||
|
Loading…
x
Reference in New Issue
Block a user