diff options
Diffstat (limited to 'core/gen_genesis.go')
-rw-r--r-- | core/gen_genesis.go | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/core/gen_genesis.go b/core/gen_genesis.go index 3f83905c9..1f3b4a8aa 100644 --- a/core/gen_genesis.go +++ b/core/gen_genesis.go @@ -13,24 +13,27 @@ import ( "github.com/ethereum/go-ethereum/params" ) +var _ = (*genesisSpecMarshaling)(nil) + func (g Genesis) MarshalJSON() ([]byte, error) { type Genesis struct { Config *params.ChainConfig `json:"config"` Nonce math.HexOrDecimal64 `json:"nonce"` Timestamp math.HexOrDecimal64 `json:"timestamp"` - ParentHash common.Hash `json:"parentHash"` ExtraData hexutil.Bytes `json:"extraData"` GasLimit math.HexOrDecimal64 `json:"gasLimit" gencodec:"required"` Difficulty *math.HexOrDecimal256 `json:"difficulty" gencodec:"required"` Mixhash common.Hash `json:"mixHash"` Coinbase common.Address `json:"coinbase"` Alloc map[common.UnprefixedAddress]GenesisAccount `json:"alloc" gencodec:"required"` + Number uint64 `json:"number"` + GasUsed math.HexOrDecimal64 `json:"gasUsed"` + ParentHash common.Hash `json:"parentHash"` } var enc Genesis 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) @@ -42,6 +45,9 @@ func (g Genesis) MarshalJSON() ([]byte, error) { enc.Alloc[common.UnprefixedAddress(k)] = v } } + enc.Number = g.Number + enc.GasUsed = math.HexOrDecimal64(g.GasUsed) + enc.ParentHash = g.ParentHash return json.Marshal(&enc) } @@ -50,13 +56,15 @@ func (g *Genesis) UnmarshalJSON(input []byte) error { Config *params.ChainConfig `json:"config"` Nonce *math.HexOrDecimal64 `json:"nonce"` Timestamp *math.HexOrDecimal64 `json:"timestamp"` - ParentHash *common.Hash `json:"parentHash"` ExtraData hexutil.Bytes `json:"extraData"` GasLimit *math.HexOrDecimal64 `json:"gasLimit" gencodec:"required"` Difficulty *math.HexOrDecimal256 `json:"difficulty" gencodec:"required"` Mixhash *common.Hash `json:"mixHash"` Coinbase *common.Address `json:"coinbase"` Alloc map[common.UnprefixedAddress]GenesisAccount `json:"alloc" gencodec:"required"` + Number *uint64 `json:"number"` + GasUsed *math.HexOrDecimal64 `json:"gasUsed"` + ParentHash *common.Hash `json:"parentHash"` } var dec Genesis if err := json.Unmarshal(input, &dec); err != nil { @@ -71,9 +79,6 @@ func (g *Genesis) UnmarshalJSON(input []byte) error { if dec.Timestamp != nil { g.Timestamp = uint64(*dec.Timestamp) } - if dec.ParentHash != nil { - g.ParentHash = *dec.ParentHash - } if dec.ExtraData != nil { g.ExtraData = dec.ExtraData } @@ -98,5 +103,14 @@ func (g *Genesis) UnmarshalJSON(input []byte) error { for k, v := range dec.Alloc { g.Alloc[common.Address(k)] = v } + if dec.Number != nil { + g.Number = *dec.Number + } + if dec.GasUsed != nil { + g.GasUsed = uint64(*dec.GasUsed) + } + if dec.ParentHash != nil { + g.ParentHash = *dec.ParentHash + } return nil } |