{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE RoleAnnotations #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -Wno-orphans #-}

module Cardano.Ledger.Shelley.Forecast (
  ShelleyForecast (..),
  mkShelleyForecast,
  sfPoolDistrL,
  sfMaxBlockHeaderSizeL,
  sfMaxBlockBodySizeL,
  sfProtocolVersionL,
  sfGenDelegsL,
  sfDecentralizationL,
  sfExtraEntropyL,
) where

import Cardano.Ledger.BaseTypes (
  Nonce,
  ProtVer,
  UnitInterval,
 )
import Cardano.Ledger.Core
import Cardano.Ledger.Keys (GenDelegs)
import Cardano.Ledger.Shelley.API.Forecast (
  EraForecast (..),
  ShelleyEraForecast (..),
  Timeline (..),
 )
import Cardano.Ledger.Shelley.Core (EraGov)
import Cardano.Ledger.Shelley.Era (ShelleyEra)
import Cardano.Ledger.Shelley.Governance ()
import Cardano.Ledger.Shelley.LedgerState (
  NewEpochState (..),
  curPParamsEpochStateL,
  dsGenDelegsL,
  esLStateL,
  lsCertStateL,
  nesEsL,
  nesPdL,
 )
import Cardano.Ledger.Shelley.Rules ()
import Cardano.Ledger.Shelley.State.CertState ()
import Cardano.Ledger.State (EraCertState (..), PoolDistr (..))
import Control.DeepSeq (NFData)
import Data.Word (Word16, Word32)
import GHC.Generics (Generic)
import Lens.Micro (Lens', lens, (^.))
import NoThunks.Class (NoThunks (..))

-- | Forecast data for TPraos eras.
data ShelleyForecast (t :: Timeline) era = ShelleyForecast
  { forall (t :: Timeline) era. ShelleyForecast t era -> PoolDistr
sfPoolDistr :: !PoolDistr
  , forall (t :: Timeline) era. ShelleyForecast t era -> Word16
sfMaxBlockHeaderSize :: !Word16
  , forall (t :: Timeline) era. ShelleyForecast t era -> Word32
sfMaxBlockBodySize :: !Word32
  , forall (t :: Timeline) era. ShelleyForecast t era -> ProtVer
sfProtocolVersion :: !ProtVer
  , forall (t :: Timeline) era. ShelleyForecast t era -> GenDelegs
sfGenDelegs :: !GenDelegs
  , forall (t :: Timeline) era. ShelleyForecast t era -> UnitInterval
sfDecentralization :: !UnitInterval
  , forall (t :: Timeline) era. ShelleyForecast t era -> Nonce
sfExtraEntropy :: !Nonce
  }
  deriving (ShelleyForecast t era -> ShelleyForecast t era -> Bool
(ShelleyForecast t era -> ShelleyForecast t era -> Bool)
-> (ShelleyForecast t era -> ShelleyForecast t era -> Bool)
-> Eq (ShelleyForecast t era)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall (t :: Timeline) era.
ShelleyForecast t era -> ShelleyForecast t era -> Bool
$c== :: forall (t :: Timeline) era.
ShelleyForecast t era -> ShelleyForecast t era -> Bool
== :: ShelleyForecast t era -> ShelleyForecast t era -> Bool
$c/= :: forall (t :: Timeline) era.
ShelleyForecast t era -> ShelleyForecast t era -> Bool
/= :: ShelleyForecast t era -> ShelleyForecast t era -> Bool
Eq, Int -> ShelleyForecast t era -> ShowS
[ShelleyForecast t era] -> ShowS
ShelleyForecast t era -> String
(Int -> ShelleyForecast t era -> ShowS)
-> (ShelleyForecast t era -> String)
-> ([ShelleyForecast t era] -> ShowS)
-> Show (ShelleyForecast t era)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall (t :: Timeline) era. Int -> ShelleyForecast t era -> ShowS
forall (t :: Timeline) era. [ShelleyForecast t era] -> ShowS
forall (t :: Timeline) era. ShelleyForecast t era -> String
$cshowsPrec :: forall (t :: Timeline) era. Int -> ShelleyForecast t era -> ShowS
showsPrec :: Int -> ShelleyForecast t era -> ShowS
$cshow :: forall (t :: Timeline) era. ShelleyForecast t era -> String
show :: ShelleyForecast t era -> String
$cshowList :: forall (t :: Timeline) era. [ShelleyForecast t era] -> ShowS
showList :: [ShelleyForecast t era] -> ShowS
Show, (forall x. ShelleyForecast t era -> Rep (ShelleyForecast t era) x)
-> (forall x.
    Rep (ShelleyForecast t era) x -> ShelleyForecast t era)
-> Generic (ShelleyForecast t era)
forall x. Rep (ShelleyForecast t era) x -> ShelleyForecast t era
forall x. ShelleyForecast t era -> Rep (ShelleyForecast t era) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (t :: Timeline) era x.
Rep (ShelleyForecast t era) x -> ShelleyForecast t era
forall (t :: Timeline) era x.
ShelleyForecast t era -> Rep (ShelleyForecast t era) x
$cfrom :: forall (t :: Timeline) era x.
ShelleyForecast t era -> Rep (ShelleyForecast t era) x
from :: forall x. ShelleyForecast t era -> Rep (ShelleyForecast t era) x
$cto :: forall (t :: Timeline) era x.
Rep (ShelleyForecast t era) x -> ShelleyForecast t era
to :: forall x. Rep (ShelleyForecast t era) x -> ShelleyForecast t era
Generic)

type role ShelleyForecast phantom phantom

instance NFData (ShelleyForecast t era)

instance NoThunks (ShelleyForecast t era)

-- | Helper to build a 'ShelleyForecast' from any TPraos-era 'NewEpochState'.
mkShelleyForecast ::
  (AtMostEra "Alonzo" era, EraGov era, EraCertState era) =>
  NewEpochState era ->
  ShelleyForecast t era
mkShelleyForecast :: forall era (t :: Timeline).
(AtMostEra "Alonzo" era, EraGov era, EraCertState era) =>
NewEpochState era -> ShelleyForecast t era
mkShelleyForecast NewEpochState era
nes =
  ShelleyForecast
    { sfPoolDistr :: PoolDistr
sfPoolDistr = NewEpochState era
nes NewEpochState era
-> Getting PoolDistr (NewEpochState era) PoolDistr -> PoolDistr
forall s a. s -> Getting a s a -> a
^. Getting PoolDistr (NewEpochState era) PoolDistr
forall era (f :: * -> *).
Functor f =>
(PoolDistr -> f PoolDistr)
-> NewEpochState era -> f (NewEpochState era)
nesPdL
    , sfMaxBlockHeaderSize :: Word16
sfMaxBlockHeaderSize = NewEpochState era
nes NewEpochState era
-> Getting Word16 (NewEpochState era) Word16 -> Word16
forall s a. s -> Getting a s a -> a
^. (EpochState era -> Const Word16 (EpochState era))
-> NewEpochState era -> Const Word16 (NewEpochState era)
forall era (f :: * -> *).
Functor f =>
(EpochState era -> f (EpochState era))
-> NewEpochState era -> f (NewEpochState era)
nesEsL ((EpochState era -> Const Word16 (EpochState era))
 -> NewEpochState era -> Const Word16 (NewEpochState era))
-> ((Word16 -> Const Word16 Word16)
    -> EpochState era -> Const Word16 (EpochState era))
-> Getting Word16 (NewEpochState era) Word16
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (PParams era -> Const Word16 (PParams era))
-> EpochState era -> Const Word16 (EpochState era)
forall era. EraGov era => Lens' (EpochState era) (PParams era)
Lens' (EpochState era) (PParams era)
curPParamsEpochStateL ((PParams era -> Const Word16 (PParams era))
 -> EpochState era -> Const Word16 (EpochState era))
-> ((Word16 -> Const Word16 Word16)
    -> PParams era -> Const Word16 (PParams era))
-> (Word16 -> Const Word16 Word16)
-> EpochState era
-> Const Word16 (EpochState era)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Word16 -> Const Word16 Word16)
-> PParams era -> Const Word16 (PParams era)
forall era. EraPParams era => Lens' (PParams era) Word16
Lens' (PParams era) Word16
ppMaxBHSizeL
    , sfMaxBlockBodySize :: Word32
sfMaxBlockBodySize = NewEpochState era
nes NewEpochState era
-> Getting Word32 (NewEpochState era) Word32 -> Word32
forall s a. s -> Getting a s a -> a
^. (EpochState era -> Const Word32 (EpochState era))
-> NewEpochState era -> Const Word32 (NewEpochState era)
forall era (f :: * -> *).
Functor f =>
(EpochState era -> f (EpochState era))
-> NewEpochState era -> f (NewEpochState era)
nesEsL ((EpochState era -> Const Word32 (EpochState era))
 -> NewEpochState era -> Const Word32 (NewEpochState era))
-> ((Word32 -> Const Word32 Word32)
    -> EpochState era -> Const Word32 (EpochState era))
-> Getting Word32 (NewEpochState era) Word32
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (PParams era -> Const Word32 (PParams era))
-> EpochState era -> Const Word32 (EpochState era)
forall era. EraGov era => Lens' (EpochState era) (PParams era)
Lens' (EpochState era) (PParams era)
curPParamsEpochStateL ((PParams era -> Const Word32 (PParams era))
 -> EpochState era -> Const Word32 (EpochState era))
-> ((Word32 -> Const Word32 Word32)
    -> PParams era -> Const Word32 (PParams era))
-> (Word32 -> Const Word32 Word32)
-> EpochState era
-> Const Word32 (EpochState era)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Word32 -> Const Word32 Word32)
-> PParams era -> Const Word32 (PParams era)
forall era. EraPParams era => Lens' (PParams era) Word32
Lens' (PParams era) Word32
ppMaxBBSizeL
    , sfProtocolVersion :: ProtVer
sfProtocolVersion = NewEpochState era
nes NewEpochState era
-> Getting ProtVer (NewEpochState era) ProtVer -> ProtVer
forall s a. s -> Getting a s a -> a
^. (EpochState era -> Const ProtVer (EpochState era))
-> NewEpochState era -> Const ProtVer (NewEpochState era)
forall era (f :: * -> *).
Functor f =>
(EpochState era -> f (EpochState era))
-> NewEpochState era -> f (NewEpochState era)
nesEsL ((EpochState era -> Const ProtVer (EpochState era))
 -> NewEpochState era -> Const ProtVer (NewEpochState era))
-> ((ProtVer -> Const ProtVer ProtVer)
    -> EpochState era -> Const ProtVer (EpochState era))
-> Getting ProtVer (NewEpochState era) ProtVer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (PParams era -> Const ProtVer (PParams era))
-> EpochState era -> Const ProtVer (EpochState era)
forall era. EraGov era => Lens' (EpochState era) (PParams era)
Lens' (EpochState era) (PParams era)
curPParamsEpochStateL ((PParams era -> Const ProtVer (PParams era))
 -> EpochState era -> Const ProtVer (EpochState era))
-> ((ProtVer -> Const ProtVer ProtVer)
    -> PParams era -> Const ProtVer (PParams era))
-> (ProtVer -> Const ProtVer ProtVer)
-> EpochState era
-> Const ProtVer (EpochState era)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ProtVer -> Const ProtVer ProtVer)
-> PParams era -> Const ProtVer (PParams era)
forall era. EraPParams era => Lens' (PParams era) ProtVer
Lens' (PParams era) ProtVer
ppProtocolVersionL
    , sfGenDelegs :: GenDelegs
