X-Git-Url: http://git.osdn.net/view?p=bytom%2Fvapor.git;a=blobdiff_plain;f=protocol%2Fstate%2Fconsensus_result.go;h=9313c4bcc37b61871745535b92505cb2210bec6b;hp=ff08429cdc3edb900c955e76e4c63dafdc1a9de9;hb=eec8f562a3dbf016e7d280c1deb532c214eb6e33;hpb=489e57ce3c46eb9e8ca25c7e966a1ea26fe41d57 diff --git a/protocol/state/consensus_result.go b/protocol/state/consensus_result.go index ff08429c..9313c4bc 100644 --- a/protocol/state/consensus_result.go +++ b/protocol/state/consensus_result.go @@ -38,9 +38,11 @@ type CoinbaseReward struct { // SortByAmount implements sort.Interface for CoinbaseReward slices type SortByAmount []CoinbaseReward -func (a SortByAmount) Len() int { return len(a) } -func (a SortByAmount) Swap(i, j int) { a[i], a[j] = a[j], a[i] } -func (a SortByAmount) Less(i, j int) bool { return a[i].Amount < a[j].Amount } +func (a SortByAmount) Len() int { return len(a) } +func (a SortByAmount) Swap(i, j int) { a[i], a[j] = a[j], a[i] } +func (a SortByAmount) Less(i, j int) bool { + return a[i].Amount > a[j].Amount || (a[i].Amount == a[j].Amount && hex.EncodeToString(a[i].ControlProgram) > hex.EncodeToString(a[j].ControlProgram)) +} // CalCoinbaseReward calculate the coinbase reward for block func CalCoinbaseReward(block *types.Block) (*CoinbaseReward, error) {