Skip to content

Commit

Permalink
discovery/gossiper: send edge NodeAnnouncements upon announcing channel
Browse files Browse the repository at this point in the history
In this commit, we also include the node announcements for both parties
of the channel if we happen to know about them. We do this to ensure
that other nodes in the network have properly processed the node
announcement of each party after successfully announcing the channel.
  • Loading branch information
wpaulino committed Oct 21, 2018
1 parent b64bfb3 commit 024bf0e
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions discovery/gossiper.go
Expand Up @@ -2351,13 +2351,51 @@ func (d *AuthenticatedGossiper) processNetworkAnnouncement(
source: nMsg.source,
msg: e1Ann,
})

// In addition to sending this edge's policy, we'll also
// attempt to send the backing node's announcement if we
// happen to know about it.
pubKey, _ := chanInfo.NodeKey1()
node, err := d.cfg.Router.FetchLightningNode(pubKey)
if err == nil {
nodeAnn, err := CreateNodeAnnouncement(node)
if err == nil {
networkMsg := networkMsg{
peer: nMsg.peer,
source: nMsg.source,
msg: nodeAnn,
}
announcements = append(
announcements, networkMsg,
)
}
}
}
if e2Ann != nil {
announcements = append(announcements, networkMsg{
peer: nMsg.peer,
source: nMsg.source,
msg: e2Ann,
})

// In addition to sending this edge's policy, we'll also
// attempt to send the backing node's announcement if we
// happen to know about it.
pubKey, _ := chanInfo.NodeKey2()
node, err := d.cfg.Router.FetchLightningNode(pubKey)
if err == nil {
nodeAnn, err := CreateNodeAnnouncement(node)
if err == nil {
networkMsg := networkMsg{
peer: nMsg.peer,
source: nMsg.source,
msg: nodeAnn,
}
announcements = append(
announcements, networkMsg,
)
}
}
}

nMsg.err <- nil
Expand Down

0 comments on commit 024bf0e

Please sign in to comment.