multi: rename lnwire.NodeAnnouncement

In preparation for adding a NodeAnnouncement2 struct along with a
NodeAnnouncement interface, this commit renames the existing
NodeAnnouncment struct to NodeAnnouncement1.
This commit is contained in:
Elle Mouton committed 2025-10-01 13:13:32 +02:00
1 parent 8372524edf
commit b8abe130a5
22 files changed
+145 -131

No files matched your search

+12 -11
View File
@@ -244,11 +244,11 @@ type Config struct {
// FetchSelfAnnouncement retrieves our current node announcement, for
// use when determining whether we should update our peers about our
// presence in the network.
FetchSelfAnnouncement func() lnwire.NodeAnnouncement
FetchSelfAnnouncement func() lnwire.NodeAnnouncement1
// UpdateSelfAnnouncement produces a new announcement for our node with
// an updated timestamp which can be broadcast to our peers.
UpdateSelfAnnouncement func() (lnwire.NodeAnnouncement, error)
UpdateSelfAnnouncement func() (lnwire.NodeAnnouncement1, error)
// ProofMatureDelta the number of confirmations which is needed before
// exchange the channel announcement proofs.
@@ -1186,7 +1186,7 @@ func (d *deDupedAnnouncements) addMsg(message networkMsg) {
// Node announcements are identified by the Vertex field. Use the
// NodeID to create the corresponding Vertex.
case *lnwire.NodeAnnouncement:
case *lnwire.NodeAnnouncement1:
sender := route.NewVertex(message.source)
deDupKey := route.Vertex(msg.NodeID)
@@ -1195,7 +1195,8 @@ func (d *deDupedAnnouncements) addMsg(message networkMsg) {
oldTimestamp := uint32(0)
mws, ok := d.nodeAnnouncements[deDupKey]
if ok {
oldTimestamp = mws.msg.(*lnwire.NodeAnnouncement).Timestamp
ann, _ := mws.msg.(*lnwire.NodeAnnouncement1)
oldTimestamp = ann.Timestamp
}
// Discard the message if it's old.
@@ -1806,7 +1807,7 @@ func (d *AuthenticatedGossiper) retransmitStaleAnns(ctx context.Context,
return nil
}
// We'll also check that our NodeAnnouncement is not too old.
// We'll also check that our NodeAnnouncement1 is not too old.
currentNodeAnn := d.cfg.FetchSelfAnnouncement()
timestamp := time.Unix(int64(currentNodeAnn.Timestamp), 0)
timeElapsed := now.Sub(timestamp)
@@ -2062,7 +2063,7 @@ func (d *AuthenticatedGossiper) fetchPKScript(chanID lnwire.ShortChannelID) (
// addNode processes the given node announcement, and adds it to our channel
// graph.
func (d *AuthenticatedGossiper) addNode(ctx context.Context,
msg *lnwire.NodeAnnouncement, op ...batch.SchedulerOption) error {
msg *lnwire.NodeAnnouncement1, op ...batch.SchedulerOption) error {
if err := netann.ValidateNodeAnn(msg); err != nil {
return fmt.Errorf("unable to validate node announcement: %w",
@@ -2153,7 +2154,7 @@ func (d *AuthenticatedGossiper) processNetworkAnnouncement(ctx context.Context,
// A new node announcement has arrived which either presents new
// information about a node in one of the channels we know about, or a
// updating previously advertised information.
case *lnwire.NodeAnnouncement:
case *lnwire.NodeAnnouncement1:
return d.handleNodeAnnouncement(ctx, nMsg, msg, schedulerOp)
// A new channel announcement has arrived, this indicates the
@@ -2248,7 +2249,7 @@ func (d *AuthenticatedGossiper) processZombieUpdate(_ context.Context,
// announcement fields and returns an error if they are invalid to prevent
// forwarding invalid node announcements to our peers.
func (d *AuthenticatedGossiper) fetchNodeAnn(ctx context.Context,
pubKey [33]byte) (*lnwire.NodeAnnouncement, error) {
pubKey [33]byte) (*lnwire.NodeAnnouncement1, error) {
node, err := d.cfg.Graph.FetchNode(ctx, pubKey)
if err != nil {
@@ -2478,12 +2479,12 @@ func (d *AuthenticatedGossiper) latestHeight() uint32 {
// handleNodeAnnouncement processes a new node announcement.
func (d *AuthenticatedGossiper) handleNodeAnnouncement(ctx context.Context,
nMsg *networkMsg, nodeAnn *lnwire.NodeAnnouncement,
nMsg *networkMsg, nodeAnn *lnwire.NodeAnnouncement1,
ops []batch.SchedulerOption) ([]networkMsg, bool) {
timestamp := time.Unix(int64(nodeAnn.Timestamp), 0)
log.Debugf("Processing NodeAnnouncement: peer=%v, timestamp=%v, "+
log.Debugf("Processing NodeAnnouncement1: peer=%v, timestamp=%v, "+
"node=%x, source=%x", nMsg.peer, timestamp, nodeAnn.NodeID,
nMsg.source.SerializeCompressed())
@@ -2542,7 +2543,7 @@ func (d *AuthenticatedGossiper) handleNodeAnnouncement(ctx context.Context,
nMsg.err <- nil
// TODO(roasbeef): get rid of the above
log.Debugf("Processed NodeAnnouncement: peer=%v, timestamp=%v, "+
log.Debugf("Processed NodeAnnouncement1: peer=%v, timestamp=%v, "+
"node=%x, source=%x", nMsg.peer, timestamp, nodeAnn.NodeID,
nMsg.source.SerializeCompressed())