cardano-ledger-core-1.14.0.0: Core components of Cardano ledgers from the Shelley release on.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Cardano.Ledger.Era

Description

Support for multiple (Shelley-based) eras in the ledger.

Synopsis

Documentation

class (Crypto (EraCrypto era), Typeable era, KnownNat (ProtVerLow era), KnownNat (ProtVerHigh era), ProtVerLow era <= ProtVerHigh era, MinVersion <= ProtVerLow era, MinVersion <= ProtVerHigh era, CmpNat (ProtVerLow era) MaxVersion ~ 'LT, CmpNat (ProtVerHigh era) MaxVersion ~ 'LT, ProtVerLow era <= MaxVersion, ProtVerHigh era <= MaxVersion) ⇒ Era era where Source #

Associated Types

type EraCrypto era ∷ Type Source #

type PreviousEra era = (r ∷ Type) | r → era Source #

Map an era to its predecessor.

For example:

type instance PreviousEra (AllegraEra c) = ShelleyEra c

type ProtVerLow era ∷ Nat Source #

Lowest major protocol version for this era

type ProtVerHigh era ∷ Nat Source #

Highest major protocol version for this era. By default se to ProtVerLow

type ProtVerHigh era = ProtVerLow era

Methods

eraNameString Source #

Textual name of the current era.

Designed to be used with TypeApplications:

>>> eraName @(ByronEra StandardCrypto)
Byron

Instances

Instances details
Crypto c ⇒ Era (ByronEra c) Source # 
Instance details

Defined in Cardano.Ledger.Core.Era

Associated Types

type EraCrypto (ByronEra c) Source #

type PreviousEra (ByronEra c) = (r ∷ Type) Source #

type ProtVerLow (ByronEra c) ∷ Nat Source #

type ProtVerHigh (ByronEra c) ∷ Nat Source #

Methods

eraNameString Source #

getTxOutAddrEraTxOut era ⇒ TxOut era → Addr (EraCrypto era) Source #

Deprecated: In favor of addrTxOutL

getTxOutCompactAddrEraTxOut era ⇒ TxOut era → CompactAddr (EraCrypto era) Source #

Deprecated: In favor of compactAddrTxOutL

getTxOutEitherAddrEraTxOut era ⇒ TxOut era → Either (Addr (EraCrypto era)) (CompactAddr (EraCrypto era)) Source #

Deprecated: In favor of addrEitherTxOutL

getTxOutBootstrapAddressEraTxOut era ⇒ TxOut era → Maybe (BootstrapAddress (EraCrypto era)) Source #

Deprecated: In favor of bootAddrTxOutF

Get the Bootsrap address from the TxOut. Returns Nothing if it is a Shelley address or newer

getAllTxInputsEraTxBody era ⇒ TxBody era → Set (TxIn (EraCrypto era)) Source #

The validity of any individual block depends only on a subset of the UTxO stored in the ledger state. The consensus layer makes use of this fact, and uses the function below to to retrieve the needed UTxO from disk and present only those to the ledger. It is therefore neccessary that this function account for all the different types of inputs inside a transaction.

type family TranslationContext era ∷ Type Source #

Per-era context used for TranslateEra.

This context will be passed to the translation instances of all types of that particular era. In practice, most instances won't need the context, but this approach makes the translation composable (as opposed to having a separate context per type).

class (Era era, Era (PreviousEra era)) ⇒ TranslateEra era f where Source #

Translation of types between eras, e.g., from Shelley to Allegra.

When era is just a phantom type parameter, an empty standalone deriving can be used:

newtype Foo era = Foo Int

instance TranslateEra (Allegra c) Foo

Note that one could use DerivingAnyClass (deriving (TranslateEra (Allegra c))), but this would introduce an undesired coupling between the era-parametric type and (a) particular era(s). The intention is to have a module with orphan instances per era.

In most cases, the era parameter won't be phantom, and a manual instance will have to be written:

newtype Bar era = Bar (TxBody era)

instance CC.Crypto c => TranslateEra (Allegra c) Bar where
    translateEra ctxt = Bar <$> translateEra ctxt

-- With the following instance being in scope:
instance CC.Crypto c => TranslatEra (Allegra c) TxBody

Note: we use PreviousEra instead of NextEra as an era definitely knows its predecessor, but not necessarily its successor. Moreover, one could argue that it makes more sense to define the translation from era A to era B where era B is defined, than where era A is defined.

Minimal complete definition

Nothing

Associated Types

type TranslationError era f ∷ Type Source #

Most translations should be infallible (default instance), but we leave the door open for partial translations.

For a partial translation, override the default type to be () or a concrete error type.

type TranslationError era f = Void

Methods

translateEraTranslationContext era → f (PreviousEra era) → Except (TranslationError era f) (f era) Source #

Translate a type f parameterised by the era from an era to the era after it.

The translation is a given the translation context of era.

A default instance is provided for when the two types are Coercible.

default translateEra ∷ (Coercible (f (PreviousEra era)) (f era), TranslationContext era ~ ()) ⇒ TranslationContext era → f (PreviousEra era) → Except (TranslationError era f) (f era) Source #

translateEra' ∷ (TranslateEra era f, TranslationError era f ~ Void) ⇒ TranslationContext era → f (PreviousEra era) → f era Source #

Variant of translateEra for when TranslationError is Void and the translation thus cannot fail.

translateEraMaybe ∷ (TranslateEra era f, TranslationError era f ~ ()) ⇒ TranslationContext era → f (PreviousEra era) → Maybe (f era) Source #

Variant of translateEra for when TranslationError is (), converting the result to a Maybe.

class (EraTx era, Eq (TxSeq era), Show (TxSeq era), EncCBORGroup (TxSeq era), DecCBOR (Annotator (TxSeq era))) ⇒ EraSegWits era where Source #

Indicates that an era supports segregated witnessing.

This class embodies an isomorphism between 'TxSeq era' and 'StrictSeq (Tx era)', witnessed by fromTxSeq and toTxSeq.

Associated Types

type TxSeq era = (r ∷ Type) | r → era Source #

Methods

fromTxSeqTxSeq era → StrictSeq (Tx era) Source #

toTxSeqStrictSeq (Tx era) → TxSeq era Source #

hashTxSeqTxSeq era → Hash (HASH (EraCrypto era)) EraIndependentBlockBody Source #

Get the block body hash from the TxSeq. Note that this is not a regular "hash the stored bytes" function since the block body hash forms a small Merkle tree.

numSegComponentsWord64 Source #

The number of segregated components