stop node when updateM1 fails

This commit is contained in:
Tuna 2018-11-12 14:56:17 +07:00
parent c0584b6612
commit 852fbef24a
2 changed files with 6 additions and 13 deletions

View file

@ -1198,12 +1198,8 @@ func (bc *BlockChain) insertChain(chain types.Blocks) (int, []interface{}, []*ty
if (chain[i].NumberU64() % bc.chainConfig.Posv.Epoch) == (bc.chainConfig.Posv.Epoch - bc.chainConfig.Posv.Gap) { if (chain[i].NumberU64() % bc.chainConfig.Posv.Epoch) == (bc.chainConfig.Posv.Epoch - bc.chainConfig.Posv.Gap) {
err := bc.UpdateM1() err := bc.UpdateM1()
if err != nil { if err != nil {
if err == ErrNotPoSV { log.Error("Error when update masternodes set. Stopping node", "err", err)
log.Error("Stopping node", "err", err) os.Exit(1)
os.Exit(1)
} else {
log.Error("Error when update masternodes set. Keep the current masternodes set for the next epoch.", "err", err)
}
} }
} }
} }
@ -1632,7 +1628,8 @@ func (bc *BlockChain) UpdateM1() error {
} }
} }
if len(ms) == 0 { if len(ms) == 0 {
log.Info("No masternode candidates found. Keep the current masternodes set for the next epoch") log.Error("No masternode found. Stopping node")
os.Exit(1)
} else { } else {
sort.Slice(ms, func(i, j int) bool { sort.Slice(ms, func(i, j int) bool {
return ms[i].Stake >= ms[j].Stake return ms[i].Stake >= ms[j].Stake

View file

@ -346,12 +346,8 @@ func (self *worker) wait() {
if (block.NumberU64() % work.config.Posv.Epoch) == (work.config.Posv.Epoch - work.config.Posv.Gap) { if (block.NumberU64() % work.config.Posv.Epoch) == (work.config.Posv.Epoch - work.config.Posv.Gap) {
err := self.chain.UpdateM1() err := self.chain.UpdateM1()
if err != nil { if err != nil {
if err == core.ErrNotPoSV { log.Error("Error when update masternodes set. Stopping node", "err", err)
log.Error("Stopping node", "err", err) os.Exit(1)
os.Exit(1)
} else {
log.Error("Error when update masternodes set. Keep the current masternodes set for the next epoch.", "err", err)
}
} }
} }
} }