discovery+chan_series: replace usage of makeNodeAnn w/ new NodeAnnouncement method
This commit is contained in:
2 files changed
+5
-45
No files matched your search
+3
-22
@@ -89,7 +89,7 @@ func (c *chanSeries) UpdatesInHorizon(chain chainhash.Hash,
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for _, nodeAnn := range nodeAnnsInHorizon {
|
for _, nodeAnn := range nodeAnnsInHorizon {
|
||||||
nodeUpdate, err := makeNodeAnn(&nodeAnn)
|
nodeUpdate, err := nodeAnn.NodeAnnouncement(true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -151,25 +151,6 @@ func (c *chanSeries) FilterChannelRange(chain chainhash.Hash,
|
|||||||
return chanResp, nil
|
return chanResp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeNodeAnn(n *channeldb.LightningNode) (*lnwire.NodeAnnouncement, error) {
|
|
||||||
alias, _ := lnwire.NewNodeAlias(n.Alias)
|
|
||||||
|
|
||||||
wireSig, err := lnwire.NewSigFromRawSignature(n.AuthSigBytes)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &lnwire.NodeAnnouncement{
|
|
||||||
Signature: wireSig,
|
|
||||||
Timestamp: uint32(n.LastUpdate.Unix()),
|
|
||||||
Addresses: n.Addresses,
|
|
||||||
NodeID: n.PubKeyBytes,
|
|
||||||
Features: n.Features.RawFeatureVector,
|
|
||||||
RGBColor: n.Color,
|
|
||||||
Alias: alias,
|
|
||||||
ExtraOpaqueData: n.ExtraOpaqueData,
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// FetchChanAnns returns a full set of channel announcements as well as their
|
// FetchChanAnns returns a full set of channel announcements as well as their
|
||||||
// updates that match the set of specified short channel ID's. We'll use this
|
// updates that match the set of specified short channel ID's. We'll use this
|
||||||
// to reply to a QueryShortChanIDs message sent by a remote peer. The response
|
// to reply to a QueryShortChanIDs message sent by a remote peer. The response
|
||||||
@@ -221,7 +202,7 @@ func (c *chanSeries) FetchChanAnns(chain chainhash.Hash,
|
|||||||
nodePub := channel.Policy1.Node.PubKeyBytes
|
nodePub := channel.Policy1.Node.PubKeyBytes
|
||||||
hasNodeAnn := channel.Policy1.Node.HaveNodeAnnouncement
|
hasNodeAnn := channel.Policy1.Node.HaveNodeAnnouncement
|
||||||
if _, ok := nodePubsSent[nodePub]; !ok && hasNodeAnn {
|
if _, ok := nodePubsSent[nodePub]; !ok && hasNodeAnn {
|
||||||
nodeAnn, err := makeNodeAnn(channel.Policy1.Node)
|
nodeAnn, err := channel.Policy1.Node.NodeAnnouncement(true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -238,7 +219,7 @@ func (c *chanSeries) FetchChanAnns(chain chainhash.Hash,
|
|||||||
nodePub := channel.Policy2.Node.PubKeyBytes
|
nodePub := channel.Policy2.Node.PubKeyBytes
|
||||||
hasNodeAnn := channel.Policy2.Node.HaveNodeAnnouncement
|
hasNodeAnn := channel.Policy2.Node.HaveNodeAnnouncement
|
||||||
if _, ok := nodePubsSent[nodePub]; !ok && hasNodeAnn {
|
if _, ok := nodePubsSent[nodePub]; !ok && hasNodeAnn {
|
||||||
nodeAnn, err := makeNodeAnn(channel.Policy2.Node)
|
nodeAnn, err := channel.Policy2.Node.NodeAnnouncement(true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-23
@@ -270,27 +270,6 @@ func (d *AuthenticatedGossiper) SynchronizeNode(syncPeer lnpeer.Peer) error {
|
|||||||
// containing all the messages to be sent to the target peer.
|
// containing all the messages to be sent to the target peer.
|
||||||
var announceMessages []lnwire.Message
|
var announceMessages []lnwire.Message
|
||||||
|
|
||||||
makeNodeAnn := func(n *channeldb.LightningNode) (
|
|
||||||
*lnwire.NodeAnnouncement, error) {
|
|
||||||
|
|
||||||
alias, _ := lnwire.NewNodeAlias(n.Alias)
|
|
||||||
|
|
||||||
wireSig, err := lnwire.NewSigFromRawSignature(n.AuthSigBytes)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &lnwire.NodeAnnouncement{
|
|
||||||
Signature: wireSig,
|
|
||||||
Timestamp: uint32(n.LastUpdate.Unix()),
|
|
||||||
Addresses: n.Addresses,
|
|
||||||
NodeID: n.PubKeyBytes,
|
|
||||||
Features: n.Features.RawFeatureVector,
|
|
||||||
RGBColor: n.Color,
|
|
||||||
Alias: alias,
|
|
||||||
ExtraOpaqueData: n.ExtraOpaqueData,
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// We'll use this map to ensure we don't send the same node
|
// 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
|
// announcement more than one time as one node may have many channel
|
||||||
// anns we'll need to send.
|
// anns we'll need to send.
|
||||||
@@ -330,7 +309,7 @@ func (d *AuthenticatedGossiper) SynchronizeNode(syncPeer lnpeer.Peer) error {
|
|||||||
nodePub := e1.Node.PubKeyBytes
|
nodePub := e1.Node.PubKeyBytes
|
||||||
hasNodeAnn := e1.Node.HaveNodeAnnouncement
|
hasNodeAnn := e1.Node.HaveNodeAnnouncement
|
||||||
if _, ok := nodePubsSent[nodePub]; !ok && hasNodeAnn {
|
if _, ok := nodePubsSent[nodePub]; !ok && hasNodeAnn {
|
||||||
nodeAnn, err := makeNodeAnn(e1.Node)
|
nodeAnn, err := e1.Node.NodeAnnouncement(true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -352,7 +331,7 @@ func (d *AuthenticatedGossiper) SynchronizeNode(syncPeer lnpeer.Peer) error {
|
|||||||
nodePub := e2.Node.PubKeyBytes
|
nodePub := e2.Node.PubKeyBytes
|
||||||
hasNodeAnn := e2.Node.HaveNodeAnnouncement
|
hasNodeAnn := e2.Node.HaveNodeAnnouncement
|
||||||
if _, ok := nodePubsSent[nodePub]; !ok && hasNodeAnn {
|
if _, ok := nodePubsSent[nodePub]; !ok && hasNodeAnn {
|
||||||
nodeAnn, err := makeNodeAnn(e2.Node)
|
nodeAnn, err := e2.Node.NodeAnnouncement(true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user