mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-04-09 20:49:08 +02:00
Merge pull request #9621 from jjjike2021/exp/maps
multi: remove x/exp/maps dependency
This commit is contained in:
commit
813f26cbc1
@ -3,13 +3,14 @@ package aliasmgr
|
||||
import (
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"maps"
|
||||
"slices"
|
||||
"sync"
|
||||
|
||||
"github.com/lightningnetwork/lnd/fn/v2"
|
||||
"github.com/lightningnetwork/lnd/htlcswitch/hop"
|
||||
"github.com/lightningnetwork/lnd/kvdb"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
"golang.org/x/exp/maps"
|
||||
)
|
||||
|
||||
// UpdateLinkAliases is a function type for a function that locates the active
|
||||
@ -515,7 +516,7 @@ func (m *Manager) RequestAlias() (lnwire.ShortChannelID, error) {
|
||||
// channel in the baseToSet map.
|
||||
haveAlias := func(maybeNextAlias lnwire.ShortChannelID) bool {
|
||||
return fn.Any(
|
||||
maps.Values(m.baseToSet),
|
||||
slices.Collect(maps.Values(m.baseToSet)),
|
||||
func(aliasList []lnwire.ShortChannelID) bool {
|
||||
return fn.Any(
|
||||
aliasList,
|
||||
|
@ -242,6 +242,8 @@ close transaction.
|
||||
* [The bitcoin `testnet4` test network is now also
|
||||
supported](https://github.com/lightningnetwork/lnd/pull/9620).
|
||||
|
||||
* [remove x/exp/maps dependency](https://github.com/lightningnetwork/lnd/pull/9621)
|
||||
|
||||
## RPC Updates
|
||||
|
||||
* Some RPCs that previously just returned an empty response message now at least
|
||||
|
@ -2,13 +2,13 @@ package fn
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"golang.org/x/exp/maps"
|
||||
"maps"
|
||||
"slices"
|
||||
)
|
||||
|
||||
// KeySet converts a map into a Set containing the keys of the map.
|
||||
func KeySet[K comparable, V any](m map[K]V) Set[K] {
|
||||
return NewSet(maps.Keys(m)...)
|
||||
return NewSet(slices.Collect(maps.Keys(m))...)
|
||||
}
|
||||
|
||||
// NewSubMapIntersect returns a sub-map of `m` containing only the keys found in
|
||||
|
@ -1,6 +1,9 @@
|
||||
package fn
|
||||
|
||||
import "golang.org/x/exp/maps"
|
||||
import (
|
||||
"maps"
|
||||
"slices"
|
||||
)
|
||||
|
||||
// Set is a generic set using type params that supports the following
|
||||
// operations: diff, union, intersection, and subset.
|
||||
@ -92,7 +95,7 @@ func (s Set[T]) Equal(other Set[T]) bool {
|
||||
|
||||
// ToSlice returns the set as a slice.
|
||||
func (s Set[T]) ToSlice() []T {
|
||||
return maps.Keys(s)
|
||||
return slices.Collect(maps.Keys(s))
|
||||
}
|
||||
|
||||
// Copy copies s and returns the result.
|
||||
|
@ -4,6 +4,8 @@ import (
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
"maps"
|
||||
"slices"
|
||||
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
@ -14,7 +16,6 @@ import (
|
||||
"github.com/lightningnetwork/lnd/fn/v2"
|
||||
"github.com/lightningnetwork/lnd/lnwallet"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
"golang.org/x/exp/maps"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -222,7 +223,7 @@ func UnmarshallCoinSelectionStrategy(strategy CoinSelectionStrategy,
|
||||
// used in various RPCs that handle scid alias mappings.
|
||||
func MarshalAliasMap(scidMap aliasmgr.ScidAliasMap) []*AliasMap {
|
||||
return fn.Map(
|
||||
maps.Keys(scidMap),
|
||||
slices.Collect(maps.Keys(scidMap)),
|
||||
func(base lnwire.ShortChannelID) *AliasMap {
|
||||
return &AliasMap{
|
||||
BaseScid: base.ToUint64(),
|
||||
|
@ -10,9 +10,11 @@ import (
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"fmt"
|
||||
"maps"
|
||||
"math"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
@ -43,7 +45,6 @@ import (
|
||||
"github.com/lightningnetwork/lnd/lnwallet/chanfunding"
|
||||
"github.com/lightningnetwork/lnd/macaroons"
|
||||
"github.com/lightningnetwork/lnd/sweep"
|
||||
"golang.org/x/exp/maps"
|
||||
"google.golang.org/grpc"
|
||||
"gopkg.in/macaroon-bakery.v2/bakery"
|
||||
)
|
||||
@ -1269,7 +1270,7 @@ func (w *WalletKit) BumpForceCloseFee(_ context.Context,
|
||||
err)
|
||||
}
|
||||
|
||||
pendingSweeps := maps.Values(inputsMap)
|
||||
pendingSweeps := slices.Collect(maps.Values(inputsMap))
|
||||
|
||||
// Discard everything except for the anchor sweeps.
|
||||
anchors := fn.Filter(
|
||||
|
@ -3,7 +3,9 @@ package sweep
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"maps"
|
||||
"math"
|
||||
"slices"
|
||||
"time"
|
||||
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
@ -15,7 +17,6 @@ import (
|
||||
"github.com/lightningnetwork/lnd/lnwallet"
|
||||
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
|
||||
"github.com/lightningnetwork/lnd/lnwallet/chanfunding"
|
||||
"golang.org/x/exp/maps"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -425,7 +426,7 @@ func fetchUtxosFromOutpoints(utxos []*lnwallet.Utxo,
|
||||
return nil, fmt.Errorf("%w: %v", ErrUnknownUTXO, err.Error())
|
||||
}
|
||||
|
||||
fetchedUtxos := maps.Values(subMap)
|
||||
fetchedUtxos := slices.Collect(maps.Values(subMap))
|
||||
|
||||
return fetchedUtxos, nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user