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:
Olaoluwa Osuntokun 2017-08-30 15:33:49 -07:00
parent a52d405998
commit a43e9c6883
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2

View File

@ -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