Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions consensus/internal/bft/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import (
"encoding/base64"
"fmt"
"math"
"sort"
"slices"
"strconv"
"sync"
"sync/atomic"

protos "github.com/hyperledger/binibft-poc/consensus/binibftprotos"
"github.com/hyperledger/binibft-poc/consensus/pkg/api"
"github.com/hyperledger/binibft-poc/consensus/pkg/types"
protos "github.com/hyperledger/binibft-poc/consensus/binibftprotos"

"github.com/golang/protobuf/proto"
)
Expand Down Expand Up @@ -185,7 +185,7 @@ func ComputeHierarchy(N, v int) (primary int, secondaries []int, followersOf map
followersSet = append(followersSet, n)
}
}
sort.Ints(followersSet)
slices.Sort(followersSet)
F := len(followersSet)
q := F / S
r := F % S
Expand Down
6 changes: 3 additions & 3 deletions consensus/pkg/api/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package api

import (
"fmt"
"sort"
"slices"
"strconv"

"github.com/hyperledger/binibft-poc/consensus/pkg/metrics"
Expand Down Expand Up @@ -51,7 +51,7 @@ func NewHistogramOpts(old metrics.HistogramOpts, labelNames []string) metrics.Hi
}

func makeStatsdFormat(labelNames []string, str string) string {
sort.Strings(labelNames)
slices.Sort(labelNames)
for _, s := range labelNames {
str += fmt.Sprintf(".%%{%s}", s)
}
Expand All @@ -62,7 +62,7 @@ func makeStatsdFormat(labelNames []string, str string) string {
func makeLabelNames(labelNames []string, names ...string) []string {
ln := make([]string, 0, len(names)+len(labelNames))
ln = append(ln, names...)
sort.Strings(labelNames)
slices.Sort(labelNames)
ln = append(ln, labelNames...)
return ln
}
Expand Down
8 changes: 3 additions & 5 deletions consensus/pkg/consensus/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
package consensus

import (
"sort"
"slices"
"strings"
"sync"
"sync/atomic"
"time"

protos "github.com/hyperledger/binibft-poc/consensus/binibftprotos"
algorithm "github.com/hyperledger/binibft-poc/consensus/internal/bft"
bft "github.com/hyperledger/binibft-poc/consensus/pkg/api"
"github.com/hyperledger/binibft-poc/consensus/pkg/metrics/disabled"
"github.com/hyperledger/binibft-poc/consensus/pkg/types"
protos "github.com/hyperledger/binibft-poc/consensus/binibftprotos"

"github.com/golang/protobuf/proto"
"github.com/pkg/errors"
Expand Down Expand Up @@ -377,9 +377,7 @@ func (c *Consensus) setNodes(nodes []uint64) {
func sortNodes(nodes []uint64) []uint64 {
sorted := make([]uint64, len(nodes))
copy(sorted, nodes)
sort.Slice(sorted, func(i, j int) bool {
return sorted[i] < sorted[j]
})
slices.Sort(sorted)
return sorted
}

Expand Down
15 changes: 5 additions & 10 deletions consensus/pkg/wal/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"io"
"os"
"path/filepath"
"sort"
"slices"
"strings"

"github.com/hyperledger/binibft-poc/consensus/pkg/api"
Expand Down Expand Up @@ -78,15 +78,15 @@ func dirReadWalNames(dirPath string) ([]string, error) {
}
}

sort.Strings(walNames)
slices.Sort(walNames)

return walNames, nil
}

// checkWalFiles for continuous sequence, readable CRC-Anchor.
// If the last file cannot be read, it may be ignored, (or repaired).
func checkWalFiles(logger api.Logger, dirName string, walNames []string) ([]uint64, error) {
sort.Strings(walNames)
slices.Sort(walNames)

indexes := make([]uint64, 0)

Expand Down Expand Up @@ -131,13 +131,8 @@ func checkWalFiles(logger api.Logger, dirName string, walNames []string) ([]uint
return nil, errors.New("wal: files not in sequence")
}
}

sort.Slice(indexes,
func(i, j int) bool {
return indexes[i] < indexes[j]
},
)


slices.Sort(indexes)
return indexes, nil
}

Expand Down