lnwallet: eliminate inner-most layer of evil mutateState nonsense
This commit begins the process of moving towards a more principled means of state tracking. We eliminate the mutateState argument from processAddEntry and processRemoveEntry and move the responsibility of mutating said state to the call-sites. The current call-sites of these functions still have their *own* mutateState argument which will be eliminated during upcoming commits. However, following the principle of micro-commits I opted to break these changes up to make review simpler.
This commit is contained in:
2 files changed
+79
-60
No files matched your search
@@ -9613,15 +9613,25 @@ func TestProcessAddRemoveEntry(t *testing.T) {
|
||||
// update type. Process remove is used for settles,
|
||||
// fails and malformed htlcs.
|
||||
process := processRemoveEntry
|
||||
heightDual := &update.removeCommitHeights
|
||||
if test.updateType == Add {
|
||||
process = processAddEntry
|
||||
heightDual = &update.addCommitHeights
|
||||
}
|
||||
|
||||
process(
|
||||
update, &ourBalance, &theirBalance, nextHeight,
|
||||
test.whoseCommitChain, test.isIncoming,
|
||||
test.mutateState,
|
||||
)
|
||||
if heightDual.GetForParty(test.whoseCommitChain) == 0 {
|
||||
process(
|
||||
update, &ourBalance, &theirBalance,
|
||||
test.isIncoming,
|
||||
)
|
||||
|
||||
if test.mutateState {
|
||||
heightDual.SetForParty(
|
||||
test.whoseCommitChain,
|
||||
nextHeight,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// Check that balances were updated as expected.
|
||||
if ourBalance != test.ourExpectedBalance {
|
||||
|
||||
Reference in new issue
Block a user