fix StructLog (#672)

This commit is contained in:
HAOYUatHZ 2024-03-16 16:23:49 +08:00 committed by GitHub
parent 4ebc036d75
commit badcd0c432
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -8,6 +8,7 @@ import (
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/common/math" "github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/core/vm"
"github.com/holiman/uint256" "github.com/holiman/uint256"
) )
@ -29,6 +30,7 @@ func (s StructLog) MarshalJSON() ([]byte, error) {
Depth int `json:"depth"` Depth int `json:"depth"`
RefundCounter uint64 `json:"refund"` RefundCounter uint64 `json:"refund"`
Err error `json:"-"` Err error `json:"-"`
ExtraData *types.ExtraData `json:"extraData"`
OpName string `json:"opName"` OpName string `json:"opName"`
ErrorString string `json:"error,omitempty"` ErrorString string `json:"error,omitempty"`
} }
@ -45,6 +47,7 @@ func (s StructLog) MarshalJSON() ([]byte, error) {
enc.Depth = s.Depth enc.Depth = s.Depth
enc.RefundCounter = s.RefundCounter enc.RefundCounter = s.RefundCounter
enc.Err = s.Err enc.Err = s.Err
enc.ExtraData = s.ExtraData
enc.OpName = s.OpName() enc.OpName = s.OpName()
enc.ErrorString = s.ErrorString() enc.ErrorString = s.ErrorString()
return json.Marshal(&enc) return json.Marshal(&enc)
@ -65,6 +68,7 @@ func (s *StructLog) UnmarshalJSON(input []byte) error {
Depth *int `json:"depth"` Depth *int `json:"depth"`
RefundCounter *uint64 `json:"refund"` RefundCounter *uint64 `json:"refund"`
Err error `json:"-"` Err error `json:"-"`
ExtraData *types.ExtraData `json:"extraData"`
} }
var dec StructLog var dec StructLog
if err := json.Unmarshal(input, &dec); err != nil { if err := json.Unmarshal(input, &dec); err != nil {
@ -106,5 +110,8 @@ func (s *StructLog) UnmarshalJSON(input []byte) error {
if dec.Err != nil { if dec.Err != nil {
s.Err = dec.Err s.Err = dec.Err
} }
if dec.ExtraData != nil {
s.ExtraData = dec.ExtraData
}
return nil return nil
} }