consensus: fix delete the 1st validator from snapshot.recents list (#1344)

* consensus: fix delete the 1st validator from snapshot.recents list

* consensus:fix uint sub error with negative
This commit is contained in:
Leon 2023-03-13 11:10:16 +08:00 committed by GitHub
parent c11431e4ea
commit c1fde0e86c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1326,7 +1326,14 @@ func (p *Parlia) backOffTime(snap *Snapshot, header *types.Header, val common.Ad
if p.chainConfig.IsPlanck(header.Number) {
// reverse the key/value of snap.Recents to get recentsMap
recentsMap := make(map[common.Address]uint64, len(snap.Recents))
bound := uint64(0)
if n, limit := header.Number.Uint64(), uint64(len(validators)/2+1); n > limit {
bound = n - limit
}
for seen, recent := range snap.Recents {
if seen <= bound {
continue
}
recentsMap[recent] = seen
}