aboutsummaryrefslogtreecommitdiffstats
path: root/core/gen_genesis_account.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@users.noreply.github.com>2017-04-06 16:38:21 +0800
committerPéter Szilágyi <peterke@gmail.com>2017-04-06 16:38:21 +0800
commit3d8de95f999de6f52f0c1605eb2913278f1d87d2 (patch)
tree1906f5ec11dbbd304bb30f3e75c117727a4d1e79 /core/gen_genesis_account.go
parent24b9860c1bc214d2db943bc69117818311406bdb (diff)
downloaddexon-3d8de95f999de6f52f0c1605eb2913278f1d87d2.tar
dexon-3d8de95f999de6f52f0c1605eb2913278f1d87d2.tar.gz
dexon-3d8de95f999de6f52f0c1605eb2913278f1d87d2.tar.bz2
dexon-3d8de95f999de6f52f0c1605eb2913278f1d87d2.tar.lz
dexon-3d8de95f999de6f52f0c1605eb2913278f1d87d2.tar.xz
dexon-3d8de95f999de6f52f0c1605eb2913278f1d87d2.tar.zst
dexon-3d8de95f999de6f52f0c1605eb2913278f1d87d2.zip
core, core/types: regenerate JSON marshaling, add "hash" to headers (#13868)
* Makefile: fix devtools target * core: regenerate genesis marshaling with fjl/gencodec@cbfa5be5a8a8 * core/types: regenerate marshaling methods with fjl/gencodec@cbfa5be5a8a8 * core/types: add "hash" to JSON headers
Diffstat (limited to 'core/gen_genesis_account.go')
-rw-r--r--core/gen_genesis_account.go34
1 files changed, 16 insertions, 18 deletions
diff --git a/core/gen_genesis_account.go b/core/gen_genesis_account.go
index 8885603aa..bc5fc936b 100644
--- a/core/gen_genesis_account.go
+++ b/core/gen_genesis_account.go
@@ -13,13 +13,13 @@ import (
)
func (g GenesisAccount) MarshalJSON() ([]byte, error) {
- type GenesisAccountJSON struct {
- Code hexutil.Bytes `json:"code,omitempty" optional:"true"`
- Storage map[common.Hash]common.Hash `json:"storage,omitempty" optional:"true"`
- Balance *math.HexOrDecimal256 `json:"balance"`
- Nonce math.HexOrDecimal64 `json:"nonce,omitempty" optional:"true"`
+ type GenesisAccount struct {
+ Code hexutil.Bytes `json:"code,omitempty"`
+ Storage map[common.Hash]common.Hash `json:"storage,omitempty"`
+ Balance *math.HexOrDecimal256 `json:"balance" gencodec:"required"`
+ Nonce math.HexOrDecimal64 `json:"nonce,omitempty"`
}
- var enc GenesisAccountJSON
+ var enc GenesisAccount
enc.Code = g.Code
enc.Storage = g.Storage
enc.Balance = (*math.HexOrDecimal256)(g.Balance)
@@ -28,30 +28,28 @@ func (g GenesisAccount) MarshalJSON() ([]byte, error) {
}
func (g *GenesisAccount) UnmarshalJSON(input []byte) error {
- type GenesisAccountJSON struct {
- Code hexutil.Bytes `json:"code,omitempty" optional:"true"`
- Storage map[common.Hash]common.Hash `json:"storage,omitempty" optional:"true"`
- Balance *math.HexOrDecimal256 `json:"balance"`
- Nonce *math.HexOrDecimal64 `json:"nonce,omitempty" optional:"true"`
+ type GenesisAccount struct {
+ Code hexutil.Bytes `json:"code,omitempty"`
+ Storage map[common.Hash]common.Hash `json:"storage,omitempty"`
+ Balance *math.HexOrDecimal256 `json:"balance" gencodec:"required"`
+ Nonce *math.HexOrDecimal64 `json:"nonce,omitempty"`
}
- var dec GenesisAccountJSON
+ var dec GenesisAccount
if err := json.Unmarshal(input, &dec); err != nil {
return err
}
- var x GenesisAccount
if dec.Code != nil {
- x.Code = dec.Code
+ g.Code = dec.Code
}
if dec.Storage != nil {
- x.Storage = dec.Storage
+ g.Storage = dec.Storage
}
if dec.Balance == nil {
return errors.New("missing required field 'balance' for GenesisAccount")
}
- x.Balance = (*big.Int)(dec.Balance)
+ g.Balance = (*big.Int)(dec.Balance)
if dec.Nonce != nil {
- x.Nonce = uint64(*dec.Nonce)
+ g.Nonce = uint64(*dec.Nonce)
}
- *g = x
return nil
}