Closed jonathanknowles closed 3 months ago
@Anviking wrote:
One request (in addition to the comment): could we rename
balanceTransactionWithSelectionStrategyAndNoZeroAdaAdjustment
to something else?
Sure!
Would balanceTransactionInner
work for you?
Or perhaps we could use the following even shorter names:
balanceTx
balanceTxInner
Justification: the abbreviation Tx
is already a de facto standard throughout the code. For example:
PartialTx
ErrBalanceTx
TxIn
TxOut
Or perhaps we could use the following even shorter names:
balanceTx balanceTxInner
Sounds great to me, just note renaming Transaction -> Tx
could cause some cascading breakage and changes (for instance BalanceSpec has a balanceTx
helper)... Maybe separate PR would be better for that...
(Though btw, long term, I'd wonder if we couldn't structure things to not have to call something inner
, but that's not of too much concern now)
Sounds great to me, just note renaming Transaction -> Tx could cause some cascading breakage and changes (for instance BalanceSpec has a balanceTx helper)... Maybe separate PR would be better for that...
I agree, it probably makes more sense to have a separate PR for any renaming of the public function. 👍🏻
Issue
ADP-3272
Description
This PR simplifies the handling of UTxOs within the inner helper function of
balanceTransaction
, so that it only has to handle two UTxO-related data structures, both supplied by the outer function:utxoReference
: the set of all UTxOs (formerly known ascombinedUTxO
).utxoSelection
: the set of all UTxOs that the transaction is allowed to spend, along with a pre-selected subset.As a bonus, because this PR moves the computation of UTxO-related data structures from the inner helper function to the outer function, the above data structures should now be evaluated at most once, instead of multiple times (once per strategy).
Notes
The
balanceTransaction
function delegates the main portion of its work to an inner helper function that is parameterised bySelectionStrategy
. It initially calls the inner helper function withSelectionStrategyOptimal
, but if that strategy fails, then it (potentially) calls the inner helper function a second time withSelectionStrategyMinimal
.In the event that the inner helper function is evaluated more than once (with two different strategies), we ideally want to avoid recomputing potentially expensive data structures that should be constant across both evaluations.