@@ -29,10 +29,6 @@ import (
2929 "path/filepath"
3030 "strconv"
3131 "strings"
32-
33- "github.com/ethereum/go-ethereum/permission"
34- "github.com/ethereum/go-ethereum/plugin"
35-
3632 "time"
3733
3834 "github.com/ethereum/go-ethereum/accounts"
@@ -42,7 +38,10 @@ import (
4238 "github.com/ethereum/go-ethereum/consensus"
4339 "github.com/ethereum/go-ethereum/consensus/clique"
4440 "github.com/ethereum/go-ethereum/consensus/ethash"
41+ "github.com/ethereum/go-ethereum/consensus/istanbul"
42+ istanbulBackend "github.com/ethereum/go-ethereum/consensus/istanbul/backend"
4543 "github.com/ethereum/go-ethereum/core"
44+ "github.com/ethereum/go-ethereum/core/rawdb"
4645 "github.com/ethereum/go-ethereum/core/state"
4746 "github.com/ethereum/go-ethereum/core/vm"
4847 "github.com/ethereum/go-ethereum/crypto"
@@ -63,6 +62,8 @@ import (
6362 "github.com/ethereum/go-ethereum/p2p/nat"
6463 "github.com/ethereum/go-ethereum/p2p/netutil"
6564 "github.com/ethereum/go-ethereum/params"
65+ "github.com/ethereum/go-ethereum/permission"
66+ "github.com/ethereum/go-ethereum/plugin"
6667 whisper "github.com/ethereum/go-ethereum/whisper/whisperv6"
6768 "gopkg.in/urfave/cli.v1"
6869)
@@ -609,7 +610,7 @@ var (
609610 Value : 50400 ,
610611 }
611612 RaftDNSEnabledFlag = cli.BoolFlag {
612- Name : "raftdnsenable" ,
613+ Name : "raftdnsenable" ,
613614 Usage : "Enable DNS resolution of peers" ,
614615 }
615616
@@ -1292,7 +1293,6 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
12921293 }
12931294 cfg .NoPruning = ctx .GlobalString (GCModeFlag .Name ) == "archive"
12941295
1295-
12961296 if ctx .GlobalIsSet (CacheFlag .Name ) || ctx .GlobalIsSet (CacheGCFlag .Name ) {
12971297 cfg .TrieCache = ctx .GlobalInt (CacheFlag .Name ) * ctx .GlobalInt (CacheGCFlag .Name ) / 100
12981298 }
@@ -1545,17 +1545,41 @@ func MakeGenesis(ctx *cli.Context) *core.Genesis {
15451545}
15461546
15471547// MakeChain creates a chain manager from set command line flags.
1548- func MakeChain (ctx * cli.Context , stack * node.Node ) (chain * core.BlockChain , chainDb ethdb.Database ) {
1549- var err error
1548+ func MakeChain (ctx * cli.Context , stack * node.Node , useExist bool ) (chain * core.BlockChain , chainDb ethdb.Database ) {
1549+ var (
1550+ config * params.ChainConfig
1551+ err error
1552+ )
15501553 chainDb = MakeChainDatabase (ctx , stack )
15511554
1552- config , _ , err := core .SetupGenesisBlock (chainDb , MakeGenesis (ctx ))
1553- if err != nil {
1554- Fatalf ("%v" , err )
1555+ if useExist {
1556+ stored := rawdb .ReadCanonicalHash (chainDb , 0 )
1557+ if (stored == common.Hash {}) {
1558+ Fatalf ("No existing genesis" )
1559+ }
1560+ config = rawdb .ReadChainConfig (chainDb , stored )
1561+ } else {
1562+ config , _ , err = core .SetupGenesisBlock (chainDb , MakeGenesis (ctx ))
1563+ if err != nil {
1564+ Fatalf ("%v" , err )
1565+ }
15551566 }
1567+
15561568 var engine consensus.Engine
15571569 if config .Clique != nil {
15581570 engine = clique .New (config .Clique , chainDb )
1571+ } else if config .Istanbul != nil {
1572+ // for IBFT
1573+ istanbulConfig := istanbul .DefaultConfig
1574+ if config .Istanbul .Epoch != 0 {
1575+ istanbulConfig .Epoch = config .Istanbul .Epoch
1576+ }
1577+ istanbulConfig .ProposerPolicy = istanbul .ProposerPolicy (config .Istanbul .ProposerPolicy )
1578+ istanbulConfig .Ceil2Nby3Block = config .Istanbul .Ceil2Nby3Block
1579+ engine = istanbulBackend .New (istanbulConfig , stack .GetNodeKey (), chainDb )
1580+ } else if config .IsQuorum {
1581+ // for Raft
1582+ engine = ethash .NewFullFaker ()
15591583 } else {
15601584 engine = ethash .NewFaker ()
15611585 if ! ctx .GlobalBool (FakePoWFlag .Name ) {
0 commit comments