mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-18 10:50:44 +00:00
XFN-155: consensus V2 initial timer kick-off check (#1849)
* fix: consensus V2 initial timer kick-off check * style: use Cmp for big.Int
This commit is contained in:
parent
1089f0b4fe
commit
a3282d4119
1 changed files with 7 additions and 3 deletions
|
|
@ -200,7 +200,7 @@ func (x *XDPoS_v2) initial(chain consensus.ChainReader, header *types.Header) er
|
||||||
var quorumCert *types.QuorumCert
|
var quorumCert *types.QuorumCert
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
if header.Number.Int64() == x.config.V2.SwitchBlock.Int64() {
|
if header.Number.Cmp(x.config.V2.SwitchBlock) == 0 {
|
||||||
log.Info("[initial] highest QC for consensus v2 first block")
|
log.Info("[initial] highest QC for consensus v2 first block")
|
||||||
blockInfo := &types.BlockInfo{
|
blockInfo := &types.BlockInfo{
|
||||||
Hash: header.Hash(),
|
Hash: header.Hash(),
|
||||||
|
|
@ -273,7 +273,11 @@ func (x *XDPoS_v2) initial(chain consensus.ChainReader, header *types.Header) er
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// Kick-off the countdown timer
|
// Kick-off the countdown timer
|
||||||
x.timeoutWorker.Reset(chain, 0, 0)
|
// Only kick-off if it is V2 switch block
|
||||||
|
// Otherwise it is a lagging node, already kick-off in `processQC`
|
||||||
|
if header.Number.Cmp(x.config.V2.SwitchBlock) == 0 {
|
||||||
|
x.timeoutWorker.Reset(chain, 0, 0)
|
||||||
|
}
|
||||||
x.isInitilised = true
|
x.isInitilised = true
|
||||||
|
|
||||||
log.Warn("[initial] finish initialisation")
|
log.Warn("[initial] finish initialisation")
|
||||||
|
|
@ -989,7 +993,7 @@ func (x *XDPoS_v2) calcMasternodes(chain consensus.ChainReader, blockNum *big.In
|
||||||
}
|
}
|
||||||
candidates := snap.NextEpochCandidates
|
candidates := snap.NextEpochCandidates
|
||||||
|
|
||||||
if blockNum.Uint64() == x.config.V2.SwitchBlock.Uint64()+1 {
|
if blockNum.Cmp(new(big.Int).Add(x.config.V2.SwitchBlock, big.NewInt(1))) == 0 {
|
||||||
log.Info("[calcMasternodes] examing first v2 block")
|
log.Info("[calcMasternodes] examing first v2 block")
|
||||||
if len(candidates) > maxMasternodes {
|
if len(candidates) > maxMasternodes {
|
||||||
candidates = candidates[:maxMasternodes]
|
candidates = candidates[:maxMasternodes]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue