From aa9a78e4639e8594849be3fa0f92d7f91f67d528 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Mon, 27 Mar 2017 11:52:39 +0200 Subject: core, core/types: use non-pointer receiver for Marshal* methods Regenerated with fjl/gencodec@1a75a2161009 Also add ,omitempty to optional GenesisAccount fields. --- core/gen_genesis.go | 66 ++++++++++++++++++++++++++--------------------------- 1 file changed, 32 insertions(+), 34 deletions(-) (limited to 'core/gen_genesis.go') diff --git a/core/gen_genesis.go b/core/gen_genesis.go index b5561ba45..eb86567b7 100644 --- a/core/gen_genesis.go +++ b/core/gen_genesis.go @@ -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) -- cgit