-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Data loss protect resending #1937
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
Merged
Roasbeef
merged 18 commits into
lightningnetwork:master
from
halseth:data-loss-protect-resending
Nov 26, 2018
Merged
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
e1d8b07
lnd_test: remove unused math/rand rependency
halseth eb2f832
lnd_test: define createPayReqs helper method
halseth 0ca7c8c
lnd_test: define helper getChanInfo
halseth 13098a5
lnd test: refactor testDataLossProtection
halseth 780e1bb
peer: correct variable name, print error
halseth 149a8ce
channeldb/legacy_serialization: add deserializeCloseChannelSummaryV6
halseth 28b15dc
channeldb/channel: write boolean to indicate presence of ChannelClose…
halseth 46c961a
channeldb/migrations: migrate ChannelCloseSummary
halseth 0b9a323
channeldb/channel: add LastChanSync field to CloseChannelSummary
halseth 676a1b1
lnwallet+link: make ChanSyncMsg take channel state as arg
halseth a9f93b2
contractcourt/chain_watcher: add channel sync message to CloseChannel…
halseth 45b132a
channeldb/db: define FetchClosedChannelForID
halseth da3f515
channeldb/db_test: add TestFetchClosedChannelForID
halseth 0dd7eed
peer: define resendChanSyncMsg
halseth 9e81b1f
chain_watcher: poll for commit point in case of failure
halseth 0c4948b
lnd test: add offline scenario to testDataLossProtection
halseth a9bd610
htlcswitch/link: remove handled TODO
halseth b1a35fc
channeldb/migrations_test: add TestMigrateOptionalChannelCloseSummary…
halseth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| package channeldb | ||
|
|
||
| import "io" | ||
|
|
||
| // deserializeCloseChannelSummaryV6 reads the v6 database format for | ||
| // ChannelCloseSummary. | ||
| // | ||
| // NOTE: deprecated, only for migration. | ||
| func deserializeCloseChannelSummaryV6(r io.Reader) (*ChannelCloseSummary, error) { | ||
| c := &ChannelCloseSummary{} | ||
|
|
||
| err := ReadElements(r, | ||
| &c.ChanPoint, &c.ShortChanID, &c.ChainHash, &c.ClosingTXID, | ||
| &c.CloseHeight, &c.RemotePub, &c.Capacity, &c.SettledBalance, | ||
| &c.TimeLockedBalance, &c.CloseType, &c.IsPending, | ||
| ) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| // We'll now check to see if the channel close summary was encoded with | ||
| // any of the additional optional fields. | ||
| err = ReadElements(r, &c.RemoteCurrentRevocation) | ||
| switch { | ||
| case err == io.EOF: | ||
| return c, nil | ||
|
|
||
| // If we got a non-eof error, then we know there's an actually issue. | ||
| // Otherwise, it may have been the case that this summary didn't have | ||
| // the set of optional fields. | ||
| case err != nil: | ||
| return nil, err | ||
| } | ||
|
|
||
| if err := readChanConfig(r, &c.LocalChanConfig); err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| // Finally, we'll attempt to read the next unrevoked commitment point | ||
| // for the remote party. If we closed the channel before receiving a | ||
| // funding locked message, then this can be nil. As a result, we'll use | ||
| // the same technique to read the field, only if there's still data | ||
| // left in the buffer. | ||
| err = ReadElements(r, &c.RemoteNextRevocation) | ||
| if err != nil && err != io.EOF { | ||
| // If we got a non-eof error, then we know there's an actually | ||
| // issue. Otherwise, it may have been the case that this | ||
| // summary didn't have the set of optional fields. | ||
| return nil, err | ||
| } | ||
|
|
||
| return c, nil | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This was after an idea by @joostjager. Lmk what you think :)