module Ouroboros.Consensus.HardFork.Combinator.Abstract.NoHardForks (
    NoHardForks(..)
  , noHardForksEpochInfo
  ) where

import           Cardano.Slotting.EpochInfo

import           Ouroboros.Consensus.Block
import           Ouroboros.Consensus.Config
import           Ouroboros.Consensus.HardFork.History as History
import           Ouroboros.Consensus.Ledger.Abstract
import           Ouroboros.Consensus.Protocol.Abstract

import           Ouroboros.Consensus.HardFork.Combinator.Abstract.SingleEraBlock
import           Ouroboros.Consensus.HardFork.Combinator.PartialConfig

{-------------------------------------------------------------------------------
  Blocks that don't /have/ any transitions
-------------------------------------------------------------------------------}

class SingleEraBlock blk => NoHardForks blk where
  -- | Extract 'EraParams' from the top-level config
  --
  -- The HFC itself does not care about this, as it must be given the full shape
  -- across /all/ eras.
  getEraParams :: TopLevelConfig blk -> EraParams

  -- | Construct partial consensus config from full consensus config
  --
  -- NOTE: This is basically just losing 'EpochInfo', but that is constant
  -- anyway when we are dealing with a single era.
  toPartialConsensusConfig :: proxy blk
                           -> ConsensusConfig (BlockProtocol blk)
                           -> PartialConsensusConfig (BlockProtocol blk)

  -- | Construct partial ledger config from full ledger config
  --
  -- See also 'toPartialConsensusConfig'
  toPartialLedgerConfig :: proxy blk
                        -> LedgerConfig blk -> PartialLedgerConfig blk

noHardForksEpochInfo :: NoHardForks blk
                     => TopLevelConfig blk -> EpochInfo Identity
noHardForksEpochInfo :: TopLevelConfig blk -> EpochInfo Identity
noHardForksEpochInfo = EpochSize -> EpochInfo Identity
forall (m :: * -> *). Monad m => EpochSize -> EpochInfo m
fixedSizeEpochInfo (EpochSize -> EpochInfo Identity)
-> (TopLevelConfig blk -> EpochSize)
-> TopLevelConfig blk
-> EpochInfo Identity
forall b c a. (b -> c) -> (a -> b) -> a -> c
. EraParams -> EpochSize
History.eraEpochSize (EraParams -> EpochSize)
-> (TopLevelConfig blk -> EraParams)
-> TopLevelConfig blk
-> EpochSize
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TopLevelConfig blk -> EraParams
forall blk. NoHardForks blk => TopLevelConfig blk -> EraParams
getEraParams