Skip to content

Commit

Permalink
fix null pointer error after taking #69
Browse files Browse the repository at this point in the history
  • Loading branch information
tak1827 committed Sep 24, 2024
1 parent ca83aec commit 23ed73f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion consensus/oasys/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,16 @@ func (s *Snapshot) ToNextValidators() *nextValidators {
operators := make([]common.Address, len(s.Validators))
stakes := make([]*big.Int, len(s.Validators))
voteAddresses := make([]types.BLSPublicKey, len(s.Validators))
var counter int
for address, info := range s.Validators {
// No worry, voterIndex is assured when creating snapshot
// Basically, voterIndex is assured when creating snapshot
i := info.Index - 1
if info.Index == 0 {
// The is one scenario that the index is 0, which is the first run after the upgrade(v1.6.0).
// In this case, As the snapshot is loaded from disk, the format is old one.
i = counter
counter++
}
operators[i] = address
stakes[i] = new(big.Int).Set(info.Stake)
copy(voteAddresses[i][:], info.VoteAddress[:])
Expand Down

0 comments on commit 23ed73f

Please sign in to comment.