channeldb+lnwallet: don't pass isRestoredChan to ChanSyncMsg

Since we have access to the internal state of the channel, we can
instead get it directly instead of passing it in as a parameter.
This commit is contained in:
Johan T. Halseth
2019-09-11 11:15:57 +02:00
parent c90b1dd17d
commit 2a6ad6e634
6 changed files with 32 additions and 45 deletions

View File

@@ -803,13 +803,10 @@ func (c *OpenChannel) MarkBorked() error {
// 3. We didn't get the last RevokeAndAck message they sent, so they'll
// re-send it.
//
// The isRestoredChan bool indicates if we need to craft a chan sync message
// for a channel that's been restored. If this is a restored channel, then
// we'll modify our typical chan sync message to ensure they force close even
// if we're on the very first state.
func (c *OpenChannel) ChanSyncMsg(
isRestoredChan bool) (*lnwire.ChannelReestablish, error) {
// If this is a restored channel, having status ChanStatusRestored, then we'll
// modify our typical chan sync message to ensure they force close even if
// we're on the very first state.
func (c *OpenChannel) ChanSyncMsg() (*lnwire.ChannelReestablish, error) {
c.Lock()
defer c.Unlock()
@@ -853,7 +850,7 @@ func (c *OpenChannel) ChanSyncMsg(
// If we've restored this channel, then we'll purposefully give them an
// invalid LocalUnrevokedCommitPoint so they'll force close the channel
// allowing us to sweep our funds.
if isRestoredChan {
if c.hasChanStatus(ChanStatusRestored) {
currentCommitSecret[0] ^= 1
}