From 852fbef24a90a19dfd9781e87335c84f7c8be34c Mon Sep 17 00:00:00 2001 From: Tuna Date: Mon, 12 Nov 2018 14:56:17 +0700 Subject: [PATCH] stop node when updateM1 fails --- core/blockchain.go | 11 ++++------- miner/worker.go | 8 ++------ 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/core/blockchain.go b/core/blockchain.go index 096517f2db..ea97affb89 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -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) { err := bc.UpdateM1() if err != nil { - if err == ErrNotPoSV { - log.Error("Stopping node", "err", err) - os.Exit(1) - } else { - log.Error("Error when update masternodes set. Keep the current masternodes set for the next epoch.", "err", err) - } + log.Error("Error when update masternodes set. Stopping node", "err", err) + os.Exit(1) } } } @@ -1632,7 +1628,8 @@ func (bc *BlockChain) UpdateM1() error { } } 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 { sort.Slice(ms, func(i, j int) bool { return ms[i].Stake >= ms[j].Stake diff --git a/miner/worker.go b/miner/worker.go index 258f857263..48bbb43de5 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -346,12 +346,8 @@ func (self *worker) wait() { if (block.NumberU64() % work.config.Posv.Epoch) == (work.config.Posv.Epoch - work.config.Posv.Gap) { err := self.chain.UpdateM1() if err != nil { - if err == core.ErrNotPoSV { - log.Error("Stopping node", "err", err) - os.Exit(1) - } else { - log.Error("Error when update masternodes set. Keep the current masternodes set for the next epoch.", "err", err) - } + log.Error("Error when update masternodes set. Stopping node", "err", err) + os.Exit(1) } } }