-
Notifications
You must be signed in to change notification settings - Fork 404
Encapsulate message wire encoding into a module #463
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
Encapsulate message wire encoding into a module #463
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. I like this, modulo 1.22 being unhappy. One thing worth considering would be moving the bulk (maybe just not the *MessageHandler traits) from msgs and the new mod here into their own top-level module? Right now most everything is stuffed into ln:: which is kinda awkward.
ae7ce30
to
298a7d8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing worth considering would be moving the bulk (maybe just not the *MessageHandler traits) from msgs and the new mod here into their own top-level module? Right now most everything is stuffed into ln:: which is kinda awkward.
I'm open to moving things around though I don't have a great sense of how it should be organized/named yet. Perhaps we can hold off until #434 is in to avoid disruption while coming up with a modularization we're happy with.
651e74d
to
b8e0be5
Compare
Rebased |
89574e0
to
7061109
Compare
Fixed a compilation error for Rust 1.22 where I needed to fully scope anything in an |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, mod the missing & in 1.22.
7061109
to
f910dac
Compare
Fixed remaining Rust 1.22 compilation errors. |
More Travis failures because the tests don't compile under Rust 1.22.0 (see #471 for details on older releases). Will fix these up now and re-push. |
Lightning messages are identified by a 2-byte type when encoded on the wire. Rather than expecting callers to know message types when sending messages to peers, have each message implement a trait defining the message type. Provide an interface for reading and writing messages as well as a Message enum for matching the decoded message, including unknown messages.
Create a MessageType abstraction and use it throughout the wire module's external interfaces. Include an is_even method for clients to determine how to handle unknown messages.
f910dac
to
0e6b207
Compare
Pushed test fixes:
|
Refactor message wire encoding into a separate module so clients don't have to concern themselves with type numbers and unknown types. Provide
wire::Message
andwire::MessageType
abstractions for encapsulating this behavior. Messages implement thewire::Encode
trait which extendsWriteable
for handling the message type. The module providesread
andwrite
convenience methods.