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())
+15 -14
View File
@@ -493,8 +493,8 @@ func (m *mockNotifier) Stop() error {
}
type annBatch struct {
nodeAnn1 *lnwire.NodeAnnouncement
nodeAnn2 *lnwire.NodeAnnouncement
nodeAnn1 *lnwire.NodeAnnouncement1
nodeAnn2 *lnwire.NodeAnnouncement1
chanAnn *lnwire.ChannelAnnouncement1
@@ -577,8 +577,8 @@ func (ctx *testCtx) createAnnouncements(blockHeight uint32, key1,
}
func createNodeAnnouncement(priv *btcec.PrivateKey,
timestamp uint32, extraBytes ...[]byte) (*lnwire.NodeAnnouncement, error) {
func createNodeAnnouncement(priv *btcec.PrivateKey, timestamp uint32,
extraBytes ...[]byte) (*lnwire.NodeAnnouncement1, error) {
var err error
k := hex.EncodeToString(priv.Serialize())
@@ -587,7 +587,7 @@ func createNodeAnnouncement(priv *btcec.PrivateKey,
return nil, err
}
a := &lnwire.NodeAnnouncement{
a := &lnwire.NodeAnnouncement1{
Timestamp: timestamp,
Addresses: testAddrs,
Alias: alias,
@@ -966,15 +966,15 @@ func createTestCtx(t *testing.T, startHeight uint32, isChanPeer bool) (
c := make(chan struct{})
return c
},
FetchSelfAnnouncement: func() lnwire.NodeAnnouncement {
return lnwire.NodeAnnouncement{
FetchSelfAnnouncement: func() lnwire.NodeAnnouncement1 {
return lnwire.NodeAnnouncement1{
Timestamp: testTimestamp,
}
},
UpdateSelfAnnouncement: func() (lnwire.NodeAnnouncement,
UpdateSelfAnnouncement: func() (lnwire.NodeAnnouncement1,
error) {
return lnwire.NodeAnnouncement{
return lnwire.NodeAnnouncement1{
Timestamp: testTimestamp,
}, nil
},
@@ -2285,7 +2285,7 @@ func TestForwardPrivateNodeAnnouncement(t *testing.T) {
case <-time.After(2 * trickleDelay):
}
// Now, we'll attempt to forward the NodeAnnouncement for the same node
// Now, we'll attempt to forward the NodeAnnouncement1 for the same node
// by opening a public channel on the network. We'll create a
// ChannelAnnouncement and hand it off to the gossiper in order to
// process it.
@@ -2312,8 +2312,9 @@ func TestForwardPrivateNodeAnnouncement(t *testing.T) {
t.Fatal("gossiper should have broadcast the channel announcement")
}
// We'll recreate the NodeAnnouncement with an updated timestamp to
// prevent a stale update. The NodeAnnouncement should now be forwarded.
// We'll recreate the NodeAnnouncement1 with an updated timestamp to
// prevent a stale update. The NodeAnnouncement1 should now be
// forwarded.
nodeAnn, err = createNodeAnnouncement(remoteKeyPriv1, timestamp+1)
require.NoError(t, err, "unable to create node announcement")
@@ -2897,7 +2898,7 @@ func TestExtraDataChannelUpdateValidation(t *testing.T) {
}
// TestExtraDataNodeAnnouncementValidation tests that we're able to properly
// validate a NodeAnnouncement that includes opaque bytes that we don't
// validate a NodeAnnouncement1 that includes opaque bytes that we don't
// currently know of.
func TestExtraDataNodeAnnouncementValidation(t *testing.T) {
t.Parallel()
@@ -3044,7 +3045,7 @@ func TestRetransmit(t *testing.T) {
chanAnn++
case *lnwire.ChannelUpdate1:
chanUpd++
case *lnwire.NodeAnnouncement:
case *lnwire.NodeAnnouncement1:
nodeAnn++
}
}
+1 -1
View File
@@ -1653,7 +1653,7 @@ func (g *GossipSyncer) FilterGossipMsgs(ctx context.Context,
// Similarly, we only send node announcements if the update
// timestamp ifs between our set gossip filter time range.
case *lnwire.NodeAnnouncement:
case *lnwire.NodeAnnouncement1:
if passesFilter(msg.Timestamp) {
msgsToSend = append(msgsToSend, msg)
}
+16 -6
View File
@@ -249,10 +249,14 @@ func TestGossipSyncerFilterGossipMsgsNoHorizon(t *testing.T) {
// through the gossiper to the target peer.
msgs := []msgWithSenders{
{
msg: &lnwire.NodeAnnouncement{Timestamp: uint32(time.Now().Unix())},
msg: &lnwire.NodeAnnouncement1{
Timestamp: uint32(time.Now().Unix()),
},
},
{
msg: &lnwire.NodeAnnouncement{Timestamp: uint32(time.Now().Unix())},
msg: &lnwire.NodeAnnouncement1{
Timestamp: uint32(time.Now().Unix()),
},
},
}
@@ -308,15 +312,21 @@ func TestGossipSyncerFilterGossipMsgsAllInMemory(t *testing.T) {
msgs := []msgWithSenders{
{
// Node ann above horizon.
msg: &lnwire.NodeAnnouncement{Timestamp: unixStamp(25001)},
msg: &lnwire.NodeAnnouncement1{
Timestamp: unixStamp(25001),
},
},
{
// Node ann below horizon.
msg: &lnwire.NodeAnnouncement{Timestamp: unixStamp(5)},
msg: &lnwire.NodeAnnouncement1{
Timestamp: unixStamp(5),
},
},
{
// Node ann above horizon.
msg: &lnwire.NodeAnnouncement{Timestamp: unixStamp(999999)},
msg: &lnwire.NodeAnnouncement1{
Timestamp: unixStamp(999999),
},
},
{
// Ann tuple below horizon.
@@ -737,7 +747,7 @@ func TestGossipSyncerReplyShortChanIDs(t *testing.T) {
ShortChannelID: lnwire.NewShortChanIDFromInt(20),
Timestamp: unixStamp(999999),
},
&lnwire.NodeAnnouncement{Timestamp: unixStamp(25001)},
&lnwire.NodeAnnouncement1{Timestamp: unixStamp(25001)},
}
// We'll then craft a reply to the upcoming query for all the matching
+5 -5
View File
@@ -188,7 +188,7 @@ func (v *ValidationBarrier) InitJobDependencies(job interface{}) (JobID,
populateDependencies(msg.ShortChannelID.String(), childJobID)
return childJobID, nil
case *lnwire.NodeAnnouncement:
case *lnwire.NodeAnnouncement1:
childJobID := JobID(v.idCtr.Add(1))
populateDependencies(
route.Vertex(msg.NodeID).String(), childJobID,
@@ -242,7 +242,7 @@ func (v *ValidationBarrier) WaitForParents(childJobID JobID,
v.Lock()
switch msg := job.(type) {
// Any ChannelUpdate or NodeAnnouncement jobs will need to wait on the
// Any ChannelUpdate or NodeAnnouncement1 jobs will need to wait on the
// completion of any active ChannelAnnouncement jobs related to them.
case *lnwire.ChannelUpdate1:
annID = msg.ShortChannelID.String()
@@ -258,7 +258,7 @@ func (v *ValidationBarrier) WaitForParents(childJobID JobID,
jobDesc = fmt.Sprintf("job=lnwire.ChannelUpdate, scid=%v",
msg.ShortChannelID.ToUint64())
case *lnwire.NodeAnnouncement:
case *lnwire.NodeAnnouncement1:
annID = route.Vertex(msg.NodeID).String()
parentJobIDs, ok = v.jobDependencies[childJobID]
@@ -269,7 +269,7 @@ func (v *ValidationBarrier) WaitForParents(childJobID JobID,
return nil
}
jobDesc = fmt.Sprintf("job=lnwire.NodeAnnouncement, pub=%s",
jobDesc = fmt.Sprintf("job=lnwire.NodeAnnouncement1, pub=%s",
route.Vertex(msg.NodeID))
// Other types of jobs can be executed immediately, so we'll just
@@ -446,7 +446,7 @@ func (v *ValidationBarrier) SignalDependents(job interface{}, id JobID) error {
return nil
case *lnwire.NodeAnnouncement:
case *lnwire.NodeAnnouncement1:
// Remove child job info.
return removeJob(route.Vertex(msg.NodeID).String(), id, true)
+3 -3
View File
@@ -186,7 +186,7 @@ func TestValidationBarrierQuit(t *testing.T) {
}
// TestValidationBarrierParentJobsClear tests that creating two parent jobs for
// ChannelUpdate / NodeAnnouncement will pause child jobs until the set of
// ChannelUpdate / NodeAnnouncement1 will pause child jobs until the set of
// parent jobs has cleared.
func TestValidationBarrierParentJobsClear(t *testing.T) {
t.Parallel()
@@ -230,14 +230,14 @@ func TestValidationBarrierParentJobsClear(t *testing.T) {
parentID3, err := barrier.InitJobDependencies(ann3)
require.NoError(t, err)
// Create the ChannelUpdate & NodeAnnouncement messages.
// Create the ChannelUpdate & NodeAnnouncement1 messages.
upd1 := &lnwire.ChannelUpdate1{
ShortChannelID: sharedScid,
}
childID1, err := barrier.InitJobDependencies(upd1)
require.NoError(t, err)
node1 := &lnwire.NodeAnnouncement{
node1 := &lnwire.NodeAnnouncement1{
NodeID: sharedNodeID,
}
childID2, err := barrier.InitJobDependencies(node1)