Merge pull request #164 from nguyenbatam/fix_update_flag_miner

fix Stake Enable = true & remove check last index when insert chain
This commit is contained in:
Tuna 2018-09-06 11:12:20 +07:00 committed by GitHub
commit d33a3027bc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 19 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

@ -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,7 +285,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")
@ -293,6 +294,7 @@ func startNode(ctx *cli.Context, stack *node.Node, cfg tomoConfig) {
if err := stack.Service(&ethereum); 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,7 +358,7 @@ func startNode(ctx *cli.Context, stack *node.Node, cfg tomoConfig) {
}
case <-core.M1Ch:
err := ethereum.BlockChain().UpdateM1()
if(err !=nil){
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)
}
}