sfGenDelegs = NewEpochState era
nes NewEpochState era
-> Getting GenDelegs (NewEpochState era) GenDelegs -> GenDelegs
forall s a. s -> Getting a s a -> a
^. (EpochState era -> Const GenDelegs (EpochState era))
-> NewEpochState era -> Const GenDelegs (NewEpochState era)
forall era (f :: * -> *).
Functor f =>
(EpochState era -> f (EpochState era))
-> NewEpochState era -> f (NewEpochState era)
nesEsL ((EpochState era -> Const GenDelegs (EpochState era))
 -> NewEpochState era -> Const GenDelegs (NewEpochState era))
-> ((GenDelegs -> Const GenDelegs GenDelegs)
    -> EpochState era -> Const GenDelegs (EpochState era))
-> Getting GenDelegs (NewEpochState era) GenDelegs
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (LedgerState era -> Const GenDelegs (LedgerState era))
-> EpochState era -> Const GenDelegs (EpochState era)
forall era (f :: * -> *).
Functor f =>
(LedgerState era -> f (LedgerState era))
-> EpochState era -> f (EpochState era)
esLStateL ((LedgerState era -> Const GenDelegs (LedgerState era))
 -> EpochState era -> Const GenDelegs (EpochState era))
-> ((GenDelegs -> Const GenDelegs GenDelegs)
    -> LedgerState era -> Const GenDelegs (LedgerState era))
