-
Notifications
You must be signed in to change notification settings - Fork 266
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
Prefix all stored LN messages by their length #1239
Conversation
Now that we have optional fields at the end of messages, we have to store their length in database, otherwise disasters will happen.
Codecov Report
@@ Coverage Diff @@
## master #1239 +/- ##
==========================================
+ Coverage 76.6% 76.78% +0.17%
==========================================
Files 140 140
Lines 9700 9723 +23
Branches 397 394 -3
==========================================
+ Hits 7431 7466 +35
+ Misses 2269 2257 -12
|
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.
I think I'd prefer the solution where we create a separate "legacy codecs" file where we put the non-length prefixed ones, and directly change the others here to be length-prefixed.
This duplicates code but makes reading the non-legacy code easier.
|
||
val DATA_WAIT_FOR_FUNDING_CONFIRMED_COMPAT_08_Codec: Codec[DATA_WAIT_FOR_FUNDING_CONFIRMED] = DATA_WAIT_FOR_FUNDING_CONFIRMED_Codec(false) | ||
|
||
val DATA_WAIT_FOR_FUNDING_CONFIRMED_11_Codec: Codec[DATA_WAIT_FOR_FUNDING_CONFIRMED] = DATA_WAIT_FOR_FUNDING_CONFIRMED_Codec(false) |
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.
Shouldn't this one be true
?
assert(htlcCodec.decodeValue(htlcCodec.encode(htlc2).require).require === htlc2) | ||
assert(htlcCodec(false).decodeValue(htlcCodec(false).encode(htlc1).require).require === htlc1) | ||
assert(htlcCodec(false).decodeValue(htlcCodec(false).encode(htlc2).require).require === htlc2) | ||
assert(htlcCodec(true).decodeValue(htlcCodec(true).encode(htlc2).require).require === htlc2) |
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.
it should be htlc1
here
Superseded by #1442. |
Now that we have optional fields at the end of messages, we have to
store their length in database, otherwise disasters will happen.