6e463c1634
This commit is a direct copy of the complete channeldb package. It only changes the package declaration at the top of every file. We make this full copy so that review can be focused on the actual changes made. Otherwise changes may drown in all the file moves. Linting for the new package is disabled, as it contains lots of pre-existing issues.
56 lines
1.6 KiB
Go
56 lines
1.6 KiB
Go
package migration_01_to_11
|
|
|
|
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
|
|
}
|