mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-13 11:09:23 +01:00
peer: ensure no messages are sent/processed _before_ all channels loaded
This commit fixes a bug which could at times cause channels to be unusable upon connection. The bug would manifest like the following: two peers would connect, one loads their channels faster than the other, this would result in the winning peer attempting to extend their revocation window. However, if the other peer hadn’t yet loaded the channel, then this would appear to them to be an unknown channel. We properly fix this issue by ensure all channels are loaded _before_ any of the goroutines needed for the operation of the peer are launched.
This commit is contained in:
parent
a75439f56b
commit
e05ec619ca
1 changed files with 9 additions and 7 deletions
16
peer.go
16
peer.go
|
@ -237,6 +237,8 @@ func (p *peer) Start() error {
|
|||
}
|
||||
}
|
||||
|
||||
// Once the init message arrives, we can parse it so we can figure out
|
||||
// the negotiation of features for this session.
|
||||
msg := <-msgChan
|
||||
if msg, ok := msg.(*lnwire.Init); ok {
|
||||
if err := p.handleInitMsg(msg); err != nil {
|
||||
|
@ -247,13 +249,6 @@ func (p *peer) Start() error {
|
|||
"must be init message")
|
||||
}
|
||||
|
||||
p.wg.Add(5)
|
||||
go p.queueHandler()
|
||||
go p.writeHandler()
|
||||
go p.readHandler()
|
||||
go p.channelManager()
|
||||
go p.pingHandler()
|
||||
|
||||
// Fetch and then load all the active channels we have with this remote
|
||||
// peer from the database.
|
||||
activeChans, err := p.server.chanDB.FetchOpenChannels(p.addr.IdentityKey)
|
||||
|
@ -272,6 +267,13 @@ func (p *peer) Start() error {
|
|||
return fmt.Errorf("unable to load channels: %v", err)
|
||||
}
|
||||
|
||||
p.wg.Add(5)
|
||||
go p.queueHandler()
|
||||
go p.writeHandler()
|
||||
go p.readHandler()
|
||||
go p.channelManager()
|
||||
go p.pingHandler()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue