peer: prevent processing close msg if channel is not found

This commit is contained in:
Wilmer Paulino committed 2018-06-25 13:13:12 -07:00
1 parent 18f17ad49b
commit b1ba83bf2b
2 files changed
+13 -7

No files matched your search

+5 -4
View File
@@ -442,10 +442,11 @@ var (
// of being opened. // of being opened.
channelOpeningStateBucket = []byte("channelOpeningState") channelOpeningStateBucket = []byte("channelOpeningState")
// ErrChannelNotFound is returned when we are looking for a specific // ErrChannelNotFound is an error returned when a channel is not known
// channel opening state in the FundingManager's internal database, but // to us. In this case of the fundingManager, this error is returned
// the channel in question is not considered being in an opening state. // when the channel in question is not considered being in an opening
ErrChannelNotFound = fmt.Errorf("channel not found in db") // state.
ErrChannelNotFound = fmt.Errorf("channel not found")
) )
// newFundingManager creates and initializes a new instance of the // newFundingManager creates and initializes a new instance of the
+8 -3
View File
@@ -1539,7 +1539,13 @@ out:
// closure process. // closure process.
chanCloser, err := p.fetchActiveChanCloser(closeMsg.cid) chanCloser, err := p.fetchActiveChanCloser(closeMsg.cid)
if err != nil { if err != nil {
peerLog.Errorf("unable to respond to remote "+ // If the channel is not known to us, we'll
// simply ignore this message.
if err == ErrChannelNotFound {
continue
}
peerLog.Errorf("Unable to respond to remote "+
"close msg: %v", err) "close msg: %v", err)
errMsg := &lnwire.Error{ errMsg := &lnwire.Error{
@@ -1617,8 +1623,7 @@ func (p *peer) fetchActiveChanCloser(chanID lnwire.ChannelID) (*channelCloser, e
channel, ok := p.activeChannels[chanID] channel, ok := p.activeChannels[chanID]
p.activeChanMtx.RUnlock() p.activeChanMtx.RUnlock()
if !ok { if !ok {
return nil, fmt.Errorf("unable to close channel, "+ return nil, ErrChannelNotFound
"ChannelID(%v) is unknown", chanID)
} }
// We'll attempt to look up the matching state machine, if we can't // We'll attempt to look up the matching state machine, if we can't