-> (GenDelegs -> Const GenDelegs GenDelegs)
-> EpochState era
-> Const GenDelegs (EpochState era)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (CertState era -> Const GenDelegs (CertState era))
-> LedgerState era -> Const GenDelegs (LedgerState era)
forall era (f :: * -> *).
Functor f =>
(CertState era -> f (CertState era))
-> LedgerState era -> f (LedgerState era)
lsCertStateL ((CertState era -> Const GenDelegs (CertState era))
 -> LedgerState era -> Const GenDelegs (LedgerState era))
-> ((GenDelegs -> Const GenDelegs GenDelegs)
    -> CertState era -> Const GenDelegs (CertState era))
-> (GenDelegs -> Const GenDelegs GenDelegs)
-> LedgerState era
-> Const GenDelegs (LedgerState era)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (DState era -> Const GenDelegs (DState era))
-> CertState era -> Const GenDelegs (CertState era)
forall era. EraCertState era => Lens' (CertState era) (DState era)
Lens' (CertState era) (DState era)
certDStateL ((DState era -> Const GenDelegs (DState era))
 -> CertState era -> Const GenDelegs (CertState era))
-> ((GenDelegs -> Const GenDelegs GenDelegs)
    -> DState era -> Const GenDelegs (DState era))
-> (GenDelegs -> Const GenDelegs GenDelegs)
-> CertState era
-> Const GenDelegs (CertState era)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (GenDelegs -> Const GenDelegs GenDelegs)
-> DState era -> Const GenDelegs (DState era)
forall era (f :: * -> *).
Functor f =>
(GenDelegs -> f GenDelegs) -> DState era -> f (DState era)
dsGenDelegsL
    , sfDecentralization :: UnitInterval
