diff options
author | obscuren <geffobscura@gmail.com> | 2015-06-08 18:12:13 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-06-09 00:33:43 +0800 |
commit | 6244b10a8f74d92addf977994e5a9c0e457229bb (patch) | |
tree | 30ad7e939d001e8a1400b76e4403546777c9f3aa /cmd/utils | |
parent | c6faa18ec9630066683548ed410e364555fd838d (diff) | |
download | dexon-6244b10a8f74d92addf977994e5a9c0e457229bb.tar.gz dexon-6244b10a8f74d92addf977994e5a9c0e457229bb.tar.zst dexon-6244b10a8f74d92addf977994e5a9c0e457229bb.zip |
core: settable genesis nonce
You can set the nonce of the block with `--genesisnonce`. When the
genesis nonce changes and it doesn't match with the first block in your
database it will fail. A new `datadir` must be given if the nonce of the
genesis block changes.
Diffstat (limited to 'cmd/utils')
-rw-r--r-- | cmd/utils/flags.go | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 909d7815e..ab7eaf023 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -93,6 +93,11 @@ var ( Usage: "Blockchain version (integer)", Value: core.BlockChainVersion, } + GenesisNonceFlag = cli.IntFlag{ + Name: "genesisnonce", + Usage: "Sets the genesis nonce", + Value: 42, + } IdentityFlag = cli.StringFlag{ Name: "identity", Usage: "Custom node name", @@ -294,6 +299,7 @@ func MakeEthConfig(clientID, version string, ctx *cli.Context) *eth.Config { Name: common.MakeName(clientID, version), DataDir: ctx.GlobalString(DataDirFlag.Name), ProtocolVersion: ctx.GlobalInt(ProtocolVersionFlag.Name), + GenesisNonce: ctx.GlobalInt(GenesisNonceFlag.Name), BlockChainVersion: ctx.GlobalInt(BlockchainVersionFlag.Name), SkipBcVersionCheck: false, NetworkId: ctx.GlobalInt(NetworkIdFlag.Name), @@ -344,7 +350,12 @@ func MakeChain(ctx *cli.Context) (chain *core.ChainManager, blockDB, stateDB, ex eventMux := new(event.TypeMux) pow := ethash.New() - chain = core.NewChainManager(blockDB, stateDB, pow, eventMux) + genesis := core.GenesisBlock(uint64(ctx.GlobalInt(GenesisNonceFlag.Name)), blockDB) + chain, err = core.NewChainManager(genesis, blockDB, stateDB, pow, eventMux) + if err != nil { + Fatalf("Could not start chainmanager: %v", err) + } + proc := core.NewBlockProcessor(stateDB, extraDB, pow, chain, eventMux) chain.SetProcessor(proc) return chain, blockDB, stateDB, extraDB |