chore: sort.Slice → slices.SortFunc
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
45636455ba
commit
5df40c1de1
3 changed files with 10 additions and 8 deletions
|
|
@ -7,7 +7,7 @@ package consensus
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
"slices"
|
||||
|
||||
"forge.lthn.ai/core/go-blockchain/config"
|
||||
"forge.lthn.ai/core/go-blockchain/types"
|
||||
|
|
@ -50,7 +50,7 @@ func CheckTimestamp(blockTimestamp uint64, flags uint8, adjustedTime uint64, rec
|
|||
func medianTimestamp(timestamps []uint64) uint64 {
|
||||
sorted := make([]uint64, len(timestamps))
|
||||
copy(sorted, timestamps)
|
||||
sort.Slice(sorted, func(i, j int) bool { return sorted[i] < sorted[j] })
|
||||
slices.Sort(sorted)
|
||||
|
||||
n := len(sorted)
|
||||
if n == 0 {
|
||||
|
|
|
|||
|
|
@ -11,9 +11,10 @@ package wallet
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"cmp"
|
||||
"errors"
|
||||
"fmt"
|
||||
"sort"
|
||||
"slices"
|
||||
|
||||
"forge.lthn.ai/core/go-blockchain/config"
|
||||
"forge.lthn.ai/core/go-blockchain/crypto"
|
||||
|
|
@ -158,8 +159,8 @@ func (b *V1Builder) buildInput(src *Transfer) (types.TxInputToKey, inputMeta, er
|
|||
})
|
||||
|
||||
// Sort by global index (consensus rule).
|
||||
sort.Slice(ring, func(a, b int) bool {
|
||||
return ring[a].GlobalIndex < ring[b].GlobalIndex
|
||||
slices.SortFunc(ring, func(a, b RingMember) int {
|
||||
return cmp.Compare(a.GlobalIndex, b.GlobalIndex)
|
||||
})
|
||||
|
||||
// Find real index after sorting.
|
||||
|
|
|
|||
|
|
@ -10,9 +10,10 @@
|
|||
package wallet
|
||||
|
||||
import (
|
||||
"cmp"
|
||||
"errors"
|
||||
"fmt"
|
||||
"sort"
|
||||
"slices"
|
||||
"strconv"
|
||||
|
||||
"forge.lthn.ai/core/go-blockchain/chain"
|
||||
|
|
@ -193,8 +194,8 @@ func (w *Wallet) Send(destinations []Destination, fee uint64) (*types.Transactio
|
|||
spendable = append(spendable, tr)
|
||||
}
|
||||
}
|
||||
sort.Slice(spendable, func(i, j int) bool {
|
||||
return spendable[i].Amount > spendable[j].Amount
|
||||
slices.SortFunc(spendable, func(a, b Transfer) int {
|
||||
return cmp.Compare(b.Amount, a.Amount) // descending
|
||||
})
|
||||
|
||||
var selected []Transfer
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue