Skip to content

Commit

Permalink
fix golint
Browse files Browse the repository at this point in the history
  • Loading branch information
ngtuna committed Sep 27, 2018
1 parent 30ae355 commit 205878c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 31 deletions.
2 changes: 1 addition & 1 deletion cmd/tomo/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, tomoConfig) {
ctx.Set(utils.NATFlag.Name, cfg.NAT)
}

// read passwords from enviroment
// read passwords from environment
passwords := []string{}
for _, env := range cfg.Account.Passwords {
if trimmed := strings.TrimSpace(env); trimmed != "" {
Expand Down
57 changes: 27 additions & 30 deletions cmd/tomo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,40 +321,37 @@ func startNode(ctx *cli.Context, stack *node.Node, cfg tomoConfig) {
log.Info("Enabled staking node!!!")
}
defer close(core.CheckpointCh)
for {
select {
case <-core.CheckpointCh:
log.Info("Checkpoint!!! It's time to reconcile node's state...")
ok, err := ethereum.ValidateStaker()
if err != nil {
utils.Fatalf("Can't verify masternode permission: %v", err)
for range core.CheckpointCh {
log.Info("Checkpoint!!! It's time to reconcile node's state...")
ok, err := ethereum.ValidateStaker()
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 {
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!!!")
}
} else if !started {
log.Info("Masternode found. Enabling staking mode...")
// 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)
}
} else if !started {
log.Info("Masternode found. Enabling staking mode...")
// Use a reduced number of threads if requested
if threads := ctx.GlobalInt(utils.StakerThreadsFlag.Name); threads > 0 {
type threaded interface {
SetThreads(threads int)
}
// 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)
if th, ok := ethereum.Engine().(threaded); ok {
th.SetThreads(threads)
}
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!!!")
}
}
}()
Expand Down

0 comments on commit 205878c

Please sign in to comment.