Skip to content

Commit

Permalink
impl of _calcScriptExecutionCost - part 3
Browse files Browse the repository at this point in the history
cleaning
  • Loading branch information
paweljakubas committed Sep 14, 2021
1 parent acf8043 commit 6808fd7
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions lib/shelley/src/Cardano/Wallet/Shelley/Transaction.hs
Expand Up @@ -176,6 +176,7 @@ import qualified Cardano.Crypto.Hash.Class as Crypto
import qualified Cardano.Crypto.Wallet as Crypto.HD
import qualified Cardano.Ledger.Alonzo.TxWitness as SL
import qualified Cardano.Ledger.Core as SL
import qualified Cardano.Wallet.Primitive.Types as W
import qualified Cardano.Wallet.Primitive.Types.Coin as Coin
import qualified Cardano.Wallet.Primitive.Types.TokenBundle as TokenBundle
import qualified Cardano.Wallet.Shelley.Compatibility as Compatibility
Expand Down Expand Up @@ -490,11 +491,18 @@ _calcScriptExecutionCost
:: ProtocolParameters
-> SealedTx
-> Coin
_calcScriptExecutionCost pp sealedTx = undefined
_calcScriptExecutionCost pp sealedTx = case prices of
Nothing -> Coin 0
Just (W.ExecutionUnitPrices perStep perMem) ->
maybe
(Coin 0)
(Coin.sumCoins . map (costOfExecutiveUnits perStep perMem))
executeUnitsM
where
_prices = view #executionUnitPrices pp

_nodetx =
prices = view #executionUnitPrices pp
costOfExecutiveUnits perStep perMem (W.ExecutionUnits steps mem) =
Coin $ ceiling $ perStep * (fromIntegral steps) + perMem * (fromIntegral mem)
executeUnitsM =
case Cardano.deserialiseFromCBOR (Cardano.AsTx Cardano.AsAlonzoEra) (getSealedTx sealedTx) of
Right txValid ->
let getScriptData (Cardano.ShelleyTxBody _ _ _ scriptdata _ _) = scriptdata
Expand Down

0 comments on commit 6808fd7

Please sign in to comment.