fix Stake Enable = true & remove check last index when insert chain

This commit is contained in:
Nguyen Ba Tam 2018-09-05 11:19:14 +07:00
parent 7c55084785
commit 4a93b33256
4 changed files with 87 additions and 85 deletions

View file

@ -127,6 +127,7 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, tomoConfig) {
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 {

View file

@ -284,7 +284,7 @@ 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")
@ -356,11 +356,10 @@ 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)
}
}
}
}()
}
}

View file

@ -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

View file

@ -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)
}
}