eth/tracers: use atomic type (#27031)

Use the new atomic types in package eth/tracers

---------

Co-authored-by: Martin Holst Swende <martin@swende.se>
Co-authored-by: Sina Mahmoodi <itz.s1na@gmail.com>
This commit is contained in:
s7v7nislands
2023-04-04 12:34:52 -04:00
committed by GitHub
co-authored by Martin Holst Swende Sina Mahmoodi
parent b4dcd1a391
commit 2adce0b066
5 changed files with 28 additions and 22 deletions
+4 -4
View File
@@ -116,8 +116,8 @@ type StructLogger struct {
gasLimit uint64
usedGas uint64
interrupt uint32 // Atomic flag to signal execution interruption
reason error // Textual reason for the interruption
interrupt atomic.Bool // Atomic flag to signal execution interruption
reason error // Textual reason for the interruption
}
// NewStructLogger returns a new logger
@@ -149,7 +149,7 @@ func (l *StructLogger) CaptureStart(env *vm.EVM, from common.Address, to common.
// CaptureState also tracks SLOAD/SSTORE ops to track storage change.
func (l *StructLogger) CaptureState(pc uint64, op vm.OpCode, gas, cost uint64, scope *vm.ScopeContext, rData []byte, depth int, err error) {
// If tracing was interrupted, set the error and stop
if atomic.LoadUint32(&l.interrupt) > 0 {
if l.interrupt.Load() {
return
}
// check if already accumulated the specified number of logs
@@ -258,7 +258,7 @@ func (l *StructLogger) GetResult() (json.RawMessage, error) {
// Stop terminates execution of the tracer at the first opportune moment.
func (l *StructLogger) Stop(err error) {
l.reason = err
atomic.StoreUint32(&l.interrupt, 1)
l.interrupt.Store(true)
}
func (l *StructLogger) CaptureTxStart(gasLimit uint64) {