Skip to content

Commit

Permalink
Sort validators by pool stake and then by address
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsporn committed Mar 8, 2024
1 parent 688f982 commit 05c4b43
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -371,9 +371,14 @@ func (o *SybilProtection) OrderedRegisteredCandidateValidatorsList(epoch iotago.
}); err != nil {
return nil, ierrors.Wrapf(err, "failed to iterate over eligible validator candidates")
}
// sort candidates by stake

// sort validators by pool stake, then by address
sort.Slice(validatorResp, func(i int, j int) bool {
return validatorResp[i].ValidatorStake > validatorResp[j].ValidatorStake
if validatorResp[i].PoolStake == validatorResp[j].PoolStake {
return validatorResp[i].AddressBech32 < validatorResp[j].AddressBech32
}

return validatorResp[i].PoolStake > validatorResp[j].PoolStake
})

return validatorResp, nil
Expand Down
1 change: 1 addition & 0 deletions pkg/requesthandler/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ func (r *RequestHandler) SelectedCommittee(epoch iotago.EpochIndex) (*api.Commit
if committee[i].PoolStake == committee[j].PoolStake {
return committee[i].AddressBech32 < committee[j].AddressBech32
}

return committee[i].PoolStake > committee[j].PoolStake
})

Expand Down

0 comments on commit 05c4b43

Please sign in to comment.