lnwallet: return balance changes rather than modifying references

Here we return the balance deltas from evaluateHTLCView rather than
passing in references to variables that will be modified. It is a
far cleaner and compositional approach which allows readers of this
code to more effectively reason about the code without having to
keep the whole codebase in their head.
This commit is contained in:
Keagan McClelland committed 2024-10-14 09:40:47 -06:00
1 parent f0eecfa2cd
commit 5307e7a5e4
2 files changed
+64 -67

No files matched your search

+5 -12
View File
@@ -8953,19 +8953,12 @@ func TestEvaluateView(t *testing.T) {
FeePerKw: feePerKw,
}
var (
// Create vars to store balance changes. We do
// not check these values in this test because
// balance modification happens on the htlc
// processing level.
ourBalance lnwire.MilliSatoshi
theirBalance lnwire.MilliSatoshi
)
// Evaluate the htlc view, mutate as test expects.
result, uncommitted, err := lc.evaluateHTLCView(
view, &ourBalance, &theirBalance, nextHeight,
test.whoseCommitChain,
// We do not check the balance deltas in this test
// because balance modification happens on the htlc
// processing level.
result, uncommitted, _, err := lc.evaluateHTLCView(
view, test.whoseCommitChain, nextHeight,
)
if err != nil {