mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-04 17:55:36 +01:00
peer: stop considering pending channels as active
This commit changes the method `isActiveChannel` such that the pending channels are not consider as active.
This commit is contained in:
parent
ccb86a9d1d
commit
60627f676f
1 changed files with 21 additions and 3 deletions
|
@ -1572,7 +1572,8 @@ out:
|
|||
|
||||
case *lnwire.ChannelReestablish:
|
||||
targetChan = msg.ChanID
|
||||
isLinkUpdate = p.isActiveChannel(targetChan)
|
||||
isLinkUpdate = p.isActiveChannel(targetChan) ||
|
||||
p.isPendingChannel(targetChan)
|
||||
|
||||
// If we failed to find the link in question, and the
|
||||
// message received was a channel sync message, then
|
||||
|
@ -1663,8 +1664,25 @@ func (p *Brontide) handleCustomMessage(msg *lnwire.Custom) error {
|
|||
// isActiveChannel returns true if the provided channel id is active, otherwise
|
||||
// returns false.
|
||||
func (p *Brontide) isActiveChannel(chanID lnwire.ChannelID) bool {
|
||||
_, ok := p.activeChannels.Load(chanID)
|
||||
return ok
|
||||
// The channel would be nil if,
|
||||
// - the channel doesn't exist, or,
|
||||
// - the channel exists, but is pending. In this case, we don't
|
||||
// consider this channel active.
|
||||
channel, _ := p.activeChannels.Load(chanID)
|
||||
|
||||
return channel != nil
|
||||
}
|
||||
|
||||
// isPendingChannel returns true if the provided channel ID is pending, and
|
||||
// returns false if the channel is active or unknown.
|
||||
func (p *Brontide) isPendingChannel(chanID lnwire.ChannelID) bool {
|
||||
// Return false if the channel is unknown.
|
||||
channel, ok := p.activeChannels.Load(chanID)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
|
||||
return channel == nil
|
||||
}
|
||||
|
||||
// storeError stores an error in our peer's buffer of recent errors with the
|
||||
|
|
Loading…
Add table
Reference in a new issue