lnwire: let gossip messages implement GossipMessage

This commit is contained in:
Elle Mouton authored and yyforyongyu committed 2025-11-12 22:54:03 +08:00
1 parent 4d3bf6379a
commit ef0e6b78bb
9 files changed
+60

No files matched your search

+7
View File
@@ -121,3 +121,10 @@ func (a *AnnounceSignatures1) SCID() ShortChannelID {
func (a *AnnounceSignatures1) ChanID() ChannelID { func (a *AnnounceSignatures1) ChanID() ChannelID {
return a.ChannelID return a.ChannelID
} }
// GossipVersion returns the gossip version that this message is part of.
//
// NOTE: this is part of the GossipMessage interface.
func (a *AnnounceSignatures1) GossipVersion() GossipVersion {
return GossipVersion1
}
+7
View File
@@ -102,6 +102,13 @@ func (a *AnnounceSignatures2) MsgType() MessageType {
return MsgAnnounceSignatures2 return MsgAnnounceSignatures2
} }
// GossipVersion returns the gossip version that this message is part of.
//
// NOTE: this is part of the GossipMessage interface.
func (a *AnnounceSignatures2) GossipVersion() GossipVersion {
return GossipVersion2
}
// SerializedSize returns the serialized size of the message in bytes. // SerializedSize returns the serialized size of the message in bytes.
// //
// This is part of the lnwire.SizeableMessage interface. // This is part of the lnwire.SizeableMessage interface.
+7
View File
@@ -232,6 +232,13 @@ func (a *ChannelAnnouncement1) SCID() ShortChannelID {
return a.ShortChannelID return a.ShortChannelID
} }
// GossipVersion returns the gossip version that this message is part of.
//
// NOTE: this is part of the GossipMessage interface.
func (a *ChannelAnnouncement1) GossipVersion() GossipVersion {
return GossipVersion1
}
// A compile-time check to ensure that ChannelAnnouncement1 implements the // A compile-time check to ensure that ChannelAnnouncement1 implements the
// ChannelAnnouncement interface. // ChannelAnnouncement interface.
var _ ChannelAnnouncement = (*ChannelAnnouncement1)(nil) var _ ChannelAnnouncement = (*ChannelAnnouncement1)(nil)
+7
View File
@@ -307,6 +307,13 @@ func (c *ChannelAnnouncement2) SCID() ShortChannelID {
return c.ShortChannelID.Val return c.ShortChannelID.Val
} }
// GossipVersion returns the gossip version that this message is part of.
//
// NOTE: this is part of the GossipMessage interface.
func (c *ChannelAnnouncement2) GossipVersion() GossipVersion {
return GossipVersion2
}
// A compile-time check to ensure that ChannelAnnouncement2 implements the // A compile-time check to ensure that ChannelAnnouncement2 implements the
// ChannelAnnouncement interface. // ChannelAnnouncement interface.
var _ ChannelAnnouncement = (*ChannelAnnouncement2)(nil) var _ ChannelAnnouncement = (*ChannelAnnouncement2)(nil)
+7
View File
@@ -363,6 +363,13 @@ func (a *ChannelUpdate1) ForwardingPolicy() *ForwardingPolicy {
} }
} }
// GossipVersion returns the gossip version that this message is part of.
//
// NOTE: this is part of the GossipMessage interface.
func (a *ChannelUpdate1) GossipVersion() GossipVersion {
return GossipVersion1
}
// CmpAge can be used to determine if the update is older or newer than the // CmpAge can be used to determine if the update is older or newer than the
// passed update. It returns 1 if this update is newer, -1 if it is older, and // passed update. It returns 1 if this update is newer, -1 if it is older, and
// 0 if they are the same age. // 0 if they are the same age.
+7
View File
@@ -85,6 +85,13 @@ type ChannelUpdate2 struct {
ExtraSignedFields ExtraSignedFields
} }
// GossipVersion returns the gossip version that this message is part of.
//
// NOTE: this is part of the GossipMessage interface.
func (c *ChannelUpdate2) GossipVersion() GossipVersion {
return GossipVersion2
}
// Encode serializes the target ChannelUpdate2 into the passed io.Writer // Encode serializes the target ChannelUpdate2 into the passed io.Writer
// observing the protocol version specified. // observing the protocol version specified.
// //
+4
View File
@@ -45,6 +45,7 @@ type AnnounceSignatures interface {
ChanID() ChannelID ChanID() ChannelID
Message Message
GossipMessage
} }
// ChannelAnnouncement is an interface that must be satisfied by any message // ChannelAnnouncement is an interface that must be satisfied by any message
@@ -66,6 +67,7 @@ type ChannelAnnouncement interface {
Node2KeyBytes() [33]byte Node2KeyBytes() [33]byte
Message Message
GossipMessage
} }
// CompareResult represents the result after comparing two things. // CompareResult represents the result after comparing two things.
@@ -122,6 +124,7 @@ type ChannelUpdate interface {
SetSCID(scid ShortChannelID) SetSCID(scid ShortChannelID)
Message Message
GossipMessage
} }
// NodeAnnouncement is an interface that must be satisfied by any message used // NodeAnnouncement is an interface that must be satisfied by any message used
@@ -138,6 +141,7 @@ type NodeAnnouncement interface {
TimestampDesc() string TimestampDesc() string
Message Message
GossipMessage
} }
// ForwardingPolicy defines the set of forwarding constraints advertised in a // ForwardingPolicy defines the set of forwarding constraints advertised in a
+7
View File
@@ -243,3 +243,10 @@ func (a *NodeAnnouncement1) NodeFeatures() *FeatureVector {
func (a *NodeAnnouncement1) TimestampDesc() string { func (a *NodeAnnouncement1) TimestampDesc() string {
return fmt.Sprintf("timestamp=%d", a.Timestamp) return fmt.Sprintf("timestamp=%d", a.Timestamp)
} }
// GossipVersion returns the gossip version that this message is part of.
//
// NOTE: this is part of the GossipMessage interface.
func (a *NodeAnnouncement1) GossipVersion() GossipVersion {
return GossipVersion1
}
+7
View File
@@ -221,6 +221,13 @@ func (n *NodeAnnouncement2) TimestampDesc() string {
return fmt.Sprintf("block_height=%d", n.BlockHeight.Val) return fmt.Sprintf("block_height=%d", n.BlockHeight.Val)
} }
// GossipVersion returns the gossip version that this message is part of.
//
// NOTE: this is part of the GossipMessage interface.
func (n *NodeAnnouncement2) GossipVersion() GossipVersion {
return GossipVersion2
}
// A compile-time check to ensure NodeAnnouncement2 implements the Message // A compile-time check to ensure NodeAnnouncement2 implements the Message
// interface. // interface.
var _ Message = (*NodeAnnouncement2)(nil) var _ Message = (*NodeAnnouncement2)(nil)