core, core/types: use non-pointer receiver for Marshal* methods

Regenerated with fjl/gencodec@1a75a21610
Also add ,omitempty to optional GenesisAccount fields.
This commit is contained in:
Felix Lange
2017-03-27 11:52:39 +02:00
parent 7419d0c382
commit aa9a78e463
7 changed files with 106 additions and 112 deletions

View File

@@ -1,4 +1,4 @@
// generated by github.com/fjl/gencodec, do not edit.
// Code generated by github.com/fjl/gencodec. DO NOT EDIT.
package core
@@ -13,31 +13,29 @@ import (
"github.com/ethereum/go-ethereum/params"
)
func (g *Genesis) MarshalJSON() ([]byte, error) {
func (g Genesis) MarshalJSON() ([]byte, error) {
type GenesisJSON struct {
ChainConfig *params.ChainConfig `json:"config" optional:"true"`
Nonce *math.HexOrDecimal64 `json:"nonce" optional:"true"`
Timestamp *math.HexOrDecimal64 `json:"timestamp" optional:"true"`
ParentHash *common.Hash `json:"parentHash" optional:"true"`
ExtraData hexutil.Bytes `json:"extraData" optional:"true"`
GasLimit *math.HexOrDecimal64 `json:"gasLimit"`
Difficulty *math.HexOrDecimal256 `json:"difficulty"`
Mixhash *common.Hash `json:"mixHash" optional:"true"`
Coinbase *common.Address `json:"coinbase" optional:"true"`
Alloc map[common.UnprefixedAddress]GenesisAccount `json:"alloc"`
Config *params.ChainConfig `json:"config" optional:"true"`
Nonce math.HexOrDecimal64 `json:"nonce" optional:"true"`
Timestamp math.HexOrDecimal64 `json:"timestamp" optional:"true"`
ParentHash common.Hash `json:"parentHash" optional:"true"`
ExtraData hexutil.Bytes `json:"extraData" optional:"true"`
GasLimit math.HexOrDecimal64 `json:"gasLimit"`
Difficulty *math.HexOrDecimal256 `json:"difficulty"`
Mixhash common.Hash `json:"mixHash" optional:"true"`
Coinbase common.Address `json:"coinbase" optional:"true"`
Alloc map[common.UnprefixedAddress]GenesisAccount `json:"alloc"`
}
var enc GenesisJSON
enc.ChainConfig = g.Config
enc.Nonce = (*math.HexOrDecimal64)(&g.Nonce)
enc.Timestamp = (*math.HexOrDecimal64)(&g.Timestamp)
enc.ParentHash = &g.ParentHash
if g.ExtraData != nil {
enc.ExtraData = g.ExtraData
}
enc.GasLimit = (*math.HexOrDecimal64)(&g.GasLimit)
enc.Config = g.Config
enc.Nonce = math.HexOrDecimal64(g.Nonce)
enc.Timestamp = math.HexOrDecimal64(g.Timestamp)
enc.ParentHash = g.ParentHash
enc.ExtraData = g.ExtraData
enc.GasLimit = math.HexOrDecimal64(g.GasLimit)
enc.Difficulty = (*math.HexOrDecimal256)(g.Difficulty)
enc.Mixhash = &g.Mixhash
enc.Coinbase = &g.Coinbase
enc.Mixhash = g.Mixhash
enc.Coinbase = g.Coinbase
if g.Alloc != nil {
enc.Alloc = make(map[common.UnprefixedAddress]GenesisAccount, len(g.Alloc))
for k, v := range g.Alloc {
@@ -49,24 +47,24 @@ func (g *Genesis) MarshalJSON() ([]byte, error) {
func (g *Genesis) UnmarshalJSON(input []byte) error {
type GenesisJSON struct {
ChainConfig *params.ChainConfig `json:"config" optional:"true"`
Nonce *math.HexOrDecimal64 `json:"nonce" optional:"true"`
Timestamp *math.HexOrDecimal64 `json:"timestamp" optional:"true"`
ParentHash *common.Hash `json:"parentHash" optional:"true"`
ExtraData hexutil.Bytes `json:"extraData" optional:"true"`
GasLimit *math.HexOrDecimal64 `json:"gasLimit"`
Difficulty *math.HexOrDecimal256 `json:"difficulty"`
Mixhash *common.Hash `json:"mixHash" optional:"true"`
Coinbase *common.Address `json:"coinbase" optional:"true"`
Alloc map[common.UnprefixedAddress]GenesisAccount `json:"alloc"`
Config *params.ChainConfig `json:"config" optional:"true"`
Nonce *math.HexOrDecimal64 `json:"nonce" optional:"true"`
Timestamp *math.HexOrDecimal64 `json:"timestamp" optional:"true"`
ParentHash *common.Hash `json:"parentHash" optional:"true"`
ExtraData hexutil.Bytes `json:"extraData" optional:"true"`
GasLimit *math.HexOrDecimal64 `json:"gasLimit"`
Difficulty *math.HexOrDecimal256 `json:"difficulty"`
Mixhash *common.Hash `json:"mixHash" optional:"true"`
Coinbase *common.Address `json:"coinbase" optional:"true"`
Alloc map[common.UnprefixedAddress]GenesisAccount `json:"alloc"`
}
var dec GenesisJSON
if err := json.Unmarshal(input, &dec); err != nil {
return err
}
var x Genesis
if dec.ChainConfig != nil {
x.Config = dec.ChainConfig
if dec.Config != nil {
x.Config = dec.Config
}
if dec.Nonce != nil {
x.Nonce = uint64(*dec.Nonce)