| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Ledger.Index
Description
An index of unspent transaction outputs, and some functions for validating transactions using the index.
Synopsis
- newtype UtxoIndex = UtxoIndex {}
- insert :: CardanoTx -> UtxoIndex -> UtxoIndex
- insertCollateral :: CardanoTx -> UtxoIndex -> UtxoIndex
- insertBlock :: Block -> UtxoIndex -> UtxoIndex
- initialise :: Blockchain -> UtxoIndex
- lookup :: MonadError ValidationError m => TxOutRef -> UtxoIndex -> m TxOut
- data ValidationError
- _TxOutRefNotFound :: AsValidationError r => Prism' r TxOutRef
- _ScriptFailure :: AsValidationError r => Prism' r ScriptError
- _CardanoLedgerValidationError :: AsValidationError r => Prism' r Text
- type ValidationSuccess = Map RdmrPtr ([Text], ExUnits)
- type ValidationErrorInPhase = (ValidationPhase, ValidationError)
- data ValidationPhase
- minFee :: Tx -> Value
- maxFee :: Ada
- adjustTxOut :: PParams (BabbageEra StandardCrypto) -> TxOut -> Either ToCardanoError ([Ada], TxOut)
- minAdaTxOut :: PParams (BabbageEra StandardCrypto) -> TxOut -> Ada
- minAdaTxOutEstimated :: Ada
- maxMinAdaTxOut :: Ada
- pubKeyTxIns :: Fold [TxIn] TxIn
- scriptTxIns :: Fold [TxIn] TxIn
- data ExBudget = ExBudget {}
- newtype ExCPU = ExCPU CostingInteger
- newtype ExMemory = ExMemory CostingInteger
- data SatInt
Types for transaction validation based on UTXO index
The UTxOs of a blockchain indexed by their references.
Instances
| Eq UtxoIndex Source # | |
| Show UtxoIndex Source # | |
| Generic UtxoIndex Source # | |
| Semigroup UtxoIndex Source # | |
| Monoid UtxoIndex Source # | |
| NFData UtxoIndex Source # | |
Defined in Ledger.Index.Internal | |
| ToJSON UtxoIndex Source # | |
| FromJSON UtxoIndex Source # | |
| ToSchema UtxoIndex Source # | |
Defined in Ledger.Index.Internal Methods declareNamedSchema :: Proxy UtxoIndex -> Declare (Definitions Schema) NamedSchema Source # | |
| Serialise UtxoIndex Source # | |
| type Rep UtxoIndex Source # | |
Defined in Ledger.Index.Internal | |
insert :: CardanoTx -> UtxoIndex -> UtxoIndex Source #
Update the index for the addition of a transaction.
insertCollateral :: CardanoTx -> UtxoIndex -> UtxoIndex Source #
Update the index for the addition of only the collateral inputs of a failed transaction.
insertBlock :: Block -> UtxoIndex -> UtxoIndex Source #
Update the index for the addition of a block.
initialise :: Blockchain -> UtxoIndex Source #
Create an index of all UTxOs on the chain.
lookup :: MonadError ValidationError m => TxOutRef -> UtxoIndex -> m TxOut Source #
Find an unspent transaction output by the TxOutRef that spends it.
data ValidationError Source #
A reason why a transaction is invalid.
Constructors
| TxOutRefNotFound TxOutRef | The transaction output consumed by a transaction input could not be found (either because it was already spent, or because there was no transaction with the given hash on the blockchain). |
| ScriptFailure ScriptError | For pay-to-script outputs: evaluation of the validator script failed. |
| CardanoLedgerValidationError Text | An error from Cardano.Ledger validation |
Instances
_TxOutRefNotFound :: AsValidationError r => Prism' r TxOutRef Source #
_ScriptFailure :: AsValidationError r => Prism' r ScriptError Source #
data ValidationPhase Source #
Instances
TODO Should be calculated based on the maximum script size permitted on the Cardano blockchain.
adjustTxOut :: PParams (BabbageEra StandardCrypto) -> TxOut -> Either ToCardanoError ([Ada], TxOut) Source #
Adjust a single transaction output so it contains at least the minimum amount of Ada and return the adjustment (if any) and the updated TxOut.
minAdaTxOut :: PParams (BabbageEra StandardCrypto) -> TxOut -> Ada Source #
Exact computation of the mimimum Ada required for a given TxOut. TODO: Should be moved to cardano-api-extended once created
minAdaTxOutEstimated :: Ada Source #
Provide a reasonable estimate of the mimimum of Ada required for a TxOut.
An exact estimate of the the mimimum of Ada in a TxOut is determined by two things:
- the PParams, more precisely its coinPerUTxOWord parameter.
- the size of the TxOut.
In many situations though, we need to determine a plausible value for the minimum of Ada needed for a TxOut
without knowing much of the TxOut.
This function provides a value big enough to balance UTxOs without
a large inlined data (larger than a hash) nor a complex val with a lot of minted values.
It's superior to the lowest minimum needed for an UTxO, as the lowest value require no datum.
An estimate of the minimum required Ada for each tx output.
maxMinAdaTxOut :: Ada Source #
Constructors
| ExBudget | |
Fields | |
Instances
| Eq ExBudget | |
| Show ExBudget | |
| Generic ExBudget | |
| Semigroup ExBudget | |
| Monoid ExBudget | |
| NFData ExBudget | |
Defined in PlutusCore.Evaluation.Machine.ExBudget | |
| ToJSON ExBudget | |
| FromJSON ExBudget | |
| NoThunks ExBudget | |
| Pretty ExBudget | |
| Lift ExBudget | |
| PrettyBy config ExBudget | |
| type Rep ExBudget | |
Defined in PlutusCore.Evaluation.Machine.ExBudget type Rep ExBudget = D1 ('MetaData "ExBudget" "PlutusCore.Evaluation.Machine.ExBudget" "plutus-core-1.0.0.1-AYZ1DL3hDMt58i5HNUtSdG" 'False) (C1 ('MetaCons "ExBudget" 'PrefixI 'True) (S1 ('MetaSel ('Just "exBudgetCPU") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedUnpack) (Rec0 ExCPU) :*: S1 ('MetaSel ('Just "exBudgetMemory") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedUnpack) (Rec0 ExMemory))) | |
Counts CPU units in picoseconds: maximum value for SatInt is 2^63 ps, or appproximately 106 days.
Constructors
| ExCPU CostingInteger |
Instances
| Eq ExCPU | |
| Num ExCPU | |
Defined in PlutusCore.Evaluation.Machine.ExMemory | |
| Ord ExCPU | |
Defined in PlutusCore.Evaluation.Machine.ExMemory | |
| Show ExCPU | |
| Generic ExCPU | |
| Semigroup ExCPU | |
| Monoid ExCPU | |
| NFData ExCPU | |
Defined in PlutusCore.Evaluation.Machine.ExMemory | |
| ToJSON ExCPU | |
| FromJSON ExCPU | |
| NoThunks ExCPU | |
| Pretty ExCPU | |
| Lift ExCPU | |
| PrettyBy config ExCPU | |
| type Rep ExCPU | |
Defined in PlutusCore.Evaluation.Machine.ExMemory type Rep ExCPU = D1 ('MetaData "ExCPU" "PlutusCore.Evaluation.Machine.ExMemory" "plutus-core-1.0.0.1-AYZ1DL3hDMt58i5HNUtSdG" 'True) (C1 ('MetaCons "ExCPU" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 CostingInteger))) | |
Counts size in machine words.
Constructors
| ExMemory CostingInteger |