Merge pull request #1639 from nspcc-dev/preview4-fixes-2

core: fix (*NEO).getCandidates
This commit is contained in:
Roman Khimov 2020-12-25 17:18:48 +03:00 committed by GitHub
commit c1409844f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -734,7 +734,7 @@ func (n *NEO) getCandidates(d dao.DAO, sortByKey bool) ([]keyWithVotes, error) {
} }
} }
if sortByKey { if sortByKey {
sort.Slice(arr, func(i, j int) bool { return strings.Compare(arr[i].Key, arr[j].Key) == -1 }) sort.Slice(arr, func(i, j int) bool { return strings.Compare(arr[i].Key[1:], arr[j].Key[1:]) == -1 })
} else { } else {
sort.Slice(arr, func(i, j int) bool { sort.Slice(arr, func(i, j int) bool {
// The most-voted validators should end up in the front of the list. // The most-voted validators should end up in the front of the list.
@ -743,7 +743,7 @@ func (n *NEO) getCandidates(d dao.DAO, sortByKey bool) ([]keyWithVotes, error) {
return cmp > 0 return cmp > 0
} }
// Ties are broken with public keys. // Ties are broken with public keys.
return strings.Compare(arr[i].Key, arr[j].Key) == -1 return strings.Compare(arr[i].Key[1:], arr[j].Key[1:]) == -1
}) })
} }
return arr, nil return arr, nil