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

+4 -4
View File
@@ -220,10 +220,10 @@ func FuzzNodeAnnouncement(f *testing.F) {
// can be represented by different underlying bytes. Instead, we
// compare the normalized string representation of each address.
assertEq := func(t *testing.T, x, y any) {
require.IsType(t, &NodeAnnouncement{}, x)
first, _ := x.(*NodeAnnouncement)
require.IsType(t, &NodeAnnouncement{}, y)
second, _ := y.(*NodeAnnouncement)
require.IsType(t, &NodeAnnouncement1{}, x)
first, _ := x.(*NodeAnnouncement1)
require.IsType(t, &NodeAnnouncement1{}, y)
second, _ := y.(*NodeAnnouncement1)
require.Equal(
t, len(first.Addresses), len(second.Addresses),
+2 -2
View File
@@ -166,7 +166,7 @@ func (t MessageType) String() string {
case MsgChannelUpdate:
return "ChannelUpdate"
case MsgNodeAnnouncement:
return "NodeAnnouncement"
return "NodeAnnouncement1"
case MsgPing:
return "Ping"
case MsgAnnounceSignatures:
@@ -330,7 +330,7 @@ func makeEmptyMessage(msgType MessageType) (Message, error) {
case MsgChannelUpdate:
msg = &ChannelUpdate1{}
case MsgNodeAnnouncement:
msg = &NodeAnnouncement{}
msg = &NodeAnnouncement1{}
case MsgPing:
msg = &Ping{}
case MsgAnnounceSignatures:
+2 -2
View File
@@ -670,11 +670,11 @@ func newMsgChannelAnnouncement(t testing.TB,
}
func newMsgNodeAnnouncement(t testing.TB,
r *rand.Rand) *lnwire.NodeAnnouncement {
r *rand.Rand) *lnwire.NodeAnnouncement1 {
t.Helper()
msg := &lnwire.NodeAnnouncement{
msg := &lnwire.NodeAnnouncement1{
Features: rawFeatureVector(),
Timestamp: uint32(r.Int31()),
Alias: randAlias(r),
+14 -15
View File
@@ -62,11 +62,11 @@ func (n NodeAlias) String() string {
return string(bytes.Trim(n[:], "\x00"))
}
// NodeAnnouncement message is used to announce the presence of a Lightning
// NodeAnnouncement1 message is used to announce the presence of a Lightning
// node and also to signal that the node is accepting incoming connections.
// Each NodeAnnouncement authenticating the advertised information within the
// Each NodeAnnouncement1 authenticating the advertised information within the
// announcement via a signature using the advertised node pubkey.
type NodeAnnouncement struct {
type NodeAnnouncement1 struct {
// Signature is used to prove the ownership of node id.
Signature Sig
@@ -100,19 +100,19 @@ type NodeAnnouncement struct {
ExtraOpaqueData ExtraOpaqueData
}
// A compile time check to ensure NodeAnnouncement implements the
// A compile time check to ensure NodeAnnouncement1 implements the
// lnwire.Message interface.
var _ Message = (*NodeAnnouncement)(nil)
var _ Message = (*NodeAnnouncement1)(nil)
// A compile time check to ensure NodeAnnouncement implements the
// A compile time check to ensure NodeAnnouncement1 implements the
// lnwire.SizeableMessage interface.
var _ SizeableMessage = (*NodeAnnouncement)(nil)
var _ SizeableMessage = (*NodeAnnouncement1)(nil)
// Decode deserializes a serialized NodeAnnouncement stored in the passed
// Decode deserializes a serialized NodeAnnouncement1 stored in the passed
// io.Reader observing the specified protocol version.
//
// This is part of the lnwire.Message interface.
func (a *NodeAnnouncement) Decode(r io.Reader, _ uint32) error {
func (a *NodeAnnouncement1) Decode(r io.Reader, _ uint32) error {
err := ReadElements(r,
&a.Signature,
&a.Features,
@@ -130,11 +130,11 @@ func (a *NodeAnnouncement) Decode(r io.Reader, _ uint32) error {
return a.ExtraOpaqueData.ValidateTLV()
}
// Encode serializes the target NodeAnnouncement into the passed io.Writer
// Encode serializes the target NodeAnnouncement1 into the passed io.Writer
// observing the protocol version specified.
//
// This is part of the lnwire.Message interface.
func (a *NodeAnnouncement) Encode(w *bytes.Buffer, pver uint32) error {
func (a *NodeAnnouncement1) Encode(w *bytes.Buffer, pver uint32) error {
if err := WriteSig(w, a.Signature); err != nil {
return err
}
@@ -170,13 +170,12 @@ func (a *NodeAnnouncement) Encode(w *bytes.Buffer, pver uint32) error {
// wire.
//
// This is part of the lnwire.Message interface.
func (a *NodeAnnouncement) MsgType() MessageType {
func (a *NodeAnnouncement1) MsgType() MessageType {
return MsgNodeAnnouncement
}
// DataToSign returns the part of the message that should be signed.
func (a *NodeAnnouncement) DataToSign() ([]byte, error) {
func (a *NodeAnnouncement1) DataToSign() ([]byte, error) {
// We should not include the signatures itself.
buffer := make([]byte, 0, MaxMsgBody)
buf := bytes.NewBuffer(buffer)
@@ -215,6 +214,6 @@ func (a *NodeAnnouncement) DataToSign() ([]byte, error) {
// SerializedSize returns the serialized size of the message in bytes.
//
// This is part of the lnwire.SizeableMessage interface.
func (a *NodeAnnouncement) SerializedSize() (uint32, error) {
func (a *NodeAnnouncement1) SerializedSize() (uint32, error) {
return MessageSerializedSize(a)
}
+4 -4
View File
@@ -1215,15 +1215,15 @@ func (ks *KickoffSig) RandTestMessage(t *rapid.T) Message {
}
}
// A compile time check to ensure NodeAnnouncement implements the
// A compile time check to ensure NodeAnnouncement1 implements the
// lnwire.TestMessage interface.
var _ TestMessage = (*NodeAnnouncement)(nil)
var _ TestMessage = (*NodeAnnouncement1)(nil)
// RandTestMessage populates the message with random data suitable for testing.
// It uses the rapid testing framework to generate random values.
//
// This is part of the TestMessage interface.
func (a *NodeAnnouncement) RandTestMessage(t *rapid.T) Message {
func (a *NodeAnnouncement1) RandTestMessage(t *rapid.T) Message {
// Generate random compressed public key for node ID
pubKey := RandPubKey(t)
var nodeID [33]byte
@@ -1236,7 +1236,7 @@ func (a *NodeAnnouncement) RandTestMessage(t *rapid.T) Message {
B: uint8(rapid.IntRange(0, 255).Draw(t, "rgbB")),
}
return &NodeAnnouncement{
return &NodeAnnouncement1{
Signature: RandSignature(t),
Features: RandFeatureVector(t),
Timestamp: uint32(rapid.IntRange(0, 0x7FFFFFFF).Draw(