sfDecentralization = NewEpochState era
nes NewEpochState era
-> Getting UnitInterval (NewEpochState era) UnitInterval
-> UnitInterval
forall s a. s -> Getting a s a -> a
^. (EpochState era -> Const UnitInterval (EpochState era))
-> NewEpochState era -> Const UnitInterval (NewEpochState era)
forall era (f :: * -> *).
Functor f =>
(EpochState era -> f (EpochState era))
-> NewEpochState era -> f (NewEpochState era)
nesEsL ((EpochState era -> Const UnitInterval (EpochState era))
 -> NewEpochState era -> Const UnitInterval (NewEpochState era))
-> ((UnitInterval -> Const UnitInterval UnitInterval)
    -> EpochState era -> Const UnitInterval (EpochState era))
-> Getting UnitInterval (NewEpochState era) UnitInterval
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (PParams era -> Const UnitInterval (PParams era))
-> EpochState era -> Const UnitInterval (EpochState era)
forall era. EraGov era => Lens' (EpochState era) (PParams era)
Lens' (EpochState era) (PParams era)
curPParamsEpochStateL ((PParams era -> Const UnitInterval (PParams era))
 -> EpochState era -> Const UnitInterval (EpochState era))
-> ((UnitInterval -> Const UnitInterval UnitInterval)
    -> PParams era -> Const UnitInterval (PParams era))
