core/forkchoice: improve stability when inturn block not generated (#2451)

This commit is contained in:
Nathan 2024-06-18 15:53:05 +08:00 committed by GitHub
parent 7b08a70a23
commit 00f094c37e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -114,7 +114,9 @@ func (f *ForkChoice) ReorgNeeded(current *types.Header, extern *types.Header) (b
if f.preserve != nil { if f.preserve != nil {
currentPreserve, externPreserve = f.preserve(current), f.preserve(extern) currentPreserve, externPreserve = f.preserve(current), f.preserve(extern)
} }
reorg = !currentPreserve && (externPreserve || f.rand.Float64() < 0.5) reorg = !currentPreserve && (externPreserve ||
extern.Time < current.Time ||
extern.Time == current.Time && f.rand.Float64() < 0.5)
} }
return reorg, nil return reorg, nil
} }