channeldb: define a single AddrSource interface
Our aim is to completely remove the `channeldb.DB`'s direct dependence on the `graphdb.ChannelGraph` pointer. The only place where it still depends on this pointer is in the `(DB).AddrsForNode(..)` method where it queries both the channel DB and the graph db for the known addresses for the node in question and then combines the results. So, to separate these out, we will define an AddrsForNodes interface in this commit which we will later let both the ChannelGraph and channeldb.DB both implement and we will merge these results outside of the channeldb package. All this commit does is to unify the `AddrSource` interface since this has been defined separately in a couple of places.
This commit is contained in:
4 files changed
+20
-26
No files matched your search
+1
-12
@@ -2,24 +2,13 @@ package lnd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/lightningnetwork/lnd/chanbackup"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/channelnotifier"
|
||||
)
|
||||
|
||||
// addrSource is an interface that allow us to get the addresses for a target
|
||||
// node. We'll need this in order to be able to properly proxy the
|
||||
// notifications to create SCBs.
|
||||
type addrSource interface {
|
||||
// AddrsForNode returns all known addresses for the target node public
|
||||
// key.
|
||||
AddrsForNode(nodePub *btcec.PublicKey) ([]net.Addr, error)
|
||||
}
|
||||
|
||||
// channelNotifier is an implementation of the chanbackup.ChannelNotifier
|
||||
// interface using the existing channelnotifier.ChannelNotifier struct. This
|
||||
// implementation allows us to satisfy all the dependencies of the
|
||||
@@ -32,7 +21,7 @@ type channelNotifier struct {
|
||||
// addrs is an implementation of the addrSource interface that allows
|
||||
// us to get the latest set of addresses for a given node. We'll need
|
||||
// this to be able to create an SCB for new channels.
|
||||
addrs addrSource
|
||||
addrs channeldb.AddrSource
|
||||
}
|
||||
|
||||
// SubscribeChans requests a new channel subscription relative to the initial
|
||||
|
||||
Reference in new issue
Block a user