-> (UnitInterval -> Const UnitInterval UnitInterval)
-> EpochState era
-> Const UnitInterval (EpochState era)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (UnitInterval -> Const UnitInterval UnitInterval)
-> PParams era -> Const UnitInterval (PParams era)
forall era.
EraPParams era =>
SimpleGetter (PParams era) UnitInterval
SimpleGetter (PParams era) UnitInterval
ppDG
    , sfExtraEntropy :: Nonce
sfExtraEntropy = NewEpochState era
nes NewEpochState era
-> Getting Nonce (NewEpochState era) Nonce -> Nonce
forall s a. s -> Getting a s a -> a
^. (EpochState era -> Const Nonce (EpochState era))
-> NewEpochState era -> Const Nonce (NewEpochState era)
forall era (f :: * -> *).
Functor f =>
(EpochState era -> f (EpochState era))
-> NewEpochState era -> f (NewEpochState era)
nesEsL ((EpochState era -> Const Nonce (EpochState era))
 -> NewEpochState era -> Const Nonce (NewEpochState era))
-> ((Nonce -> Const Nonce Nonce)
    -> EpochState era -> Const Nonce (EpochState era))
-> Getting Nonce (NewEpochState era) Nonce
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (PParams era -> Const Nonce (PParams era))
-> EpochState era -> Const Nonce (EpochState era)
forall era. EraGov era => Lens' (EpochState era) (PParams era)
Lens' (EpochState era) (PParams era)
curPParamsEpochStateL ((PParams era -> Const Nonce (PParams era))
 -> EpochState era -> Const Nonce (EpochState era))
-> ((Nonce -> Const Nonce Nonce)
    -> PParams era -> Const Nonce (PParams era))
-> (Nonce -> Const Nonce Nonce)
-> EpochState era
-> Const Nonce (EpochState era)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Nonce -> Const Nonce Nonce)
-> PParams era -> Const Nonce (PParams era)
forall era.
(EraPParams era, AtMostEra "Alonzo" era) =>
Lens' (PParams era) Nonce
Lens' (PParams era) Nonce
ppExtraEntropyL
    }

sfPoolDistrL :: Lens' (ShelleyForecast t era) PoolDistr
sfPoolDistrL :: forall (t :: Timeline) era (f :: * -> *).
Functor f =>
(PoolDistr -> f PoolDistr)
-> ShelleyForecast t era -> f (ShelleyForecast t era)
sfPoolDistrL = (ShelleyForecast t era -> PoolDistr)
-> (ShelleyForecast t era -> PoolDistr -> ShelleyForecast t era)
-> Lens
     (ShelleyForecast t era) (ShelleyForecast t era) PoolDistr PoolDistr
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens ShelleyForecast t era -> PoolDistr
forall (t :: Timeline) era. ShelleyForecast t era -> PoolDistr
sfPoolDistr ((ShelleyForecast t era -> PoolDistr -> ShelleyForecast t era)
 -> Lens
      (ShelleyForecast t era)
      (ShelleyForecast t era)
      PoolDistr
      PoolDistr)
-> (ShelleyForecast t era -> PoolDistr -> ShelleyForecast t era)
-> Lens
     (ShelleyForecast t era) (ShelleyForecast t era) PoolDistr PoolDistr
forall a b. (a -> b) -> a -> b
$ \ShelleyForecast t era
s PoolDistr
x -> ShelleyForecast t era
s {sfPoolDistr = x}

sfMaxBlockHeaderSizeL :: Lens' (ShelleyForecast t era) Word16
sfMaxBlockHeaderSizeL :: forall (t :: Timeline) era (f :: * -> *).
Functor f =>
(Word16 -> f Word16)
-> ShelleyForecast t era -> f (ShelleyForecast t era)
sfMaxBlockHeaderSizeL = (ShelleyForecast t era -> Word16)
-> (ShelleyForecast t era -> Word16 -> ShelleyForecast t era)
-> Lens
     (ShelleyForecast t era) (ShelleyForecast t era) Word16 Word16
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens ShelleyForecast t era -> Word16
forall (t :: Timeline) era. ShelleyForecast t era -> Word16
sfMaxBlockHeaderSize ((ShelleyForecast t era -> Word16 -> ShelleyForecast t era)
 -> Lens
      (ShelleyForecast t era) (ShelleyForecast t era) Word16 Word16)
