mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
Merge 471b46d8c0 into cc2b39bbd1
This commit is contained in:
commit
8772fd0c5b
1 changed files with 17 additions and 5 deletions
|
|
@ -5,6 +5,8 @@ package core
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
|
@ -39,6 +41,7 @@ func (g GenesisAccount) MarshalJSON() ([]byte, error) {
|
||||||
func (g *GenesisAccount) UnmarshalJSON(input []byte) error {
|
func (g *GenesisAccount) UnmarshalJSON(input []byte) error {
|
||||||
type GenesisAccount struct {
|
type GenesisAccount struct {
|
||||||
Code *hexutil.Bytes `json:"code,omitempty"`
|
Code *hexutil.Bytes `json:"code,omitempty"`
|
||||||
|
CodeFilePath *string `json:"codeFilePath,omitempty"`
|
||||||
Storage map[storageJSON]storageJSON `json:"storage,omitempty"`
|
Storage map[storageJSON]storageJSON `json:"storage,omitempty"`
|
||||||
Balance *math.HexOrDecimal256 `json:"balance" gencodec:"required"`
|
Balance *math.HexOrDecimal256 `json:"balance" gencodec:"required"`
|
||||||
Nonce *math.HexOrDecimal64 `json:"nonce,omitempty"`
|
Nonce *math.HexOrDecimal64 `json:"nonce,omitempty"`
|
||||||
|
|
@ -50,6 +53,15 @@ func (g *GenesisAccount) UnmarshalJSON(input []byte) error {
|
||||||
}
|
}
|
||||||
if dec.Code != nil {
|
if dec.Code != nil {
|
||||||
g.Code = *dec.Code
|
g.Code = *dec.Code
|
||||||
|
} else if dec.CodeFilePath != nil {
|
||||||
|
// Check that the file exists
|
||||||
|
// create an io.Reader with the content of the file and get it as []byte
|
||||||
|
code, err := ioutil.ReadFile(*dec.CodeFilePath)
|
||||||
|
if err != nil {
|
||||||
|
panic(fmt.Sprintf("Could not open file: %v", err))
|
||||||
|
}
|
||||||
|
|
||||||
|
g.Code = code
|
||||||
}
|
}
|
||||||
if dec.Storage != nil {
|
if dec.Storage != nil {
|
||||||
g.Storage = make(map[common.Hash]common.Hash, len(dec.Storage))
|
g.Storage = make(map[common.Hash]common.Hash, len(dec.Storage))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue