mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 18:02:24 +00:00
refactor copy
This commit is contained in:
parent
bf51ddea7a
commit
459c50f793
1 changed files with 2 additions and 12 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue