lnwallet: extract pending local updates restore method

Extract method in preparation for restoring dangling remote updates. We
need to get rid of the early return.
This commit is contained in:
Joost Jager 2020-01-06 13:14:25 +01:00
parent 2d37d341a1
commit ed8fa35ed4
No known key found for this signature in database
GPG Key ID: A61B9D4C393C59C7

@ -1814,11 +1814,25 @@ func (lc *LightningChannel) restoreStateLogs(
lc.localUpdateLog.restoreHtlc(&htlc) lc.localUpdateLog.restoreHtlc(&htlc)
} }
// If we didn't have a dangling (un-acked) commit for the remote party, // If we have a dangling (un-acked) commit for the remote party, then we
// then we can exit here. // restore the updates leading up to this commit.
if pendingRemoteCommit == nil { if pendingRemoteCommit != nil {
return nil err := lc.restorePendingLocalUpdates(
pendingRemoteCommitDiff, pendingRemoteKeys,
)
if err != nil {
return err
} }
}
return nil
}
// restorePendingLocalUpdates restores the local log updates leading up to the
// given pending remote commitment.
func (lc *LightningChannel) restorePendingLocalUpdates(
pendingRemoteCommitDiff *channeldb.CommitDiff,
pendingRemoteKeys *CommitmentKeyRing) error {
pendingCommit := pendingRemoteCommitDiff.Commitment pendingCommit := pendingRemoteCommitDiff.Commitment
pendingHeight := pendingCommit.CommitHeight pendingHeight := pendingCommit.CommitHeight