discovery/gossiper: remove unused SynchronizeNode method
This commit is contained in:
parent
9eda94a40e
commit
a4097c113a
@ -331,114 +331,6 @@ func New(cfg Config, selfKey *btcec.PublicKey) *AuthenticatedGossiper {
|
|||||||
return gossiper
|
return gossiper
|
||||||
}
|
}
|
||||||
|
|
||||||
// SynchronizeNode sends a message to the service indicating it should
|
|
||||||
// synchronize lightning topology state with the target node. This method is to
|
|
||||||
// be utilized when a node connections for the first time to provide it with
|
|
||||||
// the latest topology update state. In order to accomplish this, (currently)
|
|
||||||
// the entire network graph is read from disk, then serialized to the format
|
|
||||||
// defined within the current wire protocol. This cache of graph data is then
|
|
||||||
// sent directly to the target node.
|
|
||||||
func (d *AuthenticatedGossiper) SynchronizeNode(syncPeer lnpeer.Peer) error {
|
|
||||||
// TODO(roasbeef): need to also store sig data in db
|
|
||||||
// * will be nice when we switch to pairing sigs would only need one ^_^
|
|
||||||
|
|
||||||
// We'll collate all the gathered routing messages into a single slice
|
|
||||||
// containing all the messages to be sent to the target peer.
|
|
||||||
var announceMessages []lnwire.Message
|
|
||||||
|
|
||||||
// We'll use this map to ensure we don't send the same node
|
|
||||||
// announcement more than one time as one node may have many channel
|
|
||||||
// anns we'll need to send.
|
|
||||||
nodePubsSent := make(map[route.Vertex]struct{})
|
|
||||||
|
|
||||||
// As peers are expecting channel announcements before node
|
|
||||||
// announcements, we first retrieve the initial announcement, as well as
|
|
||||||
// the latest channel update announcement for both of the directed edges
|
|
||||||
// that make up each channel, and queue these to be sent to the peer.
|
|
||||||
var (
|
|
||||||
numEdges uint32
|
|
||||||
numNodes uint32
|
|
||||||
)
|
|
||||||
if err := d.cfg.Router.ForEachChannel(func(chanInfo *channeldb.ChannelEdgeInfo,
|
|
||||||
e1, e2 *channeldb.ChannelEdgePolicy) error {
|
|
||||||
|
|
||||||
// First, using the parameters of the channel, along with the
|
|
||||||
// channel authentication proof, we'll create re-create the
|
|
||||||
// original authenticated channel announcement. If the channel
|
|
||||||
// also has known validated nodes, then we'll send that as
|
|
||||||
// well.
|
|
||||||
if chanInfo.AuthProof != nil {
|
|
||||||
chanAnn, e1Ann, e2Ann, err := CreateChanAnnouncement(
|
|
||||||
chanInfo.AuthProof, chanInfo, e1, e2,
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
announceMessages = append(announceMessages, chanAnn)
|
|
||||||
if e1Ann != nil {
|
|
||||||
announceMessages = append(announceMessages, e1Ann)
|
|
||||||
|
|
||||||
// If this edge has a validated node
|
|
||||||
// announcement, that we haven't yet sent, then
|
|
||||||
// we'll send that as well.
|
|
||||||
nodePub := e1.Node.PubKeyBytes
|
|
||||||
hasNodeAnn := e1.Node.HaveNodeAnnouncement
|
|
||||||
if _, ok := nodePubsSent[nodePub]; !ok && hasNodeAnn {
|
|
||||||
nodeAnn, err := e1.Node.NodeAnnouncement(true)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
announceMessages = append(
|
|
||||||
announceMessages, nodeAnn,
|
|
||||||
)
|
|
||||||
nodePubsSent[nodePub] = struct{}{}
|
|
||||||
|
|
||||||
numNodes++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if e2Ann != nil {
|
|
||||||
announceMessages = append(announceMessages, e2Ann)
|
|
||||||
|
|
||||||
// If this edge has a validated node
|
|
||||||
// announcement, that we haven't yet sent, then
|
|
||||||
// we'll send that as well.
|
|
||||||
nodePub := e2.Node.PubKeyBytes
|
|
||||||
hasNodeAnn := e2.Node.HaveNodeAnnouncement
|
|
||||||
if _, ok := nodePubsSent[nodePub]; !ok && hasNodeAnn {
|
|
||||||
nodeAnn, err := e2.Node.NodeAnnouncement(true)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
announceMessages = append(
|
|
||||||
announceMessages, nodeAnn,
|
|
||||||
)
|
|
||||||
nodePubsSent[nodePub] = struct{}{}
|
|
||||||
|
|
||||||
numNodes++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
numEdges++
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}); err != nil && err != channeldb.ErrGraphNoEdgesFound {
|
|
||||||
log.Errorf("unable to sync infos with peer: %v", err)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Infof("Syncing channel graph state with %x, sending %v "+
|
|
||||||
"vertexes and %v edges", syncPeer.PubKey(),
|
|
||||||
numNodes, numEdges)
|
|
||||||
|
|
||||||
// With all the announcement messages gathered, send them all in a
|
|
||||||
// single batch to the target peer.
|
|
||||||
return syncPeer.SendMessageLazy(false, announceMessages...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// PropagateChanPolicyUpdate signals the AuthenticatedGossiper to update the
|
// PropagateChanPolicyUpdate signals the AuthenticatedGossiper to update the
|
||||||
// channel forwarding policies for the specified channels. If no channels are
|
// channel forwarding policies for the specified channels. If no channels are
|
||||||
// specified, then the update will be applied to all outgoing channels from the
|
// specified, then the update will be applied to all outgoing channels from the
|
||||||
|
Loading…
Reference in New Issue
Block a user