diff --git a/peer.go b/peer.go index b2902f02..011ba1e8 100644 --- a/peer.go +++ b/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 }