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:
parent
2d37d341a1
commit
ed8fa35ed4
@ -1814,11 +1814,25 @@ func (lc *LightningChannel) restoreStateLogs(
|
||||
lc.localUpdateLog.restoreHtlc(&htlc)
|
||||
}
|
||||
|
||||
// If we didn't have a dangling (un-acked) commit for the remote party,
|
||||
// then we can exit here.
|
||||
if pendingRemoteCommit == nil {
|
||||
return nil
|
||||
// If we have a dangling (un-acked) commit for the remote party, then we
|
||||
// restore the updates leading up to this commit.
|
||||
if pendingRemoteCommit != 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
|
||||
pendingHeight := pendingCommit.CommitHeight
|
||||
|
Loading…
Reference in New Issue
Block a user