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