istanbul-tools/genesis/gen_quorum_genesis.go

117 lines
4.3 KiB
Go

// Code generated by github.com/fjl/gencodec. DO NOT EDIT.
package genesis
import (
"encoding/json"
"errors"
"math/big"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/core"
)
var _ = (*genesisSpecMarshaling)(nil)
func (q QuorumGenesis) MarshalJSON() ([]byte, error) {
type QuorumGenesis struct {
Config *QuorumChainConfig `json:"config"`
Nonce math.HexOrDecimal64 `json:"nonce"`
Timestamp math.HexOrDecimal64 `json:"timestamp"`
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]core.GenesisAccount `json:"alloc" gencodec:"required"`
Number math.HexOrDecimal64 `json:"number"`
GasUsed math.HexOrDecimal64 `json:"gasUsed"`
ParentHash common.Hash `json:"parentHash"`
}
var enc QuorumGenesis
enc.Config = q.Config
enc.Nonce = math.HexOrDecimal64(q.Nonce)
enc.Timestamp = math.HexOrDecimal64(q.Timestamp)
enc.ExtraData = q.ExtraData
enc.GasLimit = math.HexOrDecimal64(q.GasLimit)
enc.Difficulty = (*math.HexOrDecimal256)(q.Difficulty)
enc.Mixhash = q.Mixhash
enc.Coinbase = q.Coinbase
if q.Alloc != nil {
enc.Alloc = make(map[common.UnprefixedAddress]core.GenesisAccount, len(q.Alloc))
for k, v := range q.Alloc {
enc.Alloc[common.UnprefixedAddress(k)] = v
}
}
enc.Number = math.HexOrDecimal64(q.Number)
enc.GasUsed = math.HexOrDecimal64(q.GasUsed)
enc.ParentHash = q.ParentHash
return json.Marshal(&enc)
}
func (q *QuorumGenesis) UnmarshalJSON(input []byte) error {
type QuorumGenesis struct {
Config *QuorumChainConfig `json:"config"`
Nonce *math.HexOrDecimal64 `json:"nonce"`
Timestamp *math.HexOrDecimal64 `json:"timestamp"`
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]core.GenesisAccount `json:"alloc" gencodec:"required"`
Number *math.HexOrDecimal64 `json:"number"`
GasUsed *math.HexOrDecimal64 `json:"gasUsed"`
ParentHash *common.Hash `json:"parentHash"`
}
var dec QuorumGenesis
if err := json.Unmarshal(input, &dec); err != nil {
return err
}
if dec.Config != nil {
q.Config = dec.Config
}
if dec.Nonce != nil {
q.Nonce = uint64(*dec.Nonce)
}
if dec.Timestamp != nil {
q.Timestamp = uint64(*dec.Timestamp)
}
if dec.ExtraData != nil {
q.ExtraData = dec.ExtraData
}
if dec.GasLimit == nil {
return errors.New("missing required field 'gasLimit' for QuorumGenesis")
}
q.GasLimit = uint64(*dec.GasLimit)
if dec.Difficulty == nil {
return errors.New("missing required field 'difficulty' for QuorumGenesis")
}
q.Difficulty = (*big.Int)(dec.Difficulty)
if dec.Mixhash != nil {
q.Mixhash = *dec.Mixhash
}
if dec.Coinbase != nil {
q.Coinbase = *dec.Coinbase
}
if dec.Alloc == nil {
return errors.New("missing required field 'alloc' for QuorumGenesis")
}
q.Alloc = make(core.GenesisAlloc, len(dec.Alloc))
for k, v := range dec.Alloc {
q.Alloc[common.Address(k)] = v
}
if dec.Number != nil {
q.Number = uint64(*dec.Number)
}
if dec.GasUsed != nil {
q.GasUsed = uint64(*dec.GasUsed)
}
if dec.ParentHash != nil {
q.ParentHash = *dec.ParentHash
}
return nil
}