lnwallet: remove mutateState from evaluateHTLCView
In line with previous commits we are progressively removing the mutateState argument from this call stack for a more principled software design approach. NOTE FOR REVIEWERS: We take a naive approach to updating the tests here and simply take the functionality we are removing from evaluateHTLCView and run it directly after the function in the test suite. It's possible that we should instead remove this from the test suite altogether but I opted to take a more conservative approach with respect to reducing the scope of tests. If you have opinions here, please make them known.
This commit is contained in:
4 files changed
+146
-97
No files matched your search
@@ -283,3 +283,31 @@ func (pd *paymentDescriptor) toLogUpdate() channeldb.LogUpdate {
|
||||
UpdateMsg: msg,
|
||||
}
|
||||
}
|
||||
|
||||
// setCommitHeight updates the appropriate addCommitHeight and/or
|
||||
// removeCommitHeight for whoseCommitChain and locks it in at nextHeight.
|
||||
func (pd *paymentDescriptor) setCommitHeight(
|
||||
whoseCommitChain lntypes.ChannelParty, nextHeight uint64) {
|
||||
|
||||
switch pd.EntryType {
|
||||
case Add:
|
||||
pd.addCommitHeights.SetForParty(
|
||||
whoseCommitChain, nextHeight,
|
||||
)
|
||||
case Settle, Fail, MalformedFail:
|
||||
pd.removeCommitHeights.SetForParty(
|
||||
whoseCommitChain, nextHeight,
|
||||
)
|
||||
case FeeUpdate:
|
||||
// Fee updates are applied for all commitments
|
||||
// after they are sent/received, so we consider
|
||||
// them being added and removed at the same
|
||||
// height.
|
||||
pd.addCommitHeights.SetForParty(
|
||||
whoseCommitChain, nextHeight,
|
||||
)
|
||||
pd.removeCommitHeights.SetForParty(
|
||||
whoseCommitChain, nextHeight,
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user