lnwire: remove MaxPayloadLength from Message interface

Removes the MaxPayloadLength function from the Message interface
and checks that each message payload is not greater than MaxMsgBody.
Since all messages are now allowed to be 65535 bytes in size, the
MaxPayloadLength is no longer needed.
This commit is contained in:
eugene committed 2021-03-04 16:48:10 -05:00
1 parent 055db6b9ac
commit 7ff04d8bad
30 files changed
+7 -246

No files matched your search

+5 -13
View File
@@ -151,7 +151,6 @@ type Serializable interface {
type Message interface {
Serializable
MsgType() MessageType
MaxPayloadLength(uint32) uint32
}
// makeEmptyMessage creates a new empty message of the proper concrete type
@@ -237,19 +236,12 @@ func WriteMessage(w io.Writer, msg Message, pver uint32) (int, error) {
payload := bw.Bytes()
lenp := len(payload)
// Enforce maximum overall message payload.
if lenp > MaxMessagePayload {
// Enforce maximum message payload, which means the body cannot be
// greater than MaxMsgBody.
if lenp > MaxMsgBody {
return totalBytes, fmt.Errorf("message payload is too large - "+
"encoded %d bytes, but maximum message payload is %d bytes",
lenp, MaxMessagePayload)
}
// Enforce maximum message payload on the message type.
mpl := msg.MaxPayloadLength(pver)
if uint32(lenp) > mpl {
return totalBytes, fmt.Errorf("message payload is too large - "+
"encoded %d bytes, but maximum message payload of "+
"type %v is %d bytes", lenp, msg.MsgType(), mpl)
"encoded %d bytes, but maximum message body is %d bytes",
lenp, MaxMsgBody)
}
// With the initial sanity checks complete, we'll now write out the