multi: update to fn v2

This commit is contained in:
Keagan McClelland
2024-12-03 15:51:05 -07:00
parent 48fba10562
commit ed2989ae33
167 changed files with 372 additions and 302 deletions

View File

@@ -5,7 +5,7 @@ import (
"io"
"github.com/btcsuite/btcd/btcec/v2"
"github.com/lightningnetwork/lnd/fn"
"github.com/lightningnetwork/lnd/fn/v2"
"github.com/lightningnetwork/lnd/tlv"
)

View File

@@ -6,7 +6,7 @@ import (
"io"
"sort"
"github.com/lightningnetwork/lnd/fn"
"github.com/lightningnetwork/lnd/fn/v2"
"github.com/lightningnetwork/lnd/tlv"
)
@@ -179,9 +179,12 @@ func (c CustomRecords) SerializeTo(w io.Writer) error {
// ProduceRecordsSorted converts a slice of record producers into a slice of
// records and then sorts it by type.
func ProduceRecordsSorted(recordProducers ...tlv.RecordProducer) []tlv.Record {
records := fn.Map(func(producer tlv.RecordProducer) tlv.Record {
return producer.Record()
}, recordProducers)
records := fn.Map(
recordProducers,
func(producer tlv.RecordProducer) tlv.Record {
return producer.Record()
},
)
// Ensure that the set of records are sorted before we attempt to
// decode from the stream, to ensure they're canonical.
@@ -212,9 +215,9 @@ func TlvMapToRecords(tlvMap tlv.TypeMap) []tlv.Record {
// RecordsAsProducers converts a slice of records into a slice of record
// producers.
func RecordsAsProducers(records []tlv.Record) []tlv.RecordProducer {
return fn.Map(func(record tlv.Record) tlv.RecordProducer {
return fn.Map(records, func(record tlv.Record) tlv.RecordProducer {
return &record
}, records)
})
}
// EncodeRecords encodes the given records into a byte slice.

View File

@@ -4,7 +4,7 @@ import (
"bytes"
"testing"
"github.com/lightningnetwork/lnd/fn"
"github.com/lightningnetwork/lnd/fn/v2"
"github.com/lightningnetwork/lnd/tlv"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@@ -182,9 +182,12 @@ func TestCustomRecordsExtendRecordProducers(t *testing.T) {
func serializeRecordProducers(t *testing.T,
producers []tlv.RecordProducer) []byte {
tlvRecords := fn.Map(func(p tlv.RecordProducer) tlv.Record {
return p.Record()
}, producers)
tlvRecords := fn.Map(
producers,
func(p tlv.RecordProducer) tlv.Record {
return p.Record()
},
)
stream, err := tlv.NewStream(tlvRecords...)
require.NoError(t, err)

View File

@@ -5,7 +5,7 @@ import (
"io"
"github.com/btcsuite/btcd/btcec/v2/schnorr/musig2"
"github.com/lightningnetwork/lnd/fn"
"github.com/lightningnetwork/lnd/fn/v2"
"github.com/lightningnetwork/lnd/tlv"
)

View File

@@ -6,7 +6,7 @@ import (
"github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcutil"
"github.com/lightningnetwork/lnd/fn"
"github.com/lightningnetwork/lnd/fn/v2"
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
"github.com/lightningnetwork/lnd/tlv"
)

View File

@@ -5,7 +5,7 @@ import (
"fmt"
"io"
"github.com/lightningnetwork/lnd/fn"
"github.com/lightningnetwork/lnd/fn/v2"
"github.com/lightningnetwork/lnd/tlv"
)

View File

@@ -22,7 +22,7 @@ import (
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/fn"
"github.com/lightningnetwork/lnd/fn/v2"
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
"github.com/lightningnetwork/lnd/tlv"
"github.com/lightningnetwork/lnd/tor"

View File

@@ -10,7 +10,7 @@ import (
"github.com/davecgh/go-spew/spew"
"github.com/go-errors/errors"
"github.com/lightningnetwork/lnd/fn"
"github.com/lightningnetwork/lnd/fn/v2"
"github.com/lightningnetwork/lnd/tlv"
)

View File

@@ -9,7 +9,7 @@ import (
"testing"
"github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/fn"
"github.com/lightningnetwork/lnd/fn/v2"
"github.com/stretchr/testify/require"
)