diff --git a/cmd/tomo/config.go b/cmd/tomo/config.go index dc199a04d2..cdb068b873 100644 --- a/cmd/tomo/config.go +++ b/cmd/tomo/config.go @@ -123,10 +123,11 @@ func defaultNodeConfig() node.Config { func makeConfigNode(ctx *cli.Context) (*node.Node, tomoConfig) { // Load defaults. cfg := tomoConfig{ - Eth: eth.DefaultConfig, - Shh: whisper.DefaultConfig, - Node: defaultNodeConfig(), - Dashboard: dashboard.DefaultConfig, + Eth: eth.DefaultConfig, + Shh: whisper.DefaultConfig, + Node: defaultNodeConfig(), + Dashboard: dashboard.DefaultConfig, + StakeEnable: true, } // Load config file. if file := ctx.GlobalString(configFileFlag.Name); file != "" { @@ -134,7 +135,9 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, tomoConfig) { utils.Fatalf("%v", err) } } - + if ctx.GlobalIsSet(utils.StakingEnabledFlag.Name) { + cfg.StakeEnable = ctx.GlobalBool(utils.StakingEnabledFlag.Name) + } // read passwords from enviroment passwords := []string{} for _, env := range cfg.Account.Passwords { diff --git a/cmd/tomo/main.go b/cmd/tomo/main.go index 3afa5d36bd..7d3b328416 100644 --- a/cmd/tomo/main.go +++ b/cmd/tomo/main.go @@ -27,6 +27,7 @@ import ( "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/accounts/keystore" "github.com/ethereum/go-ethereum/cmd/utils" + "github.com/ethereum/go-ethereum/consensus/posv" "github.com/ethereum/go-ethereum/console" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/eth" @@ -284,15 +285,16 @@ func startNode(ctx *cli.Context, stack *node.Node, cfg tomoConfig) { } }() // Start auxiliary services if enabled - if cfg.StakeEnable || ctx.GlobalBool(utils.DeveloperFlag.Name) { - // Mining only makes sense if a full Ethereum node is running - if ctx.GlobalBool(utils.LightModeFlag.Name) || ctx.GlobalString(utils.SyncModeFlag.Name) == "light" { - utils.Fatalf("Light clients do not support staking") - } - var ethereum *eth.Ethereum - if err := stack.Service(ðereum); err != nil { - utils.Fatalf("Ethereum service not running: %v", err) - } + + // Mining only makes sense if a full Ethereum node is running + if ctx.GlobalBool(utils.LightModeFlag.Name) || ctx.GlobalString(utils.SyncModeFlag.Name) == "light" { + utils.Fatalf("Light clients do not support staking") + } + var ethereum *eth.Ethereum + if err := stack.Service(ðereum); err != nil { + utils.Fatalf("Ethereum service not running: %v", err) + } + if _, ok := ethereum.Engine().(*posv.Posv); ok { go func() { started := false ok, err := ethereum.ValidateStaker() @@ -356,8 +358,8 @@ func startNode(ctx *cli.Context, stack *node.Node, cfg tomoConfig) { } case <-core.M1Ch: err := ethereum.BlockChain().UpdateM1() - if(err !=nil){ - log.Error("Error when update M1",err) + if err != nil { + log.Error("Error when update M1", err) } } } diff --git a/core/blockchain.go b/core/blockchain.go index 1c8884d6af..ff234c4b5b 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -698,7 +698,7 @@ func (bc *BlockChain) procFutureBlocks() { type WriteStatus byte const ( - NonStatTy WriteStatus = iota + NonStatTy WriteStatus = iota CanonStatTy SideStatTy ) @@ -1192,7 +1192,7 @@ func (bc *BlockChain) insertChain(chain types.Blocks) (int, []interface{}, []*ty stats.processed++ stats.usedGas += usedGas stats.report(chain, i, bc.stateCache.TrieDB().Size()) - if i == len(chain)-1 && bc.chainConfig.Posv != nil { + if bc.chainConfig.Posv != nil { // epoch block if (chain[i].NumberU64() % bc.chainConfig.Posv.Epoch) == 0 { CheckpointCh <- 1 diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go index 4180ae2eaa..183c36e716 100644 --- a/eth/downloader/downloader.go +++ b/eth/downloader/downloader.go @@ -1350,7 +1350,7 @@ func (d *Downloader) processFullSyncContent() error { // prepare set of masternodes for the next epoch if (inserts[len(inserts)-1].Header.Number.Uint64() % epoch) == (epoch - gap) { err := d.blockchain.UpdateM1() - if (err != nil) { + if err != nil { log.Error("Error when update M1", err) } }