From b5efc0ef3e340d838bb7216cff2227dfa5140912 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Mon, 2 Sep 2024 11:01:07 +0200 Subject: [PATCH] lnwallet: extract diskCommit, remove unused error return value --- lnwallet/channel.go | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/lnwallet/channel.go b/lnwallet/channel.go index 8dba07973..2338f6c10 100644 --- a/lnwallet/channel.go +++ b/lnwallet/channel.go @@ -3167,11 +3167,11 @@ func genRemoteHtlcSigJobs(keyRing *CommitmentKeyRing, var err error cancelChan := make(chan struct{}) + diskCommit := remoteCommitView.toDiskCommit(lntypes.Remote) auxResult, err := fn.MapOptionZ( leafStore, func(s AuxLeafStore) fn.Result[CommitDiffAuxResult] { return s.FetchLeavesFromCommit( - NewAuxChanState(chanState), - *remoteCommitView.toDiskCommit(lntypes.Remote), + NewAuxChanState(chanState), *diskCommit, *keyRing, ) }, @@ -3351,8 +3351,7 @@ func genRemoteHtlcSigJobs(keyRing *CommitmentKeyRing, // new commitment to the remote party. The commit diff returned contains all // information necessary for retransmission. func (lc *LightningChannel) createCommitDiff(newCommit *commitment, - commitSig lnwire.Sig, htlcSigs []lnwire.Sig) (*channeldb.CommitDiff, - error) { + commitSig lnwire.Sig, htlcSigs []lnwire.Sig) *channeldb.CommitDiff { // First, we need to convert the funding outpoint into the ID that's // used on the wire to identify this channel. We'll use this shortly @@ -3489,7 +3488,7 @@ func (lc *LightningChannel) createCommitDiff(newCommit *commitment, ClosedCircuitKeys: closedCircuitKeys, AddAcks: ackAddRefs, SettleFailAcks: settleFailRefs, - }, nil + } } // getUnsignedAckedUpdates returns all remote log updates that we haven't @@ -4124,10 +4123,7 @@ func (lc *LightningChannel) SignNextCommitment() (*NewCommitState, error) { // As we're about to proposer a new commitment state for the remote // party, we'll write this pending state to disk before we exit, so we // can retransmit it if necessary. - commitDiff, err := lc.createCommitDiff(newCommitView, sig, htlcSigs) - if err != nil { - return nil, err - } + commitDiff := lc.createCommitDiff(newCommitView, sig, htlcSigs) err = lc.channelState.AppendRemoteCommitChain(commitDiff) if err != nil { return nil, err @@ -4682,13 +4678,12 @@ func genHtlcSigValidationJobs(chanState *channeldb.OpenChannel, len(localCommitmentView.outgoingHTLCs) verifyJobs := make([]VerifyJob, 0, numHtlcs) + diskCommit := localCommitmentView.toDiskCommit(lntypes.Local) auxResult, err := fn.MapOptionZ( leafStore, func(s AuxLeafStore) fn.Result[CommitDiffAuxResult] { return s.FetchLeavesFromCommit( - NewAuxChanState(chanState), - *localCommitmentView.toDiskCommit( - lntypes.Local, - ), *keyRing, + NewAuxChanState(chanState), *diskCommit, + *keyRing, ) }, ).Unpack()