-> (ShelleyForecast t era -> Word16 -> ShelleyForecast t era)
-> Lens
     (ShelleyForecast t era) (ShelleyForecast t era) Word16 Word16
forall a b. (a -> b) -> a -> b
$ \ShelleyForecast t era
s Word16
x -> ShelleyForecast t era
s {sfMaxBlockHeaderSize = x}

sfMaxBlockBodySizeL :: Lens' (ShelleyForecast t era) Word32
sfMaxBlockBodySizeL :: forall (t :: Timeline) era (f :: * -> *).
Functor f =>
(Word32 -> f Word32)
-> ShelleyForecast t era -> f (ShelleyForecast t era)
sfMaxBlockBodySizeL = (ShelleyForecast t era -> Word32)
-> (ShelleyForecast t era -> Word32 -> ShelleyForecast t era)
-> Lens
     (ShelleyForecast t era) (ShelleyForecast t era) Word32 Word32
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens ShelleyForecast t era -> Word32
forall (t :: Timeline) era. ShelleyForecast t era -> Word32
sfMaxBlockBodySize ((ShelleyForecast t era -> Word32 -> ShelleyForecast t era)
 -> Lens
      (ShelleyForecast t era) (ShelleyForecast t era) Word32 Word32)
-> (ShelleyForecast t era -> Word32 -> ShelleyForecast t era)
-> Lens
     (ShelleyForecast t era) (ShelleyForecast t era) Word32 Word32
forall a b. (a -> b) -> a -> b
$ \ShelleyForecast t era
s Word32
x -> ShelleyForecast t era
s {sfMaxBlockBodySize = x}

sfProtocolVersionL :: Lens' (ShelleyForecast t era) ProtVer
sfProtocolVersionL :: forall (t :: Timeline) era (f :: * -> *).
Functor f =>
(ProtVer -> f ProtVer)
-> ShelleyForecast t era -> f (ShelleyForecast t era)
sfProtocolVersionL = (ShelleyForecast t era -> ProtVer)
-> (ShelleyForecast t era -> ProtVer -> ShelleyForecast t era)
-> Lens
     (ShelleyForecast t era) (ShelleyForecast t era) ProtVer ProtVer
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens ShelleyForecast t era -> ProtVer
forall (t :: Timeline) era. ShelleyForecast t era -> ProtVer
sfProtocolVersion ((ShelleyForecast t era -> ProtVer -> ShelleyForecast t era)
 -> Lens
      (ShelleyForecast t era) (ShelleyForecast t era) ProtVer ProtVer)
-> (ShelleyForecast t era -> ProtVer -> ShelleyForecast t era)
-> Lens
     (ShelleyForecast t era) (ShelleyForecast t era) ProtVer ProtVer
forall a b. (a -> b) -> a -> b
$ \ShelleyForecast t era
s ProtVer
x -> ShelleyForecast t era
s {sfProtocolVersion = x}

sfGenDelegsL :: Lens' (ShelleyForecast t era) GenDelegs
sfGenDelegsL :: forall (t :: Timeline) era (f :: * -> *).
Functor f =>
(GenDelegs -> f GenDelegs)
-> ShelleyForecast t era -> f (ShelleyForecast t era)
sfGenDelegsL = (ShelleyForecast t era -> GenDelegs)
-> (ShelleyForecast t era -> GenDelegs -> ShelleyForecast t era)
-> Lens
     (ShelleyForecast t era) (ShelleyForecast t era) GenDelegs GenDelegs
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens ShelleyForecast t era -> GenDelegs
forall (t :: Timeline) era. ShelleyForecast t era -> GenDelegs
sfGenDelegs ((ShelleyForecast t era -> GenDelegs -> ShelleyForecast t era)
 -> Lens
      (ShelleyForecast t era)
      (ShelleyForecast t era)
      GenDelegs
      GenDelegs)
