Skip to content

Commit c527d22

Browse files
holimanjorgemmsilva
authored andcommitted
all: remove dependency on golang.org/exp (ethereum#29314)
This change includes a leftovers from ethereum#29307 - using the [new `slices` package](https://go.dev/doc/go1.21#slices) and - using the [new `cmp.Ordered`](https://go.dev/doc/go1.21#cmp) instead of exp `constraints.Ordered`
1 parent 06232e0 commit c527d22

File tree

42 files changed

+51
-56
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+51
-56
lines changed

accounts/keystore/account_cache.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"fmt"
2323
"os"
2424
"path/filepath"
25+
"slices"
2526
"sort"
2627
"strings"
2728
"sync"
@@ -31,7 +32,6 @@ import (
3132
"github.com/ethereum/go-ethereum/accounts"
3233
"github.com/ethereum/go-ethereum/common"
3334
"github.com/ethereum/go-ethereum/log"
34-
"golang.org/x/exp/slices"
3535
)
3636

3737
// Minimum amount of time between cache reloads. This limit applies if the platform does

accounts/keystore/account_cache_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ import (
2323
"os"
2424
"path/filepath"
2525
"reflect"
26+
"slices"
2627
"testing"
2728
"time"
2829

2930
"github.com/cespare/cp"
3031
"github.com/davecgh/go-spew/spew"
3132
"github.com/ethereum/go-ethereum/accounts"
3233
"github.com/ethereum/go-ethereum/common"
33-
"golang.org/x/exp/slices"
3434
)
3535

3636
var (

accounts/keystore/keystore_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"math/rand"
2121
"os"
2222
"runtime"
23+
"slices"
2324
"strings"
2425
"sync"
2526
"sync/atomic"
@@ -30,7 +31,6 @@ import (
3031
"github.com/ethereum/go-ethereum/common"
3132
"github.com/ethereum/go-ethereum/crypto"
3233
"github.com/ethereum/go-ethereum/event"
33-
"golang.org/x/exp/slices"
3434
)
3535

3636
var testSigData = make([]byte, 32)

build/update-license.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,12 @@ import (
4646
"path/filepath"
4747
"regexp"
4848
"runtime"
49+
"slices"
4950
"strconv"
5051
"strings"
5152
"sync"
5253
"text/template"
5354
"time"
54-
55-
"golang.org/x/exp/slices"
5655
)
5756

5857
var (

cmd/devp2p/dns_route53.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"context"
2121
"errors"
2222
"fmt"
23+
"slices"
2324
"strconv"
2425
"strings"
2526
"time"
@@ -32,7 +33,6 @@ import (
3233
"github.com/ethereum/go-ethereum/log"
3334
"github.com/ethereum/go-ethereum/p2p/dnsdisc"
3435
"github.com/urfave/cli/v2"
35-
"golang.org/x/exp/slices"
3636
)
3737

3838
const (

cmd/devp2p/internal/ethtest/chain.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"math/big"
2828
"os"
2929
"path/filepath"
30+
"slices"
3031
"sort"
3132
"strings"
3233

@@ -40,7 +41,6 @@ import (
4041
"github.com/ethereum/go-ethereum/eth/protocols/eth"
4142
"github.com/ethereum/go-ethereum/params"
4243
"github.com/ethereum/go-ethereum/rlp"
43-
"golang.org/x/exp/slices"
4444
)
4545

4646
// Chain is a lightweight blockchain-like store which can read a hivechain

cmd/devp2p/nodeset.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ import (
2121
"encoding/json"
2222
"fmt"
2323
"os"
24+
"slices"
2425
"time"
2526

2627
"github.com/ethereum/go-ethereum/common"
2728
"github.com/ethereum/go-ethereum/p2p/enode"
28-
"golang.org/x/exp/slices"
2929
)
3030

3131
const jsonIndent = " "

common/prque/lazyqueue.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
package prque
1818

1919
import (
20+
"cmp"
2021
"container/heap"
2122
"time"
2223

2324
"github.com/ethereum/go-ethereum/common/mclock"
24-
"golang.org/x/exp/constraints"
2525
)
2626

2727
// LazyQueue is a priority queue data structure where priorities can change over
@@ -33,7 +33,7 @@ import (
3333
//
3434
// If the upper estimate is exceeded then Update should be called for that item.
3535
// A global Refresh function should also be called periodically.
36-
type LazyQueue[P constraints.Ordered, V any] struct {
36+
type LazyQueue[P cmp.Ordered, V any] struct {
3737
clock mclock.Clock
3838
// Items are stored in one of two internal queues ordered by estimated max
3939
// priority until the next and the next-after-next refresh. Update and Refresh
@@ -50,12 +50,12 @@ type LazyQueue[P constraints.Ordered, V any] struct {
5050
}
5151

5252
type (
53-
PriorityCallback[P constraints.Ordered, V any] func(data V) P // actual priority callback
54-
MaxPriorityCallback[P constraints.Ordered, V any] func(data V, until mclock.AbsTime) P // estimated maximum priority callback
53+
PriorityCallback[P cmp.Ordered, V any] func(data V) P // actual priority callback
54+
MaxPriorityCallback[P cmp.Ordered, V any] func(data V, until mclock.AbsTime) P // estimated maximum priority callback
5555
)
5656

5757
// NewLazyQueue creates a new lazy queue
58-
func NewLazyQueue[P constraints.Ordered, V any](setIndex SetIndexCallback[V], priority PriorityCallback[P, V], maxPriority MaxPriorityCallback[P, V], clock mclock.Clock, refreshPeriod time.Duration) *LazyQueue[P, V] {
58+
func NewLazyQueue[P cmp.Ordered, V any](setIndex SetIndexCallback[V], priority PriorityCallback[P, V], maxPriority MaxPriorityCallback[P, V], clock mclock.Clock, refreshPeriod time.Duration) *LazyQueue[P, V] {
5959
q := &LazyQueue[P, V]{
6060
popQueue: newSstack[P, V](nil),
6161
setIndex: setIndex,

common/prque/prque.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,17 @@
1818
package prque
1919

2020
import (
21+
"cmp"
2122
"container/heap"
22-
23-
"golang.org/x/exp/constraints"
2423
)
2524

2625
// Priority queue data structure.
27-
type Prque[P constraints.Ordered, V any] struct {
26+
type Prque[P cmp.Ordered, V any] struct {
2827
cont *sstack[P, V]
2928
}
3029

3130
// New creates a new priority queue.
32-
func New[P constraints.Ordered, V any](setIndex SetIndexCallback[V]) *Prque[P, V] {
31+
func New[P cmp.Ordered, V any](setIndex SetIndexCallback[V]) *Prque[P, V] {
3332
return &Prque[P, V]{newSstack[P, V](setIndex)}
3433
}
3534

common/prque/sstack.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010

1111
package prque
1212

13-
import "golang.org/x/exp/constraints"
13+
import "cmp"
1414

1515
// The size of a block of data
1616
const blockSize = 4096
1717

1818
// A prioritized item in the sorted stack.
19-
type item[P constraints.Ordered, V any] struct {
19+
type item[P cmp.Ordered, V any] struct {
2020
value V
2121
priority P
2222
}
@@ -29,7 +29,7 @@ type SetIndexCallback[V any] func(data V, index int)
2929
// Internal sortable stack data structure. Implements the Push and Pop ops for
3030
// the stack (heap) functionality and the Len, Less and Swap methods for the
3131
// sortability requirements of the heaps.
32-
type sstack[P constraints.Ordered, V any] struct {
32+
type sstack[P cmp.Ordered, V any] struct {
3333
setIndex SetIndexCallback[V]
3434
size int
3535
capacity int
@@ -40,7 +40,7 @@ type sstack[P constraints.Ordered, V any] struct {
4040
}
4141

4242
// Creates a new, empty stack.
43-
func newSstack[P constraints.Ordered, V any](setIndex SetIndexCallback[V]) *sstack[P, V] {
43+
func newSstack[P cmp.Ordered, V any](setIndex SetIndexCallback[V]) *sstack[P, V] {
4444
result := new(sstack[P, V])
4545
result.setIndex = setIndex
4646
result.active = make([]*item[P, V], blockSize)

0 commit comments

Comments
 (0)