Skip to content

Commit 12668fe

Browse files
committed
eth/hooks: use slices.SortStableFunc in engine_v2
1 parent b49f6cb commit 12668fe

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

eth/hooks/engine_v2_hooks.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ package hooks
33
import (
44
"errors"
55
"math/big"
6+
"slices"
67
"time"
78

89
"github.com/XinFinOrg/XDPoSChain/common"
9-
"github.com/XinFinOrg/XDPoSChain/common/sort"
1010
"github.com/XinFinOrg/XDPoSChain/consensus"
1111
"github.com/XinFinOrg/XDPoSChain/consensus/XDPoS"
1212
"github.com/XinFinOrg/XDPoSChain/consensus/XDPoS/utils"
@@ -428,8 +428,8 @@ func GetSigningTxCount(c *XDPoS.XDPoS, chain consensus.ChainReader, header *type
428428
ms = append(ms, utils.Masternode{Address: candidate, Stake: v})
429429
}
430430
}
431-
sort.Slice(ms, func(i, j int) bool {
432-
return ms[i].Stake.Cmp(ms[j].Stake) >= 0
431+
slices.SortStableFunc(ms, func(a, b utils.Masternode) int {
432+
return b.Stake.Cmp(a.Stake)
433433
})
434434
// find penalty and filter them out
435435
penalties := common.ExtractAddressFromBytes(h.Penalties)

0 commit comments

Comments
 (0)