mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-22 14:22:37 +01:00
peer: send msgs to chanStream
for both active and pending channels
This commit now sends messages to `chanStream` for both pending and active channels. If the message is sent to a pending channel, it will be queued in `chanStream`. Once the channel link becomes active, the early messages will be processed.
This commit is contained in:
parent
a9da25b238
commit
f9d4212ecc
1 changed files with 22 additions and 3 deletions
|
@ -1607,8 +1607,7 @@ out:
|
|||
|
||||
case *lnwire.ChannelReestablish:
|
||||
targetChan = msg.ChanID
|
||||
isLinkUpdate = p.isActiveChannel(targetChan) ||
|
||||
p.isPendingChannel(targetChan)
|
||||
isLinkUpdate = p.hasChannel(targetChan)
|
||||
|
||||
// If we failed to find the link in question, and the
|
||||
// message received was a channel sync message, then
|
||||
|
@ -1625,9 +1624,22 @@ out:
|
|||
}
|
||||
}
|
||||
|
||||
// For messages that implement the LinkUpdater interface, we
|
||||
// will consider them as link updates and send them to
|
||||
// chanStream. These messages will be queued inside chanStream
|
||||
// if the channel is not active yet.
|
||||
case LinkUpdater:
|
||||
targetChan = msg.TargetChanID()
|
||||
isLinkUpdate = p.isActiveChannel(targetChan)
|
||||
isLinkUpdate = p.hasChannel(targetChan)
|
||||
|
||||
// Log an error if we don't have this channel. This
|
||||
// means the peer has sent us a message with unknown
|
||||
// channel ID.
|
||||
if !isLinkUpdate {
|
||||
p.log.Errorf("Unknown channel ID: %v found "+
|
||||
"in received msg=%s", targetChan,
|
||||
nextMsg.MsgType())
|
||||
}
|
||||
|
||||
case *lnwire.ChannelUpdate,
|
||||
*lnwire.ChannelAnnouncement,
|
||||
|
@ -1729,6 +1741,13 @@ func (p *Brontide) isPendingChannel(chanID lnwire.ChannelID) bool {
|
|||
return channel == nil
|
||||
}
|
||||
|
||||
// hasChannel returns true if the peer has a pending/active channel specified
|
||||
// by the channel ID.
|
||||
func (p *Brontide) hasChannel(chanID lnwire.ChannelID) bool {
|
||||
_, ok := p.activeChannels.Load(chanID)
|
||||
return ok
|
||||
}
|
||||
|
||||
// storeError stores an error in our peer's buffer of recent errors with the
|
||||
// current timestamp. Errors are only stored if we have at least one active
|
||||
// channel with the peer to mitigate a dos vector where a peer costlessly
|
||||
|
|
Loading…
Add table
Reference in a new issue