Skip to content

Commit

Permalink
peer: check for ErrEdgeNotFound when loading chan edge for fwrding po…
Browse files Browse the repository at this point in the history
…licy

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.
  • Loading branch information
Roasbeef committed Aug 30, 2017
1 parent a52d405 commit a43e9c6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ func (p *peer) loadActiveChannels(chans []*channeldb.OpenChannel) error {
// the database.
graph := p.server.chanDB.ChannelGraph()
info, p1, p2, err := graph.FetchChannelEdgesByOutpoint(chanPoint)
if err != nil {
if err != nil && err != channeldb.ErrEdgeNotFound {
return err
}

Expand All @@ -334,7 +334,7 @@ func (p *peer) loadActiveChannels(chans []*channeldb.OpenChannel) error {
// TODO(roasbeef): can add helper method to get policy for
// particular channel.
var selfPolicy *channeldb.ChannelEdgePolicy
if info.NodeKey1.IsEqual(p.server.identityPriv.PubKey()) {
if info != nil && info.NodeKey1.IsEqual(p.server.identityPriv.PubKey()) {
selfPolicy = p1
} else {
selfPolicy = p2
Expand Down

0 comments on commit a43e9c6

Please sign in to comment.