fix golint

This commit is contained in:
Tuna 2018-09-27 14:36:58 +07:00
parent 30ae355fd1
commit 205878c40b
2 changed files with 28 additions and 31 deletions

View file

@ -151,7 +151,7 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, tomoConfig) {
ctx.Set(utils.NATFlag.Name, cfg.NAT) ctx.Set(utils.NATFlag.Name, cfg.NAT)
} }
// read passwords from enviroment // read passwords from environment
passwords := []string{} passwords := []string{}
for _, env := range cfg.Account.Passwords { for _, env := range cfg.Account.Passwords {
if trimmed := strings.TrimSpace(env); trimmed != "" { if trimmed := strings.TrimSpace(env); trimmed != "" {

View file

@ -321,40 +321,37 @@ func startNode(ctx *cli.Context, stack *node.Node, cfg tomoConfig) {
log.Info("Enabled staking node!!!") log.Info("Enabled staking node!!!")
} }
defer close(core.CheckpointCh) defer close(core.CheckpointCh)
for { for range core.CheckpointCh {
select { log.Info("Checkpoint!!! It's time to reconcile node's state...")
case <-core.CheckpointCh: ok, err := ethereum.ValidateStaker()
log.Info("Checkpoint!!! It's time to reconcile node's state...") if err != nil {
ok, err := ethereum.ValidateStaker() utils.Fatalf("Can't verify masternode permission: %v", err)
if err != nil { }
utils.Fatalf("Can't verify masternode permission: %v", err) if !ok {
if started {
log.Info("Only masternode can propose and verify blocks. Cancelling staking on this node...")
ethereum.StopStaking()
started = false
log.Info("Cancelled mining mode!!!")
} }
if !ok { } else if !started {
if started { log.Info("Masternode found. Enabling staking mode...")
log.Info("Only masternode can propose and verify blocks. Cancelling staking on this node...") // Use a reduced number of threads if requested
ethereum.StopStaking() if threads := ctx.GlobalInt(utils.StakerThreadsFlag.Name); threads > 0 {
started = false type threaded interface {
log.Info("Cancelled mining mode!!!") SetThreads(threads int)
} }
} else if !started { if th, ok := ethereum.Engine().(threaded); ok {
log.Info("Masternode found. Enabling staking mode...") th.SetThreads(threads)
// Use a reduced number of threads if requested
if threads := ctx.GlobalInt(utils.StakerThreadsFlag.Name); threads > 0 {
type threaded interface {
SetThreads(threads int)
}
if th, ok := ethereum.Engine().(threaded); ok {
th.SetThreads(threads)
}
} }
// Set the gas price to the limits from the CLI and start mining
ethereum.TxPool().SetGasPrice(cfg.Eth.GasPrice)
if err := ethereum.StartStaking(true); err != nil {
utils.Fatalf("Failed to start staking: %v", err)
}
started = true
log.Info("Enabled staking node!!!")
} }
// Set the gas price to the limits from the CLI and start mining
ethereum.TxPool().SetGasPrice(cfg.Eth.GasPrice)
if err := ethereum.StartStaking(true); err != nil {
utils.Fatalf("Failed to start staking: %v", err)
}
started = true
log.Info("Enabled staking node!!!")
} }
} }
}() }()