-> (ShelleyForecast t era -> GenDelegs -> ShelleyForecast t era)
-> Lens
     (ShelleyForecast t era) (ShelleyForecast t era) GenDelegs GenDelegs
forall a b. (a -> b) -> a -> b
$ \ShelleyForecast t era
s GenDelegs
x -> ShelleyForecast t era
s {sfGenDelegs = x}

sfDecentralizationL :: Lens' (ShelleyForecast t era) UnitInterval
sfDecentralizationL :: forall (t :: Timeline) era (f :: * -> *).
Functor f =>
(UnitInterval -> f UnitInterval)
-> ShelleyForecast t era -> f (ShelleyForecast t era)
sfDecentralizationL = (ShelleyForecast t era -> UnitInterval)
-> (ShelleyForecast t era -> UnitInterval -> ShelleyForecast t era)
-> Lens
     (ShelleyForecast t era)
     (ShelleyForecast t era)
     UnitInterval
     UnitInterval
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens ShelleyForecast t era -> UnitInterval
forall (t :: Timeline) era. ShelleyForecast t era -> UnitInterval
sfDecentralization ((ShelleyForecast t era -> UnitInterval -> ShelleyForecast t era)
 -> Lens
      (ShelleyForecast t era)
      (ShelleyForecast t era)
      UnitInterval
      UnitInterval)
-> (ShelleyForecast t era -> UnitInterval -> ShelleyForecast t era)
-> Lens
     (ShelleyForecast t era)
     (ShelleyForecast t era)
     UnitInterval
     UnitInterval
forall a b. (a -> b) -> a -> b
$ \ShelleyForecast t era
s UnitInterval
x -> ShelleyForecast t era
s {sfDecentralization = x}

sfExtraEntropyL :: Lens' (ShelleyForecast t era) Nonce
sfExtraEntropyL :: forall (t :: Timeline) era (f :: * -> *).
Functor f =>
(Nonce -> f Nonce)
-> ShelleyForecast t era -> f (ShelleyForecast t era)
sfExtraEntropyL = (ShelleyForecast t era -> Nonce)
-> (ShelleyForecast t era -> Nonce -> ShelleyForecast t era)
-> Lens (ShelleyForecast t era) (ShelleyForecast t era) Nonce Nonce
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens ShelleyForecast t era -> Nonce
forall (t :: Timeline) era. ShelleyForecast t era -> Nonce
sfExtraEntropy ((ShelleyForecast t era -> Nonce -> ShelleyForecast t era)
 -> Lens
      (ShelleyForecast t era) (ShelleyForecast t era) Nonce Nonce)
-> (ShelleyForecast t era -> Nonce -> ShelleyForecast t era)
-> Lens (ShelleyForecast t era) (ShelleyForecast t era) Nonce Nonce
forall a b. (a -> b) -> a -> b
$ \ShelleyForecast t era
s Nonce
x -> ShelleyForecast t era
s {sfExtraEntropy = x}

instance EraForecast ShelleyEra where
  type Forecast t ShelleyEra = ShelleyForecast t ShelleyEra
  mkForecast :: forall (t :: Timeline).
NewEpochState ShelleyEra -> Forecast t ShelleyEra
mkForecast = NewEpochState ShelleyEra -> Forecast t ShelleyEra
NewEpochState ShelleyEra -> ShelleyForecast t ShelleyEra
forall era (t :: Timeline).
(AtMostEra "Alonzo" era, EraGov era, EraCertState era) =>
NewEpochState era -> ShelleyForecast t era
mkShelleyForecast
  poolDistrForecastL :: forall (t :: Timeline). Lens' (Forecast t ShelleyEra) PoolDistr
