{-# LANGUAGE DeriveGeneric              #-}
{-# LANGUAGE DerivingVia                #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}

module Ouroboros.Consensus.Config.SecurityParam (SecurityParam (..)) where

import           Data.Word
import           GHC.Generics (Generic)
import           NoThunks.Class (NoThunks)
import           Quiet

-- | Protocol security parameter
--
-- We interpret this as the number of rollbacks we support.
--
-- i.e., k == 0: we can't roll back at all
--       k == 1: we can roll back at most one block, etc
--
-- NOTE: This talks about the number of /blocks/ we can roll back, not
-- the number of /slots/.
newtype SecurityParam = SecurityParam { SecurityParam -> Word64
maxRollbacks :: Word64 }
  deriving (SecurityParam -> SecurityParam -> Bool
(SecurityParam -> SecurityParam -> Bool)
-> (SecurityParam -> SecurityParam -> Bool) -> Eq SecurityParam
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SecurityParam -> SecurityParam -> Bool
$c/= :: SecurityParam -> SecurityParam -> Bool
== :: SecurityParam -> SecurityParam -> Bool
$c== :: SecurityParam -> SecurityParam -> Bool
Eq, (forall x. SecurityParam -> Rep SecurityParam x)
-> (forall x. Rep SecurityParam x -> SecurityParam)
-> Generic SecurityParam
forall x. Rep SecurityParam x -> SecurityParam
forall x. SecurityParam -> Rep SecurityParam x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SecurityParam x -> SecurityParam
$cfrom :: forall x. SecurityParam -> Rep SecurityParam x
Generic, Context -> SecurityParam -> IO (Maybe ThunkInfo)
Proxy SecurityParam -> String
(Context -> SecurityParam -> IO (Maybe ThunkInfo))
-> (Context -> SecurityParam -> IO (Maybe ThunkInfo))
-> (Proxy SecurityParam -> String)
-> NoThunks SecurityParam
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
showTypeOf :: Proxy SecurityParam -> String
$cshowTypeOf :: Proxy SecurityParam -> String
wNoThunks :: Context -> SecurityParam -> IO (Maybe ThunkInfo)
$cwNoThunks :: Context -> SecurityParam -> IO (Maybe ThunkInfo)
noThunks :: Context -> SecurityParam -> IO (Maybe ThunkInfo)
$cnoThunks :: Context -> SecurityParam -> IO (Maybe ThunkInfo)
NoThunks)
  deriving Int -> SecurityParam -> ShowS
[SecurityParam] -> ShowS
SecurityParam -> String
(Int -> SecurityParam -> ShowS)
-> (SecurityParam -> String)
-> ([SecurityParam] -> ShowS)
-> Show SecurityParam
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SecurityParam] -> ShowS
$cshowList :: [SecurityParam] -> ShowS
show :: SecurityParam -> String
$cshow :: SecurityParam -> String
showsPrec :: Int -> SecurityParam -> ShowS
$cshowsPrec :: Int -> SecurityParam -> ShowS
Show via Quiet SecurityParam