mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-30 07:35:07 +02:00
multi: let chan and graph db implement AddrSource
Then use both to construct a multiAddrSource AddrSource and use that around the code-base.
This commit is contained in:
@@ -414,6 +414,32 @@ func (c *ChannelGraph) NewPathFindTx() (kvdb.RTx, error) {
|
||||
return c.db.BeginReadTx()
|
||||
}
|
||||
|
||||
// AddrsForNode returns all known addresses for the target node public key that
|
||||
// the graph DB is aware of. The returned boolean indicates if the given node is
|
||||
// unknown to the graph DB or not.
|
||||
//
|
||||
// NOTE: this is part of the channeldb.AddrSource interface.
|
||||
func (c *ChannelGraph) AddrsForNode(nodePub *btcec.PublicKey) (bool, []net.Addr,
|
||||
error) {
|
||||
|
||||
pubKey, err := route.NewVertexFromBytes(nodePub.SerializeCompressed())
|
||||
if err != nil {
|
||||
return false, nil, err
|
||||
}
|
||||
|
||||
node, err := c.FetchLightningNode(pubKey)
|
||||
// We don't consider it an error if the graph is unaware of the node.
|
||||
switch {
|
||||
case err != nil && !errors.Is(err, ErrGraphNodeNotFound):
|
||||
return false, nil, err
|
||||
|
||||
case errors.Is(err, ErrGraphNodeNotFound):
|
||||
return false, nil, nil
|
||||
}
|
||||
|
||||
return true, node.Addresses, nil
|
||||
}
|
||||
|
||||
// ForEachChannel iterates through all the channel edges stored within the
|
||||
// graph and invokes the passed callback for each edge. The callback takes two
|
||||
// edges as since this is a directed graph, both the in/out edges are visited.
|
||||
|
Reference in New Issue
Block a user