From a4023144d31d705f85df6d4c49faf64b77231910 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Thu, 10 Nov 2016 17:41:23 -0800 Subject: [PATCH] peer: notify routing manager of newly loaded channels --- peer.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/peer.go b/peer.go index 85cf793e..44b7ceb4 100644 --- a/peer.go +++ b/peer.go @@ -228,6 +228,19 @@ func (p *peer) loadActiveChannels(chans []*channeldb.OpenChannel) error { p.activeChannels[chanPoint] = lnChan peerLog.Infof("peerID(%v) loaded ChannelPoint(%v)", p.id, chanPoint) + // Notify the routing table of this newly loaded channel. + chanInfo := lnChan.StateSnapshot() + capacity := int64(chanInfo.LocalBalance + chanInfo.RemoteBalance) + pubSerialized := p.addr.IdentityKey.SerializeCompressed() + vertex := hex.EncodeToString(pubSerialized) + p.server.routingMgr.OpenChannel( + graph.NewID(vertex), + graph.NewEdgeID(chanInfo.ChannelPoint.String()), + &rt.ChannelInfo{ + Cpt: capacity, + }, + ) + // Register this new channel link with the HTLC Switch. This is // necessary to properly route multi-hop payments, and forward // new payments triggered by RPC clients.