Skip to content

Commit

Permalink
Log finished ex units map
Browse files Browse the repository at this point in the history
  • Loading branch information
j-mueller committed Jan 26, 2025
1 parent 8efe5a8 commit f5ed230
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/coin-selection/lib/Convex/CoinSelection.hs
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ data TxBalancingMessage
PrepareInputs {availableBalance :: C.Value, transactionBalance :: C.Value}
| -- | Balancing a transaction body
StartBalancing {numInputs :: !Int, numOutputs :: !Int}
| -- | Execution units of the transaction, or error message in case of script error
ExUnitsMap {exUnits :: [(C.ScriptWitnessIndex, Either String C.ExecutionUnits)]}
| -- | Execution units of the transaction
ExUnitsMap {exUnits :: [(C.ScriptWitnessIndex, C.ExecutionUnits)]}
| -- | The transaction fee
Txfee {fee :: C.Quantity}
| -- | The remaining balance (after paying the fee)
Expand Down Expand Up @@ -292,13 +292,14 @@ balanceTransactionBody
csiUtxo
txbody0

traceWith tracer $ ExUnitsMap $ fmap (second (first (C.docToString . C.prettyError) . fmap snd)) $ Map.toList exUnitsMap

exUnitsMap' <- balancingError $
case Map.mapEither id exUnitsMap of
(failures, exUnitsMap') ->
handleExUnitsErrors (C.txScriptValidityToScriptValidity $ C.txScriptValidity csiTxBody) failures $
fmap snd exUnitsMap'

traceWith tracer $ ExUnitsMap $ Map.toList exUnitsMap'

txbodycontent1 <- balancingError $ substituteExecutionUnits exUnitsMap' csiTxBody
let txbodycontent1' = txbodycontent1 & set L.txFee (Coin (2 ^ (32 :: Integer) - 1)) & over L.txOuts (|> changeOutputLarge)

Expand Down

0 comments on commit f5ed230

Please sign in to comment.