poolDistrForecastL = (PoolDistr -> f PoolDistr)
-> Forecast t ShelleyEra -> f (Forecast t ShelleyEra)
(PoolDistr -> f PoolDistr)
-> ShelleyForecast t ShelleyEra -> f (ShelleyForecast t ShelleyEra)
forall (t :: Timeline) era (f :: * -> *).
Functor f =>
(PoolDistr -> f PoolDistr)
-> ShelleyForecast t era -> f (ShelleyForecast t era)
sfPoolDistrL
  maxBlockHeaderSizeForecastL :: forall (t :: Timeline). Lens' (Forecast t ShelleyEra) Word16
maxBlockHeaderSizeForecastL = (Word16 -> f Word16)
-> Forecast t ShelleyEra -> f (Forecast t ShelleyEra)
(Word16 -> f Word16)
-> ShelleyForecast t ShelleyEra -> f (ShelleyForecast t ShelleyEra)
forall (t :: Timeline) era (f :: * -> *).
Functor f =>
(Word16 -> f Word16)
-> ShelleyForecast t era -> f (ShelleyForecast t era)
sfMaxBlockHeaderSizeL
  maxBlockBodySizeForecastL :: forall (t :: Timeline). Lens' (Forecast t ShelleyEra) Word32
maxBlockBodySizeForecastL = (Word32 -> f Word32)
-> Forecast t ShelleyEra -> f (Forecast t ShelleyEra)
(Word32 -> f Word32)
-> ShelleyForecast t ShelleyEra -> f (ShelleyForecast t ShelleyEra)
forall (t :: Timeline) era (f :: * -> *).
Functor f =>
(Word32 -> f Word32)
-> ShelleyForecast t era -> f (ShelleyForecast t era)
sfMaxBlockBodySizeL
  protocolVersionForecastL :: forall (t :: Timeline). Lens' (Forecast t ShelleyEra) ProtVer
protocolVersionForecastL = (ProtVer -> f ProtVer)
-> Forecast t ShelleyEra -> f (Forecast t ShelleyEra)
(ProtVer -> f ProtVer)
-> ShelleyForecast t ShelleyEra -> f (ShelleyForecast t ShelleyEra)
forall (t :: Timeline) era (f :: * -> *).
Functor f =>
(ProtVer -> f ProtVer)
-> ShelleyForecast t era -> f (ShelleyForecast t era)
sfProtocolVersionL

instance ShelleyEraForecast ShelleyEra where
  genDelegsForecastL :: forall (t :: Timeline). Lens' (Forecast t ShelleyEra) GenDelegs
genDelegsForecastL = (GenDelegs -> f GenDelegs)
-> Forecast t ShelleyEra -> f (Forecast t ShelleyEra)
(GenDelegs -> f GenDelegs)
-> ShelleyForecast t ShelleyEra -> f (ShelleyForecast t ShelleyEra)
forall (t :: Timeline) era (f :: * -> *).
Functor f =>
(GenDelegs -> f GenDelegs)
-> ShelleyForecast t era -> f (ShelleyForecast t era)
sfGenDelegsL
  decentralizationForecastL :: forall (t :: Timeline). Lens' (Forecast t ShelleyEra) UnitInterval
decentralizationForecastL = (UnitInterval -> f UnitInterval)
-> Forecast t ShelleyEra -> f (Forecast t ShelleyEra)
(UnitInterval -> f UnitInterval)
-> ShelleyForecast t ShelleyEra -> f (ShelleyForecast t ShelleyEra)
forall (t :: Timeline) era (f :: * -> *).
Functor f =>
(UnitInterval -> f UnitInterval)
-> ShelleyForecast t era -> f (ShelleyForecast t era)
sfDecentralizationL
  extraEntropyForecastL :: forall (t :: Timeline). Lens' (Forecast t ShelleyEra) Nonce
extraEntropyForecastL = (Nonce -> f Nonce)
-> Forecast t ShelleyEra -> f (Forecast t ShelleyEra)
(Nonce -> f Nonce)
-> ShelleyForecast t ShelleyEra -> f (ShelleyForecast t ShelleyEra)
forall (t :: Timeline) era (f :: * -> *).
Functor f =>
(Nonce -> f Nonce)
-> ShelleyForecast t era -> f (ShelleyForecast t era)
sfExtraEntropyL