mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-19 21:31:37 +00:00
fix error deadlocked master node
This commit is contained in:
parent
2e505d6e99
commit
5ebc19f70a
1 changed files with 18 additions and 19 deletions
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
// Copyright 2015 The go-ethereum Authors
|
||||
// This file is part of the go-ethereum library.
|
||||
//
|
||||
|
|
@ -338,6 +337,24 @@ func (self *worker) wait() {
|
|||
if stat == core.CanonStatTy {
|
||||
events = append(events, core.ChainHeadEvent{Block: block})
|
||||
}
|
||||
if work.config.XDPoS != nil {
|
||||
// epoch block
|
||||
if (block.NumberU64() % work.config.XDPoS.Epoch) == 0 {
|
||||
core.CheckpointCh <- 1
|
||||
}
|
||||
// prepare set of masternodes for the next epoch
|
||||
if (block.NumberU64() % work.config.XDPoS.Epoch) == (work.config.XDPoS.Epoch - work.config.XDPoS.Gap) {
|
||||
err := self.chain.UpdateM1()
|
||||
if err != nil {
|
||||
if err == core.ErrNotXDPoS {
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
self.chain.PostChainEvents(events, logs)
|
||||
|
||||
// Insert the block into the set of pending ones to wait for confirmations
|
||||
|
|
@ -591,24 +608,6 @@ func (self *worker) commitNewWork() {
|
|||
log.Info("Commit new mining work", "number", work.Block.Number(), "txs", work.tcount, "special txs", len(specialTxs), "uncles", len(uncles), "elapsed", common.PrettyDuration(time.Since(tstart)))
|
||||
self.unconfirmed.Shift(work.Block.NumberU64() - 1)
|
||||
}
|
||||
if work.config.XDPoS != nil {
|
||||
// epoch block
|
||||
if (work.Block.NumberU64() % work.config.XDPoS.Epoch) == 0 {
|
||||
core.CheckpointCh <- 1
|
||||
}
|
||||
// prepare set of masternodes for the next epoch
|
||||
if (work.Block.NumberU64() % work.config.XDPoS.Epoch) == (work.config.XDPoS.Epoch - work.config.XDPoS.Gap) {
|
||||
err := self.chain.UpdateM1()
|
||||
if err != nil {
|
||||
if err == core.ErrNotXDPoS {
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
self.push(work)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue