Skip to content

Commit 5235f3b

Browse files
authored
Merge pull request #9623 from Roasbeef/size-msg-test-msg
Size msg test msg
2 parents 5d92172 + 05a6b68 commit 5235f3b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2635
-1781
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,5 @@ coverage.txt
8080
# Release build directory (to avoid build.vcs.modified Golang build tag to be
8181
# set to true by having untracked files in the working directory).
8282
/lnd-*/
83+
84+
.aider*

lnwire/accept_channel.go

+11
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ type AcceptChannel struct {
128128
// interface.
129129
var _ Message = (*AcceptChannel)(nil)
130130

131+
// A compile time check to ensure AcceptChannel implements the
132+
// lnwire.SizeableMessage interface.
133+
var _ SizeableMessage = (*AcceptChannel)(nil)
134+
131135
// Encode serializes the target AcceptChannel into the passed io.Writer
132136
// implementation. Serialization will observe the rules defined by the passed
133137
// protocol version.
@@ -281,3 +285,10 @@ func (a *AcceptChannel) Decode(r io.Reader, pver uint32) error {
281285
func (a *AcceptChannel) MsgType() MessageType {
282286
return MsgAcceptChannel
283287
}
288+
289+
// SerializedSize returns the serialized size of the message in bytes.
290+
//
291+
// This is part of the lnwire.SizeableMessage interface.
292+
func (a *AcceptChannel) SerializedSize() (uint32, error) {
293+
return MessageSerializedSize(a)
294+
}

lnwire/announcement_signatures.go

+11
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ type AnnounceSignatures1 struct {
4747
// lnwire.Message interface.
4848
var _ Message = (*AnnounceSignatures1)(nil)
4949

50+
// A compile time check to ensure AnnounceSignatures1 implements the
51+
// lnwire.SizeableMessage interface.
52+
var _ SizeableMessage = (*AnnounceSignatures1)(nil)
53+
5054
// A compile time check to ensure AnnounceSignatures1 implements the
5155
// lnwire.AnnounceSignatures interface.
5256
var _ AnnounceSignatures = (*AnnounceSignatures1)(nil)
@@ -97,6 +101,13 @@ func (a *AnnounceSignatures1) MsgType() MessageType {
97101
return MsgAnnounceSignatures
98102
}
99103

104+
// SerializedSize returns the serialized size of the message in bytes.
105+
//
106+
// This is part of the lnwire.SizeableMessage interface.
107+
func (a *AnnounceSignatures1) SerializedSize() (uint32, error) {
108+
return MessageSerializedSize(a)
109+
}
110+
100111
// SCID returns the ShortChannelID of the channel.
101112
//
102113
// This is part of the lnwire.AnnounceSignatures interface.

lnwire/announcement_signatures_2.go

+11
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ type AnnounceSignatures2 struct {
4141
// lnwire.Message interface.
4242
var _ Message = (*AnnounceSignatures2)(nil)
4343

44+
// A compile time check to ensure AnnounceSignatures2 implements the
45+
// lnwire.SizeableMessage interface.
46+
var _ SizeableMessage = (*AnnounceSignatures2)(nil)
47+
4448
// Decode deserializes a serialized AnnounceSignatures2 stored in the passed
4549
// io.Reader observing the specified protocol version.
4650
//
@@ -82,6 +86,13 @@ func (a *AnnounceSignatures2) MsgType() MessageType {
8286
return MsgAnnounceSignatures2
8387
}
8488

89+
// SerializedSize returns the serialized size of the message in bytes.
90+
//
91+
// This is part of the lnwire.SizeableMessage interface.
92+
func (a *AnnounceSignatures2) SerializedSize() (uint32, error) {
93+
return MessageSerializedSize(a)
94+
}
95+
8596
// SCID returns the ShortChannelID of the channel.
8697
//
8798
// NOTE: this is part of the AnnounceSignatures interface.

lnwire/channel_announcement.go

+11
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ type ChannelAnnouncement1 struct {
6262
// lnwire.Message interface.
6363
var _ Message = (*ChannelAnnouncement1)(nil)
6464

65+
// A compile time check to ensure ChannelAnnouncement1 implements the
66+
// lnwire.SizeableMessage interface.
67+
var _ SizeableMessage = (*ChannelAnnouncement1)(nil)
68+
6569
// Decode deserializes a serialized ChannelAnnouncement stored in the passed
6670
// io.Reader observing the specified protocol version.
6771
//
@@ -143,6 +147,13 @@ func (a *ChannelAnnouncement1) MsgType() MessageType {
143147
return MsgChannelAnnouncement
144148
}
145149

150+
// SerializedSize returns the serialized size of the message in bytes.
151+
//
152+
// This is part of the lnwire.SizeableMessage interface.
153+
func (a *ChannelAnnouncement1) SerializedSize() (uint32, error) {
154+
return MessageSerializedSize(a)
155+
}
156+
146157
// DataToSign is used to retrieve part of the announcement message which should
147158
// be signed.
148159
func (a *ChannelAnnouncement1) DataToSign() ([]byte, error) {

lnwire/channel_announcement_2.go

+11
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,21 @@ func (c *ChannelAnnouncement2) MsgType() MessageType {
194194
return MsgChannelAnnouncement2
195195
}
196196

197+
// SerializedSize returns the serialized size of the message in bytes.
198+
//
199+
// This is part of the lnwire.SizeableMessage interface.
200+
func (c *ChannelAnnouncement2) SerializedSize() (uint32, error) {
201+
return MessageSerializedSize(c)
202+
}
203+
197204
// A compile time check to ensure ChannelAnnouncement2 implements the
198205
// lnwire.Message interface.
199206
var _ Message = (*ChannelAnnouncement2)(nil)
200207

208+
// A compile time check to ensure ChannelAnnouncement2 implements the
209+
// lnwire.SizeableMessage interface.
210+
var _ SizeableMessage = (*ChannelAnnouncement2)(nil)
211+
201212
// Node1KeyBytes returns the bytes representing the public key of node 1 in the
202213
// channel.
203214
//

lnwire/channel_ready.go

+11
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ func NewChannelReady(cid ChannelID, npcp *btcec.PublicKey) *ChannelReady {
6363
// interface.
6464
var _ Message = (*ChannelReady)(nil)
6565

66+
// A compile time check to ensure ChannelReady implements the
67+
// lnwire.SizeableMessage interface.
68+
var _ SizeableMessage = (*ChannelReady)(nil)
69+
6670
// Decode deserializes the serialized ChannelReady message stored in the
6771
// passed io.Reader into the target ChannelReady using the deserialization
6872
// rules defined by the passed protocol version.
@@ -170,3 +174,10 @@ func (c *ChannelReady) Encode(w *bytes.Buffer, _ uint32) error {
170174
func (c *ChannelReady) MsgType() MessageType {
171175
return MsgChannelReady
172176
}
177+
178+
// SerializedSize returns the serialized size of the message in bytes.
179+
//
180+
// This is part of the lnwire.SizeableMessage interface.
181+
func (c *ChannelReady) SerializedSize() (uint32, error) {
182+
return MessageSerializedSize(c)
183+
}

lnwire/channel_reestablish.go

+11
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ type ChannelReestablish struct {
9999
// lnwire.Message interface.
100100
var _ Message = (*ChannelReestablish)(nil)
101101

102+
// A compile time check to ensure ChannelReestablish implements the
103+
// lnwire.SizeableMessage interface.
104+
var _ SizeableMessage = (*ChannelReestablish)(nil)
105+
102106
// Encode serializes the target ChannelReestablish into the passed io.Writer
103107
// observing the protocol version specified.
104108
//
@@ -234,3 +238,10 @@ func (a *ChannelReestablish) Decode(r io.Reader, pver uint32) error {
234238
func (a *ChannelReestablish) MsgType() MessageType {
235239
return MsgChannelReestablish
236240
}
241+
242+
// SerializedSize returns the serialized size of the message in bytes.
243+
//
244+
// This is part of the lnwire.SizeableMessage interface.
245+
func (a *ChannelReestablish) SerializedSize() (uint32, error) {
246+
return MessageSerializedSize(a)
247+
}

lnwire/channel_update.go

+11
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ type ChannelUpdate1 struct {
124124
// interface.
125125
var _ Message = (*ChannelUpdate1)(nil)
126126

127+
// A compile time check to ensure ChannelUpdate1 implements the
128+
// lnwire.SizeableMessage interface.
129+
var _ SizeableMessage = (*ChannelUpdate1)(nil)
130+
127131
// Decode deserializes a serialized ChannelUpdate stored in the passed
128132
// io.Reader observing the specified protocol version.
129133
//
@@ -367,3 +371,10 @@ func (a *ChannelUpdate1) SetSCID(scid ShortChannelID) {
367371
// A compile time assertion to ensure ChannelUpdate1 implements the
368372
// ChannelUpdate interface.
369373
var _ ChannelUpdate = (*ChannelUpdate1)(nil)
374+
375+
// SerializedSize returns the serialized size of the message in bytes.
376+
//
377+
// This is part of the lnwire.SizeableMessage interface.
378+
func (a *ChannelUpdate1) SerializedSize() (uint32, error) {
379+
return MessageSerializedSize(a)
380+
}

lnwire/channel_update_2.go

+7
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,13 @@ func (c *ChannelUpdate2) MsgType() MessageType {
241241
return MsgChannelUpdate2
242242
}
243243

244+
// SerializedSize returns the serialized size of the message in bytes.
245+
//
246+
// This is part of the lnwire.SizeableMessage interface.
247+
func (c *ChannelUpdate2) SerializedSize() (uint32, error) {
248+
return MessageSerializedSize(c)
249+
}
250+
244251
func (c *ChannelUpdate2) ExtraData() ExtraOpaqueData {
245252
return c.ExtraOpaqueData
246253
}

lnwire/closing_complete.go

+11
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,17 @@ func (c *ClosingComplete) MsgType() MessageType {
169169
return MsgClosingComplete
170170
}
171171

172+
// SerializedSize returns the serialized size of the message in bytes.
173+
//
174+
// This is part of the lnwire.SizeableMessage interface.
175+
func (c *ClosingComplete) SerializedSize() (uint32, error) {
176+
return MessageSerializedSize(c)
177+
}
178+
172179
// A compile time check to ensure ClosingComplete implements the lnwire.Message
173180
// interface.
174181
var _ Message = (*ClosingComplete)(nil)
182+
183+
// A compile time check to ensure ClosingComplete implements the
184+
// lnwire.SizeableMessage interface.
185+
var _ SizeableMessage = (*ClosingComplete)(nil)

lnwire/closing_sig.go

+11
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,17 @@ func (c *ClosingSig) MsgType() MessageType {
107107
return MsgClosingSig
108108
}
109109

110+
// SerializedSize returns the serialized size of the message in bytes.
111+
//
112+
// This is part of the lnwire.SizeableMessage interface.
113+
func (c *ClosingSig) SerializedSize() (uint32, error) {
114+
return MessageSerializedSize(c)
115+
}
116+
110117
// A compile time check to ensure ClosingSig implements the lnwire.Message
111118
// interface.
112119
var _ Message = (*ClosingSig)(nil)
120+
121+
// A compile time check to ensure ClosingSig implements the
122+
// lnwire.SizeableMessage interface.
123+
var _ SizeableMessage = (*ClosingSig)(nil)

lnwire/closing_signed.go

+11
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ func NewClosingSigned(cid ChannelID, fs btcutil.Amount,
5959
// interface.
6060
var _ Message = (*ClosingSigned)(nil)
6161

62+
// A compile time check to ensure ClosingSigned implements the
63+
// lnwire.SizeableMessage interface.
64+
var _ SizeableMessage = (*ClosingSigned)(nil)
65+
6266
// Decode deserializes a serialized ClosingSigned message stored in the passed
6367
// io.Reader observing the specified protocol version.
6468
//
@@ -130,3 +134,10 @@ func (c *ClosingSigned) Encode(w *bytes.Buffer, pver uint32) error {
130134
func (c *ClosingSigned) MsgType() MessageType {
131135
return MsgClosingSigned
132136
}
137+
138+
// SerializedSize returns the serialized size of the message in bytes.
139+
//
140+
// This is part of the lnwire.SizeableMessage interface.
141+
func (c *ClosingSigned) SerializedSize() (uint32, error) {
142+
return MessageSerializedSize(c)
143+
}

lnwire/commit_sig.go

+11
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ func NewCommitSig() *CommitSig {
6464
// interface.
6565
var _ Message = (*CommitSig)(nil)
6666

67+
// A compile time check to ensure CommitSig implements the
68+
// lnwire.SizeableMessage interface.
69+
var _ SizeableMessage = (*CommitSig)(nil)
70+
6771
// Decode deserializes a serialized CommitSig message stored in the
6872
// passed io.Reader observing the specified protocol version.
6973
//
@@ -151,3 +155,10 @@ func (c *CommitSig) MsgType() MessageType {
151155
func (c *CommitSig) TargetChanID() ChannelID {
152156
return c.ChanID
153157
}
158+
159+
// SerializedSize returns the serialized size of the message in bytes.
160+
//
161+
// This is part of the lnwire.SizeableMessage interface.
162+
func (c *CommitSig) SerializedSize() (uint32, error) {
163+
return MessageSerializedSize(c)
164+
}

lnwire/custom.go

+12-1
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,14 @@ type Custom struct {
6969
Data []byte
7070
}
7171

72-
// A compile time check to ensure FundingCreated implements the lnwire.Message
72+
// A compile time check to ensure Custom implements the lnwire.Message
7373
// interface.
7474
var _ Message = (*Custom)(nil)
7575

76+
// A compile time check to ensure Custom implements the lnwire.SizeableMessage
77+
// interface.
78+
var _ SizeableMessage = (*Custom)(nil)
79+
7680
// NewCustom instantiates a new custom message.
7781
func NewCustom(msgType MessageType, data []byte) (*Custom, error) {
7882
if msgType < CustomTypeStart && !IsCustomOverride(msgType) {
@@ -117,3 +121,10 @@ func (c *Custom) Decode(r io.Reader, pver uint32) error {
117121
func (c *Custom) MsgType() MessageType {
118122
return c.Type
119123
}
124+
125+
// SerializedSize returns the serialized size of the message in bytes.
126+
//
127+
// This is part of the lnwire.SizeableMessage interface.
128+
func (c *Custom) SerializedSize() (uint32, error) {
129+
return MessageSerializedSize(c)
130+
}

lnwire/dyn_ack.go

+11
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ type DynAck struct {
4141
// interface.
4242
var _ Message = (*DynAck)(nil)
4343

44+
// A compile time check to ensure DynAck implements the lnwire.SizeableMessage
45+
// interface.
46+
var _ SizeableMessage = (*DynAck)(nil)
47+
4448
// Encode serializes the target DynAck into the passed io.Writer. Serialization
4549
// will observe the rules defined by the passed protocol version.
4650
//
@@ -136,3 +140,10 @@ func (da *DynAck) Decode(r io.Reader, _ uint32) error {
136140
func (da *DynAck) MsgType() MessageType {
137141
return MsgDynAck
138142
}
143+
144+
// SerializedSize returns the serialized size of the message in bytes.
145+
//
146+
// This is part of the lnwire.SizeableMessage interface.
147+
func (da *DynAck) SerializedSize() (uint32, error) {
148+
return MessageSerializedSize(da)
149+
}

lnwire/dyn_propose.go

+11
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ type DynPropose struct {
105105
// interface.
106106
var _ Message = (*DynPropose)(nil)
107107

108+
// A compile time check to ensure DynPropose implements the
109+
// lnwire.SizeableMessage interface.
110+
var _ SizeableMessage = (*DynPropose)(nil)
111+
108112
// Encode serializes the target DynPropose into the passed io.Writer.
109113
// Serialization will observe the rules defined by the passed protocol version.
110114
//
@@ -317,3 +321,10 @@ func (dp *DynPropose) Decode(r io.Reader, _ uint32) error {
317321
func (dp *DynPropose) MsgType() MessageType {
318322
return MsgDynPropose
319323
}
324+
325+
// SerializedSize returns the serialized size of the message in bytes.
326+
//
327+
// This is part of the lnwire.SizeableMessage interface.
328+
func (dp *DynPropose) SerializedSize() (uint32, error) {
329+
return MessageSerializedSize(dp)
330+
}

lnwire/dyn_reject.go

+11
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ type DynReject struct {
3030
// interface.
3131
var _ Message = (*DynReject)(nil)
3232

33+
// A compile time check to ensure DynReject implements the
34+
// lnwire.SizeableMessage interface.
35+
var _ SizeableMessage = (*DynReject)(nil)
36+
3337
// Encode serializes the target DynReject into the passed io.Writer.
3438
// Serialization will observe the rules defined by the passed protocol version.
3539
//
@@ -74,3 +78,10 @@ func (dr *DynReject) Decode(r io.Reader, _ uint32) error {
7478
func (dr *DynReject) MsgType() MessageType {
7579
return MsgDynReject
7680
}
81+
82+
// SerializedSize returns the serialized size of the message in bytes.
83+
//
84+
// This is part of the lnwire.SizeableMessage interface.
85+
func (dr *DynReject) SerializedSize() (uint32, error) {
86+
return MessageSerializedSize(dr)
87+
}

0 commit comments

Comments
 (0)