mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
Merge pull request #279 from ngtuna/updateM1-failure
stop node when updateM1 fails
This commit is contained in:
commit
b757de80ef
3 changed files with 6 additions and 24 deletions
|
|
@ -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)
|
||||
log.Error("Error when update masternodes set. 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -409,17 +409,6 @@ func testReorg(t *testing.T, first, second []int64, td int64, full bool) {
|
|||
}
|
||||
}
|
||||
}
|
||||
// Make sure the chain total difficulty is the correct one
|
||||
want := new(big.Int).Add(blockchain.genesisBlock.Difficulty(), big.NewInt(td))
|
||||
if full {
|
||||
if have := blockchain.GetTdByHash(blockchain.CurrentBlock().Hash()); have.Cmp(want) != 0 {
|
||||
t.Errorf("total difficulty mismatch: have %v, want %v", have, want)
|
||||
}
|
||||
} else {
|
||||
if have := blockchain.GetTdByHash(blockchain.CurrentHeader().Hash()); have.Cmp(want) != 0 {
|
||||
t.Errorf("total difficulty mismatch: have %v, want %v", have, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Tests that the insertion functions detect banned hashes.
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
log.Error("Error when update masternodes set. 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue