Skip to content

Commit e72caf7

Browse files
committed
multi: remove x/exp/maps dependency
1 parent 67d2eac commit e72caf7

File tree

7 files changed

+22
-13
lines changed

7 files changed

+22
-13
lines changed

aliasmgr/aliasmgr.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ package aliasmgr
33
import (
44
"encoding/binary"
55
"fmt"
6+
"maps"
7+
"slices"
68
"sync"
79

810
"github.com/lightningnetwork/lnd/fn/v2"
911
"github.com/lightningnetwork/lnd/htlcswitch/hop"
1012
"github.com/lightningnetwork/lnd/kvdb"
1113
"github.com/lightningnetwork/lnd/lnwire"
12-
"golang.org/x/exp/maps"
1314
)
1415

1516
// UpdateLinkAliases is a function type for a function that locates the active
@@ -515,7 +516,7 @@ func (m *Manager) RequestAlias() (lnwire.ShortChannelID, error) {
515516
// channel in the baseToSet map.
516517
haveAlias := func(maybeNextAlias lnwire.ShortChannelID) bool {
517518
return fn.Any(
518-
maps.Values(m.baseToSet),
519+
slices.Collect(maps.Values(m.baseToSet)),
519520
func(aliasList []lnwire.ShortChannelID) bool {
520521
return fn.Any(
521522
aliasList,

docs/release-notes/release-notes-0.19.0.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,8 @@ close transaction.
237237
* [The bitcoin `testnet4` test network is now also
238238
supported](https://github.com/lightningnetwork/lnd/pull/9620).
239239

240+
* [remove x/exp/maps dependency](https://github.com/lightningnetwork/lnd/pull/9621)
241+
240242
## RPC Updates
241243

242244
* Some RPCs that previously just returned an empty response message now at least

fn/map.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ package fn
22

33
import (
44
"fmt"
5-
6-
"golang.org/x/exp/maps"
5+
"maps"
6+
"slices"
77
)
88

99
// KeySet converts a map into a Set containing the keys of the map.
1010
func KeySet[K comparable, V any](m map[K]V) Set[K] {
11-
return NewSet(maps.Keys(m)...)
11+
return NewSet(slices.Collect(maps.Keys(m))...)
1212
}
1313

1414
// NewSubMapIntersect returns a sub-map of `m` containing only the keys found in

fn/set.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package fn
22

3-
import "golang.org/x/exp/maps"
3+
import (
4+
"maps"
5+
"slices"
6+
)
47

58
// Set is a generic set using type params that supports the following
69
// operations: diff, union, intersection, and subset.
@@ -92,7 +95,7 @@ func (s Set[T]) Equal(other Set[T]) bool {
9295

9396
// ToSlice returns the set as a slice.
9497
func (s Set[T]) ToSlice() []T {
95-
return maps.Keys(s)
98+
return slices.Collect(maps.Keys(s))
9699
}
97100

98101
// Copy copies s and returns the result.

lnrpc/marshall_utils.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"encoding/hex"
55
"errors"
66
"fmt"
7+
"maps"
8+
"slices"
79

810
"github.com/btcsuite/btcd/btcutil"
911
"github.com/btcsuite/btcd/chaincfg"
@@ -14,7 +16,6 @@ import (
1416
"github.com/lightningnetwork/lnd/fn/v2"
1517
"github.com/lightningnetwork/lnd/lnwallet"
1618
"github.com/lightningnetwork/lnd/lnwire"
17-
"golang.org/x/exp/maps"
1819
)
1920

2021
var (
@@ -222,7 +223,7 @@ func UnmarshallCoinSelectionStrategy(strategy CoinSelectionStrategy,
222223
// used in various RPCs that handle scid alias mappings.
223224
func MarshalAliasMap(scidMap aliasmgr.ScidAliasMap) []*AliasMap {
224225
return fn.Map(
225-
maps.Keys(scidMap),
226+
slices.Collect(maps.Keys(scidMap)),
226227
func(base lnwire.ShortChannelID) *AliasMap {
227228
return &AliasMap{
228229
BaseScid: base.ToUint64(),

lnrpc/walletrpc/walletkit_server.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ import (
1010
"encoding/binary"
1111
"errors"
1212
"fmt"
13+
"maps"
1314
"math"
1415
"os"
1516
"path/filepath"
17+
"slices"
1618
"sort"
1719
"time"
1820

@@ -43,7 +45,6 @@ import (
4345
"github.com/lightningnetwork/lnd/lnwallet/chanfunding"
4446
"github.com/lightningnetwork/lnd/macaroons"
4547
"github.com/lightningnetwork/lnd/sweep"
46-
"golang.org/x/exp/maps"
4748
"google.golang.org/grpc"
4849
"gopkg.in/macaroon-bakery.v2/bakery"
4950
)
@@ -1269,7 +1270,7 @@ func (w *WalletKit) BumpForceCloseFee(_ context.Context,
12691270
err)
12701271
}
12711272

1272-
pendingSweeps := maps.Values(inputsMap)
1273+
pendingSweeps := slices.Collect(maps.Values(inputsMap))
12731274

12741275
// Discard everything except for the anchor sweeps.
12751276
anchors := fn.Filter(

sweep/walletsweep.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ package sweep
33
import (
44
"errors"
55
"fmt"
6+
"maps"
67
"math"
8+
"slices"
79
"time"
810

911
"github.com/btcsuite/btcd/btcutil"
@@ -15,7 +17,6 @@ import (
1517
"github.com/lightningnetwork/lnd/lnwallet"
1618
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
1719
"github.com/lightningnetwork/lnd/lnwallet/chanfunding"
18-
"golang.org/x/exp/maps"
1920
)
2021

2122
var (
@@ -425,7 +426,7 @@ func fetchUtxosFromOutpoints(utxos []*lnwallet.Utxo,
425426
return nil, fmt.Errorf("%w: %v", ErrUnknownUTXO, err.Error())
426427
}
427428

428-
fetchedUtxos := maps.Values(subMap)
429+
fetchedUtxos := slices.Collect(maps.Values(subMap))
429430

430431
return fetchedUtxos, nil
431432
}

0 commit comments

Comments
 (0)