simplify computation
This commit is contained in:
parent
8564e9532b
commit
1cd9353faa
|
@ -337,26 +337,10 @@ proc execSelfDestruct*(c: Computation, beneficiary: EthAddress) =
|
|||
proc addLogEntry*(c: Computation, log: Log) {.inline.} =
|
||||
c.logEntries.add(log)
|
||||
|
||||
proc getSuicides*(c: Computation): HashSet[EthAddress] =
|
||||
if c.isSuccess:
|
||||
result = c.suicides
|
||||
|
||||
proc getGasRefund*(c: Computation): GasInt =
|
||||
if c.isSuccess:
|
||||
result = c.gasMeter.gasRefunded
|
||||
|
||||
proc getGasUsed*(c: Computation): GasInt =
|
||||
if c.shouldBurnGas:
|
||||
result = c.msg.gas
|
||||
else:
|
||||
result = max(0, c.msg.gas - c.gasMeter.gasRemaining)
|
||||
|
||||
proc getGasRemaining*(c: Computation): GasInt =
|
||||
if c.shouldBurnGas:
|
||||
result = 0
|
||||
else:
|
||||
result = c.gasMeter.gasRemaining
|
||||
|
||||
proc refundSelfDestruct*(c: Computation) =
|
||||
let cost = gasFees[c.fork][RefundSelfDestruct]
|
||||
c.gasMeter.refundGas(cost * c.suicides.len)
|
||||
|
|
|
@ -106,9 +106,6 @@ proc getTracingResult*(vmState: BaseVMState): JsonNode =
|
|||
doAssert(vmState.tracingEnabled)
|
||||
vmState.tracer.trace
|
||||
|
||||
proc addLogs*(vmState: BaseVMState, logs: seq[Log]) =
|
||||
shallowCopy(vmState.logEntries, logs)
|
||||
|
||||
proc getAndClearLogEntries*(vmState: BaseVMState): seq[Log] =
|
||||
shallowCopy(result, vmState.logEntries)
|
||||
vmState.logEntries = @[]
|
||||
|
|
|
@ -82,8 +82,8 @@ proc execComputation*(c: Computation) =
|
|||
|
||||
if c.isSuccess:
|
||||
c.refundSelfDestruct()
|
||||
c.vmState.suicides = c.getSuicides()
|
||||
c.vmState.addLogs(c.logEntries)
|
||||
shallowCopy(c.vmState.suicides, c.suicides)
|
||||
shallowCopy(c.vmState.logEntries, c.logEntries)
|
||||
|
||||
c.vmstate.status = c.isSuccess
|
||||
|
||||
|
|
Loading…
Reference in New Issue