{-# 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
$c== :: SecurityParam -> SecurityParam -> Bool
== :: SecurityParam -> SecurityParam -> Bool
$c/= :: SecurityParam -> SecurityParam -> Bool
/= :: 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
$cfrom :: forall x. SecurityParam -> Rep SecurityParam x
from :: forall x. SecurityParam -> Rep SecurityParam x
$cto :: forall x. Rep SecurityParam x -> SecurityParam
to :: forall x. Rep SecurityParam x -> SecurityParam
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
$cnoThunks :: Context -> SecurityParam -> IO (Maybe ThunkInfo)
noThunks :: Context -> SecurityParam -> IO (Maybe ThunkInfo)
$cwNoThunks :: Context -> SecurityParam -> IO (Maybe ThunkInfo)
wNoThunks :: Context -> SecurityParam -> IO (Maybe ThunkInfo)
$cshowTypeOf :: Proxy SecurityParam -> String
showTypeOf :: Proxy SecurityParam -> String
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
$cshowsPrec :: Int -> SecurityParam -> ShowS
showsPrec :: Int -> SecurityParam -> ShowS
$cshow :: SecurityParam -> String
show :: SecurityParam -> String
$cshowList :: [SecurityParam] -> ShowS
showList :: [SecurityParam] -> ShowS
Show via Quiet SecurityParam