From 89b0e25e2c6084025c3c6e88237a54aa8766fd9c Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Thu, 19 Jan 2023 06:31:17 +0800 Subject: [PATCH] multi: add `lnutils` to host fundamental utility functions We also move the `fn/stream.go` into the package `lnutils`. Eventually we will put all the [utility functions](https://github.com/lightninglabs/taro/tree/main/chanutils) into this package. --- discovery/gossiper.go | 4 ++-- lnutils/README.md | 4 ++++ {fn => lnutils}/stream.go | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 lnutils/README.md rename {fn => lnutils}/stream.go (93%) diff --git a/discovery/gossiper.go b/discovery/gossiper.go index 9bb6959e5..eb13d77ea 100644 --- a/discovery/gossiper.go +++ b/discovery/gossiper.go @@ -18,10 +18,10 @@ import ( "github.com/lightningnetwork/lnd/batch" "github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/channeldb" - "github.com/lightningnetwork/lnd/fn" "github.com/lightningnetwork/lnd/keychain" "github.com/lightningnetwork/lnd/kvdb" "github.com/lightningnetwork/lnd/lnpeer" + "github.com/lightningnetwork/lnd/lnutils" "github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/multimutex" @@ -1185,7 +1185,7 @@ func (d *AuthenticatedGossiper) sendBatch(annBatch []msgWithSenders, // skip the filter and dedup logic below, and just send the // announcements out to all our coonnected peers. if isLocal { - msgsToSend := fn.Map( + msgsToSend := lnutils.Map( annBatch, func(m msgWithSenders) lnwire.Message { return m.msg }, diff --git a/lnutils/README.md b/lnutils/README.md new file mode 100644 index 000000000..fe2fafa7c --- /dev/null +++ b/lnutils/README.md @@ -0,0 +1,4 @@ +# `lnutils` + +This package provides fundamental types and utility functions that can be used +by all other packages. diff --git a/fn/stream.go b/lnutils/stream.go similarity index 93% rename from fn/stream.go rename to lnutils/stream.go index 9974eb467..ed04fa2ee 100644 --- a/fn/stream.go +++ b/lnutils/stream.go @@ -1,4 +1,4 @@ -package fn +package lnutils // Map takes an input slice, and applies the function f to each element, // yielding a new slice.