1
0
Fork 0
forked from forks/go-ethereum

core/types: delete unused test variable (#31776)

Delete the unused `Account.PrivateKey` variable.
This commit is contained in:
maskpp 2025-05-08 21:21:48 +08:00 committed by GitHub
parent 181dd2e660
commit 6bc57579d1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 22 deletions

View file

@ -38,17 +38,13 @@ type Account struct {
Storage map[common.Hash]common.Hash `json:"storage,omitempty"`
Balance *big.Int `json:"balance" gencodec:"required"`
Nonce uint64 `json:"nonce,omitempty"`
// used in tests
PrivateKey []byte `json:"secretKey,omitempty"`
}
type accountMarshaling struct {
Code hexutil.Bytes
Balance *math.HexOrDecimal256
Nonce math.HexOrDecimal64
Storage map[storageJSON]storageJSON
PrivateKey hexutil.Bytes
Code hexutil.Bytes
Balance *math.HexOrDecimal256
Nonce math.HexOrDecimal64
Storage map[storageJSON]storageJSON
}
// storageJSON represents a 256 bit byte array, but allows less than 256 bits when

View file

@ -17,11 +17,10 @@ var _ = (*accountMarshaling)(nil)
// MarshalJSON marshals as JSON.
func (a Account) MarshalJSON() ([]byte, error) {
type Account struct {
Code hexutil.Bytes `json:"code,omitempty"`
Storage map[storageJSON]storageJSON `json:"storage,omitempty"`
Balance *math.HexOrDecimal256 `json:"balance" gencodec:"required"`
Nonce math.HexOrDecimal64 `json:"nonce,omitempty"`
PrivateKey hexutil.Bytes `json:"secretKey,omitempty"`
Code hexutil.Bytes `json:"code,omitempty"`
Storage map[storageJSON]storageJSON `json:"storage,omitempty"`
Balance *math.HexOrDecimal256 `json:"balance" gencodec:"required"`
Nonce math.HexOrDecimal64 `json:"nonce,omitempty"`
}
var enc Account
enc.Code = a.Code
@ -33,18 +32,16 @@ func (a Account) MarshalJSON() ([]byte, error) {
}
enc.Balance = (*math.HexOrDecimal256)(a.Balance)
enc.Nonce = math.HexOrDecimal64(a.Nonce)
enc.PrivateKey = a.PrivateKey
return json.Marshal(&enc)
}
// UnmarshalJSON unmarshals from JSON.
func (a *Account) UnmarshalJSON(input []byte) error {
type Account struct {
Code *hexutil.Bytes `json:"code,omitempty"`
Storage map[storageJSON]storageJSON `json:"storage,omitempty"`
Balance *math.HexOrDecimal256 `json:"balance" gencodec:"required"`
Nonce *math.HexOrDecimal64 `json:"nonce,omitempty"`
PrivateKey *hexutil.Bytes `json:"secretKey,omitempty"`
Code *hexutil.Bytes `json:"code,omitempty"`
Storage map[storageJSON]storageJSON `json:"storage,omitempty"`
Balance *math.HexOrDecimal256 `json:"balance" gencodec:"required"`
Nonce *math.HexOrDecimal64 `json:"nonce,omitempty"`
}
var dec Account
if err := json.Unmarshal(input, &dec); err != nil {
@ -66,8 +63,5 @@ func (a *Account) UnmarshalJSON(input []byte) error {
if dec.Nonce != nil {
a.Nonce = uint64(*dec.Nonce)
}
if dec.PrivateKey != nil {
a.PrivateKey = *dec.PrivateKey
}
return nil
}