peer: add method handleLinkUpdateMsg to handle channel update msgs
This commit is contained in:
1 file changed
+26
-14
+26
-14
@@ -1657,20 +1657,7 @@ out:
|
|||||||
if isLinkUpdate {
|
if isLinkUpdate {
|
||||||
// If this is a channel update, then we need to feed it
|
// If this is a channel update, then we need to feed it
|
||||||
// into the channel's in-order message stream.
|
// into the channel's in-order message stream.
|
||||||
chanStream, ok := p.activeMsgStreams[targetChan]
|
p.sendLinkUpdateMsg(targetChan, nextMsg)
|
||||||
if !ok {
|
|
||||||
// If a stream hasn't yet been created, then
|
|
||||||
// we'll do so, add it to the map, and finally
|
|
||||||
// start it.
|
|
||||||
chanStream = newChanMsgStream(p, targetChan)
|
|
||||||
p.activeMsgStreams[targetChan] = chanStream
|
|
||||||
chanStream.Start()
|
|
||||||
defer chanStream.Stop()
|
|
||||||
}
|
|
||||||
|
|
||||||
// With the stream obtained, add the message to the
|
|
||||||
// stream so we can continue processing message.
|
|
||||||
chanStream.AddMsg(nextMsg)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
idleTimer.Reset(idleTimeout)
|
idleTimer.Reset(idleTimeout)
|
||||||
@@ -3883,3 +3870,28 @@ func (p *Brontide) handleNewPendingChannel(req *newChannelMsg) {
|
|||||||
p.activeChannels.Store(chanID, nil)
|
p.activeChannels.Store(chanID, nil)
|
||||||
p.addedChannels.Store(chanID, struct{}{})
|
p.addedChannels.Store(chanID, struct{}{})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// sendLinkUpdateMsg sends a message that updates the channel to the
|
||||||
|
// channel's message stream.
|
||||||
|
func (p *Brontide) sendLinkUpdateMsg(cid lnwire.ChannelID, msg lnwire.Message) {
|
||||||
|
p.log.Tracef("Sending link update msg=%v", msg.MsgType())
|
||||||
|
|
||||||
|
chanStream, ok := p.activeMsgStreams[cid]
|
||||||
|
if !ok {
|
||||||
|
// If a stream hasn't yet been created, then we'll do so, add
|
||||||
|
// it to the map, and finally start it.
|
||||||
|
chanStream = newChanMsgStream(p, cid)
|
||||||
|
p.activeMsgStreams[cid] = chanStream
|
||||||
|
chanStream.Start()
|
||||||
|
|
||||||
|
// Stop the stream when quit.
|
||||||
|
go func() {
|
||||||
|
<-p.quit
|
||||||
|
chanStream.Stop()
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
|
// With the stream obtained, add the message to the stream so we can
|
||||||
|
// continue processing message.
|
||||||
|
chanStream.AddMsg(msg)
|
||||||
|
}
|
||||||
Reference in new issue
Block a user