mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-12-09 04:13:00 +01:00
channeldb: let AddrsForNode indicate if the node was found or not
Before this commit, the `(channeldb.DB).AddrsForNode` method treats the results from the channel db and the graph db slightly differently. It errors out if the channel db is unaware of the node in question but does not error out if the graph is unaware of the node. So this commit changes the logic slightly so that a "node-unknown" error from either backing source is not seen as an error.
This commit is contained in:
@@ -62,20 +62,19 @@ func (m *mockChannelSource) addAddrsForNode(nodePub *btcec.PublicKey, addrs []ne
|
||||
m.addrs[nodeKey] = addrs
|
||||
}
|
||||
|
||||
func (m *mockChannelSource) AddrsForNode(nodePub *btcec.PublicKey) ([]net.Addr, error) {
|
||||
func (m *mockChannelSource) AddrsForNode(nodePub *btcec.PublicKey) (bool,
|
||||
[]net.Addr, error) {
|
||||
|
||||
if m.failQuery {
|
||||
return nil, fmt.Errorf("fail")
|
||||
return false, nil, fmt.Errorf("fail")
|
||||
}
|
||||
|
||||
var nodeKey [33]byte
|
||||
copy(nodeKey[:], nodePub.SerializeCompressed())
|
||||
|
||||
addrs, ok := m.addrs[nodeKey]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("can't find addr")
|
||||
}
|
||||
|
||||
return addrs, nil
|
||||
return ok, addrs, nil
|
||||
}
|
||||
|
||||
// TestFetchBackupForChan tests that we're able to construct a single channel
|
||||
|
||||
Reference in New Issue
Block a user