-
Notifications
You must be signed in to change notification settings - Fork 132
Add version fields to RFQ wire messages #911
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d2b5e07
af5a222
e5a2ee8
007cc77
b5ef173
17c1dca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ import ( | |
"encoding/binary" | ||
"encoding/hex" | ||
"errors" | ||
"io" | ||
"math" | ||
|
||
"github.com/lightningnetwork/lnd/lnwire" | ||
|
@@ -115,6 +116,45 @@ func NewIncomingMsgFromWire(wireMsg WireMessage) (IncomingMsg, error) { | |
} | ||
} | ||
|
||
// WireMsgDataVersion specifies the version of the contents within a wire | ||
// message data field. | ||
type WireMsgDataVersion uint8 | ||
|
||
const ( | ||
// V0 represents version 0 of the contents in a wire message data field. | ||
V0 WireMsgDataVersion = 0 | ||
) | ||
|
||
// WireMsgDataVersionEncoder is a function that can be used to encode a | ||
// WireMsgDataVersion to a writer. | ||
func WireMsgDataVersionEncoder(w io.Writer, val any, buf *[8]byte) error { | ||
if version, ok := val.(*WireMsgDataVersion); ok { | ||
versionUint8 := uint8(*version) | ||
return tlv.EUint8(w, &versionUint8, buf) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: why not return tlv.EUint8T(w, uint8(*version), buf) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should have been There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sg, could be in the follow-up PR you mentioned above. |
||
} | ||
|
||
return tlv.NewTypeForEncodingErr(val, "WireMsgDataVersion") | ||
} | ||
|
||
// WireMsgDataVersionDecoder is a function that can be used to decode a | ||
// WireMsgDataVersion from a reader. | ||
func WireMsgDataVersionDecoder(r io.Reader, val any, buf *[8]byte, | ||
l uint64) error { | ||
|
||
if version, ok := val.(*WireMsgDataVersion); ok { | ||
var versionInt uint8 | ||
err := tlv.DUint8(r, &versionInt, buf, l) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
*version = WireMsgDataVersion(versionInt) | ||
return nil | ||
} | ||
|
||
return tlv.NewTypeForDecodingErr(val, "WireMsgDataVersion", l, 8) | ||
} | ||
|
||
// IncomingMsg is an interface that represents an inbound wire message | ||
// that has been received from a peer. | ||
type IncomingMsg interface { | ||
|
Uh oh!
There was an error while loading. Please reload this page.