lnwallet: extract diskCommit, remove unused error return value

This commit is contained in:
Oliver Gugger 2024-09-02 11:01:07 +02:00
parent 1b28f47c1d
commit b5efc0ef3e
No known key found for this signature in database
GPG Key ID: 8E4256593F177720

View File

@ -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()