mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-11 21:04:11 +00:00
Helper procs for updating opcode executor based on fork
This commit is contained in:
parent
d435e434ec
commit
b49637cdbf
@ -222,14 +222,22 @@ macro genFrontierDispatch(computation: BaseComputation): untyped =
|
||||
proc frontierVM(computation: var BaseComputation) =
|
||||
genFrontierDispatch(computation)
|
||||
|
||||
proc updateOpcodeExec*(computation: var BaseComputation, fork: Fork) =
|
||||
case fork
|
||||
of FkFrontier:
|
||||
computation.opCodeExec = frontierVM
|
||||
computation.frontierVM()
|
||||
else:
|
||||
raise newException(VMError, "Unknown or not implemented fork: " & $fork)
|
||||
|
||||
proc updateOpcodeExec*(computation: var BaseComputation) =
|
||||
let fork = computation.vmState.blockHeader.blockNumber.toFork
|
||||
computation.updateOpcodeExec(fork)
|
||||
|
||||
proc executeOpcodes*(computation: var BaseComputation) =
|
||||
# TODO: Optimise getting fork and updating opCodeExec only when necessary
|
||||
let fork = computation.vmState.blockHeader.blockNumber.toFork
|
||||
try:
|
||||
case fork
|
||||
of FkFrontier:
|
||||
computation.opCodeExec = frontierVM
|
||||
computation.frontierVM()
|
||||
else:
|
||||
raise newException(ValueError, "not implemented fork: " & $fork)
|
||||
computation.updateOpcodeExec(fork)
|
||||
except VMError:
|
||||
computation.error = Error(info: getCurrentExceptionMsg())
|
||||
|
Loading…
x
Reference in New Issue
Block a user