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:
Elle Mouton
2024-10-22 14:02:43 +02:00
parent 1859993734
commit 083d3c9d7c
4 changed files with 20 additions and 26 deletions

15
channeldb/addr_source.go Normal file
View File

@@ -0,0 +1,15 @@
package channeldb
import (
"net"
"github.com/btcsuite/btcd/btcec/v2"
)
// AddrSource is an interface that allow us to get the addresses for a target
// node. It may combine the results of multiple address sources.
type AddrSource interface {
// AddrsForNode returns all known addresses for the target node public
// key.
AddrsForNode(nodePub *btcec.PublicKey) ([]net.Addr, error)
}