refactor copy

This commit is contained in:
Sina Mahmoodi 2025-02-04 16:30:39 +01:00
parent bf51ddea7a
commit 459c50f793

View file

@ -18,7 +18,6 @@ package tracing
import ( import (
"math/big" "math/big"
"reflect"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
@ -211,17 +210,8 @@ type Hooks struct {
// Note: it is not a deep copy. If a hook has been implemented as a closure and acts on // Note: it is not a deep copy. If a hook has been implemented as a closure and acts on
// a mutable state, the copied hook will still act on the same state. // a mutable state, the copied hook will still act on the same state.
func (h *Hooks) copy() *Hooks { func (h *Hooks) copy() *Hooks {
copied := &Hooks{} c := *h
srcValue := reflect.ValueOf(h).Elem() return &c
dstValue := reflect.ValueOf(copied).Elem()
for i := 0; i < srcValue.NumField(); i++ {
field := srcValue.Field(i)
if !field.IsNil() {
dstValue.Field(i).Set(field)
}
}
return copied
} }
// BalanceChangeReason is used to indicate the reason for a balance change, useful // BalanceChangeReason is used to indicate the reason for a balance change, useful