From c13382e27d869d9c2bcf9040fa19c428907c2cad Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Fri, 25 Dec 2020 16:25:26 +0300 Subject: [PATCH] core: fix (*NEO).getCandidates Don't need to pay attention to key prefix while sorting. --- pkg/core/native/native_neo.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/core/native/native_neo.go b/pkg/core/native/native_neo.go index 00f654c36..66de06252 100644 --- a/pkg/core/native/native_neo.go +++ b/pkg/core/native/native_neo.go @@ -734,7 +734,7 @@ func (n *NEO) getCandidates(d dao.DAO, sortByKey bool) ([]keyWithVotes, error) { } } 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 { sort.Slice(arr, func(i, j int) bool { // 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 } // 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