From a43e9c6883d5668c8e4ad17d2df75476c7eb3bfc Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Wed, 30 Aug 2017 15:33:49 -0700 Subject: [PATCH] peer: check for ErrEdgeNotFound when loading chan edge for fwrding policy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- peer.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/peer.go b/peer.go index 788f4724e..0e8011a25 100644 --- a/peer.go +++ b/peer.go @@ -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 } @@ -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