turn getAccountsForDeletion into interator

This commit is contained in:
andri lim 2019-03-20 00:11:35 +07:00
parent b6587bddfd
commit a02cbdd91b
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
3 changed files with 5 additions and 21 deletions

View File

@ -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

View File

@ -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:

View File

@ -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: