aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorJeffrey Wilcke <geffobscura@gmail.com>2015-07-10 20:29:40 +0800
committerJeffrey Wilcke <geffobscura@gmail.com>2015-07-10 23:37:41 +0800
commita32c51effda8682b292d04863aae7811f78abf7e (patch)
treed721822cc10c929d5a2def0865c366e085ef99be /cmd
parent5a810758dbe75dce9537d464ac0e5b5385b0e78f (diff)
downloaddexon-a32c51effda8682b292d04863aae7811f78abf7e.tar
dexon-a32c51effda8682b292d04863aae7811f78abf7e.tar.gz
dexon-a32c51effda8682b292d04863aae7811f78abf7e.tar.bz2
dexon-a32c51effda8682b292d04863aae7811f78abf7e.tar.lz
dexon-a32c51effda8682b292d04863aae7811f78abf7e.tar.xz
dexon-a32c51effda8682b292d04863aae7811f78abf7e.tar.zst
dexon-a32c51effda8682b292d04863aae7811f78abf7e.zip
cmd, core, eth, common: genesis preparation
Implemented the --genesis flag thru which we can set a custom genesis block, including the official Ethereum genesis block.
Diffstat (limited to 'cmd')
-rw-r--r--cmd/geth/js_test.go6
-rw-r--r--cmd/geth/main.go1
-rw-r--r--cmd/utils/flags.go9
3 files changed, 12 insertions, 4 deletions
diff --git a/cmd/geth/js_test.go b/cmd/geth/js_test.go
index db2c5ca03..ffd164d27 100644
--- a/cmd/geth/js_test.go
+++ b/cmd/geth/js_test.go
@@ -37,6 +37,7 @@ import (
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/eth"
+ "github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/rpc/codec"
"github.com/ethereum/go-ethereum/rpc/comms"
)
@@ -89,9 +90,9 @@ func testREPL(t *testing.T, config func(*eth.Config)) (string, *testjethre, *eth
t.Fatal(err)
}
- // set up mock genesis with balance on the testAddress
- core.GenesisAccounts = []byte(testGenesis)
+ db, _ := ethdb.NewMemDatabase()
+ core.WriteGenesisBlockForTesting(db, common.HexToAddress(testAddress), common.String2Big(testBalance))
ks := crypto.NewKeyStorePlain(filepath.Join(tmp, "keystore"))
am := accounts.NewManager(ks)
conf := &eth.Config{
@@ -102,6 +103,7 @@ func testREPL(t *testing.T, config func(*eth.Config)) (string, *testjethre, *eth
Name: "test",
SolcPath: testSolcPath,
PowTest: true,
+ NewDB: func(path string) (common.Database, error) { return db, nil },
}
if config != nil {
config(conf)
diff --git a/cmd/geth/main.go b/cmd/geth/main.go
index 51a0defaa..6acdff9ad 100644
--- a/cmd/geth/main.go
+++ b/cmd/geth/main.go
@@ -277,6 +277,7 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso
utils.UnlockedAccountFlag,
utils.PasswordFileFlag,
utils.GenesisNonceFlag,
+ utils.GenesisFileFlag,
utils.BootnodesFlag,
utils.DataDirFlag,
utils.BlockchainVersionFlag,
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go
index 903c97e71..73bdb935a 100644
--- a/cmd/utils/flags.go
+++ b/cmd/utils/flags.go
@@ -114,6 +114,10 @@ var (
Usage: "Sets the genesis nonce",
Value: 42,
}
+ GenesisFileFlag = cli.StringFlag{
+ Name: "genesis",
+ Usage: "Inserts/Overwrites the genesis block (json format)",
+ }
IdentityFlag = cli.StringFlag{
Name: "identity",
Usage: "Custom node name",
@@ -378,6 +382,7 @@ func MakeEthConfig(clientID, version string, ctx *cli.Context) *eth.Config {
Name: common.MakeName(clientID, version),
DataDir: ctx.GlobalString(DataDirFlag.Name),
GenesisNonce: ctx.GlobalInt(GenesisNonceFlag.Name),
+ GenesisFile: ctx.GlobalString(GenesisFileFlag.Name),
BlockChainVersion: ctx.GlobalInt(BlockchainVersionFlag.Name),
SkipBcVersionCheck: false,
NetworkId: ctx.GlobalInt(NetworkIdFlag.Name),
@@ -434,8 +439,8 @@ func MakeChain(ctx *cli.Context) (chain *core.ChainManager, blockDB, stateDB, ex
eventMux := new(event.TypeMux)
pow := ethash.New()
- genesis := core.GenesisBlock(uint64(ctx.GlobalInt(GenesisNonceFlag.Name)), blockDB)
- chain, err = core.NewChainManager(genesis, blockDB, stateDB, extraDB, pow, eventMux)
+ //genesis := core.GenesisBlock(uint64(ctx.GlobalInt(GenesisNonceFlag.Name)), blockDB)
+ chain, err = core.NewChainManager(blockDB, stateDB, extraDB, pow, eventMux)
if err != nil {
Fatalf("Could not start chainmanager: %v", err)
}