Skip to content

Commit

Permalink
Bring back LedgerState patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
jasagredo committed Apr 3, 2024
1 parent 244a150 commit 2e42f5b
Showing 1 changed file with 55 additions and 8 deletions.
63 changes: 55 additions & 8 deletions cardano-api/internal/Cardano/Api/LedgerState.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@
module Cardano.Api.LedgerState
( -- * Initialization / Accumulation
envSecurityParam
, LedgerState ( .. )
, pattern Consensus.LedgerStateByron
, pattern Consensus.LedgerStateShelley
, pattern Consensus.LedgerStateAllegra
, pattern Consensus.LedgerStateMary
, pattern Consensus.LedgerStateAlonzo
, pattern Consensus.LedgerStateBabbage
, pattern Consensus.LedgerStateConway
, LedgerState
( ..
, LedgerStateByron
, LedgerStateShelley
, LedgerStateAllegra
, LedgerStateMary
, LedgerStateAlonzo
, LedgerStateBabbage
, LedgerStateConway
)

, encodeLedgerState
, decodeLedgerState
Expand Down Expand Up @@ -142,6 +144,7 @@ import Cardano.Slotting.Slot (WithOrigin (At, Origin))
import qualified Cardano.Slotting.Slot as Slot
import qualified Ouroboros.Consensus.Block.Abstract as Consensus
import Ouroboros.Consensus.Block.Forging (BlockForging)
import qualified Ouroboros.Consensus.Byron.Ledger as Byron
import qualified Ouroboros.Consensus.Cardano as Consensus
import qualified Ouroboros.Consensus.Cardano.Block as Consensus
import qualified Ouroboros.Consensus.Cardano.CanHardFork as Consensus
Expand All @@ -157,6 +160,7 @@ import qualified Ouroboros.Consensus.Node.ProtocolInfo as Consensus
import Ouroboros.Consensus.Protocol.Abstract (ChainDepState, ConsensusProtocol (..))
import qualified Ouroboros.Consensus.Protocol.Praos.Common as Consensus
import Ouroboros.Consensus.Protocol.Praos.VRF (mkInputVRF, vrfLeaderValue)
import qualified Ouroboros.Consensus.Shelley.HFEras as Shelley
import qualified Ouroboros.Consensus.Shelley.Ledger.Ledger as Shelley
import Ouroboros.Consensus.Storage.Serialisation
import Ouroboros.Consensus.TypeFamilyWrappers (WrapLedgerEvent (WrapLedgerEvent))
Expand Down Expand Up @@ -305,6 +309,49 @@ applyBlock
applyBlock env oldState validationMode
= applyBlock' env oldState validationMode . toConsensusBlock

pattern LedgerStateByron
:: Ledger.LedgerState Byron.ByronBlock
-> LedgerState
pattern LedgerStateByron st <- LedgerState (Consensus.LedgerStateByron st)

pattern LedgerStateShelley
:: Ledger.LedgerState Shelley.StandardShelleyBlock
-> LedgerState
pattern LedgerStateShelley st <- LedgerState (Consensus.LedgerStateShelley st)

pattern LedgerStateAllegra
:: Ledger.LedgerState Shelley.StandardAllegraBlock
-> LedgerState
pattern LedgerStateAllegra st <- LedgerState (Consensus.LedgerStateAllegra st)

pattern LedgerStateMary
:: Ledger.LedgerState Shelley.StandardMaryBlock
-> LedgerState
pattern LedgerStateMary st <- LedgerState (Consensus.LedgerStateMary st)

pattern LedgerStateAlonzo
:: Ledger.LedgerState Shelley.StandardAlonzoBlock
-> LedgerState
pattern LedgerStateAlonzo st <- LedgerState (Consensus.LedgerStateAlonzo st)

pattern LedgerStateBabbage
:: Ledger.LedgerState Shelley.StandardBabbageBlock
-> LedgerState
pattern LedgerStateBabbage st <- LedgerState (Consensus.LedgerStateBabbage st)

pattern LedgerStateConway
:: Ledger.LedgerState Shelley.StandardConwayBlock
-> LedgerState
pattern LedgerStateConway st <- LedgerState (Consensus.LedgerStateConway st)

{-# COMPLETE LedgerStateByron
, LedgerStateShelley
, LedgerStateAllegra
, LedgerStateMary
, LedgerStateAlonzo
, LedgerStateBabbage
, LedgerStateConway #-}

data FoldBlocksError
= FoldBlocksInitialLedgerStateError !InitialLedgerStateError
| FoldBlocksApplyBlockError !LedgerStateError
Expand Down

0 comments on commit 2e42f5b

Please sign in to comment.