-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b4b39e1
commit 6e116ef
Showing
3 changed files
with
140 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package metachain | ||
|
||
import ( | ||
"bytes" | ||
|
||
"github.com/ElrondNetwork/elrond-go/state" | ||
) | ||
|
||
type validatorList []*state.ValidatorInfo | ||
|
||
// Len will return the length of the validatorList | ||
func (v validatorList) Len() int { return len(v) } | ||
|
||
// Swap will interchange the objects on input indexes | ||
func (v validatorList) Swap(i, j int) { v[i], v[j] = v[j], v[i] } | ||
|
||
// Less will return true if object on index i should appear before object in index j | ||
// Sorting of validators should be by index and public key | ||
func (v validatorList) Less(i, j int) bool { | ||
if v[i].TempRating == v[j].TempRating { | ||
if v[i].Index == v[j].Index { | ||
return bytes.Compare(v[i].PublicKey, v[j].PublicKey) < 0 | ||
} | ||
return v[i].Index < v[j].Index | ||
} | ||
return v[i].TempRating < v[j].TempRating | ||
} |