mirror of
https://github.com/aljazceru/breez-lnd.git
synced 2025-12-18 22:54:26 +01:00
peer: check for ErrEdgeNotFound when loading chan edge for fwrding policy
This commit adds a precautionary check for the error returned if the channel hasn’t yet been announced when attempting to read the our current routing policy to initialize the channelLink for a channel. Previously, if the channel wasn’t they announced, the function would return early instead of using the default policy. We also include another bug fix, that avoids a possible nil pointer panic in the case that the ChannelEdgeInfo reread form the graph is nil.
This commit is contained in:
4
peer.go
4
peer.go
@@ -322,7 +322,7 @@ func (p *peer) loadActiveChannels(chans []*channeldb.OpenChannel) error {
|
|||||||
// the database.
|
// the database.
|
||||||
graph := p.server.chanDB.ChannelGraph()
|
graph := p.server.chanDB.ChannelGraph()
|
||||||
info, p1, p2, err := graph.FetchChannelEdgesByOutpoint(chanPoint)
|
info, p1, p2, err := graph.FetchChannelEdgesByOutpoint(chanPoint)
|
||||||
if err != nil {
|
if err != nil && err != channeldb.ErrEdgeNotFound {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -334,7 +334,7 @@ func (p *peer) loadActiveChannels(chans []*channeldb.OpenChannel) error {
|
|||||||
// TODO(roasbeef): can add helper method to get policy for
|
// TODO(roasbeef): can add helper method to get policy for
|
||||||
// particular channel.
|
// particular channel.
|
||||||
var selfPolicy *channeldb.ChannelEdgePolicy
|
var selfPolicy *channeldb.ChannelEdgePolicy
|
||||||
if info.NodeKey1.IsEqual(p.server.identityPriv.PubKey()) {
|
if info != nil && info.NodeKey1.IsEqual(p.server.identityPriv.PubKey()) {
|
||||||
selfPolicy = p1
|
selfPolicy = p1
|
||||||
} else {
|
} else {
|
||||||
selfPolicy = p2
|
selfPolicy = p2
|
||||||
|
|||||||
Reference in New Issue
Block a user