{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TemplateHaskell #-}

module Cardano.Chain.Genesis.Initializer (
  GenesisInitializer (..),
  TestnetBalanceOptions (..),
  FakeAvvmOptions (..),
) where

import Cardano.Chain.Common (Lovelace)
import Cardano.Prelude

-- | Options determining generated genesis stakes, balances, and delegation
data GenesisInitializer = GenesisInitializer
  { GenesisInitializer -> TestnetBalanceOptions
giTestBalance :: !TestnetBalanceOptions
  , GenesisInitializer -> FakeAvvmOptions
giFakeAvvmBalance :: !FakeAvvmOptions
  , GenesisInitializer -> Rational
giAvvmBalanceFactor :: !Rational
  -- ^ Avvm balances will be multiplied by this factor
  , GenesisInitializer -> Bool
giUseHeavyDlg :: !Bool
  -- ^ Whether to use heavyweight delegation for genesis keys
  }
  deriving (GenesisInitializer -> GenesisInitializer -> Bool
(GenesisInitializer -> GenesisInitializer -> Bool)
-> (GenesisInitializer -> GenesisInitializer -> Bool)
-> Eq GenesisInitializer
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GenesisInitializer -> GenesisInitializer -> Bool
== :: GenesisInitializer -> GenesisInitializer -> Bool
$c/= :: GenesisInitializer -> GenesisInitializer -> Bool
/= :: GenesisInitializer -> GenesisInitializer -> Bool
Eq, Int -> GenesisInitializer -> ShowS
[GenesisInitializer] -> ShowS
GenesisInitializer -> String
(Int -> GenesisInitializer -> ShowS)
-> (GenesisInitializer -> String)
-> ([GenesisInitializer] -> ShowS)
-> Show GenesisInitializer
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GenesisInitializer -> ShowS
showsPrec :: Int -> GenesisInitializer -> ShowS
$cshow :: GenesisInitializer -> String
show :: GenesisInitializer -> String
$cshowList :: [GenesisInitializer] -> ShowS
showList :: [GenesisInitializer] -> ShowS
Show)

-- | These options determine balances of nodes specific for testnet
data TestnetBalanceOptions = TestnetBalanceOptions
  { TestnetBalanceOptions -> Word
tboPoors :: !Word
  -- ^ Number of poor nodes (with small balance).
  , TestnetBalanceOptions -> Word
tboRichmen :: !Word
  -- ^ Number of rich nodes (with huge balance).
  , TestnetBalanceOptions -> Lovelace
tboTotalBalance :: !Lovelace
  -- ^ Total balance owned by these nodes.
  , TestnetBalanceOptions -> Rational
tboRichmenShare :: !Rational
  -- ^ Portion of stake owned by all richmen together.
  }
  deriving (TestnetBalanceOptions -> TestnetBalanceOptions -> Bool
(TestnetBalanceOptions -> TestnetBalanceOptions -> Bool)
-> (TestnetBalanceOptions -> TestnetBalanceOptions -> Bool)
-> Eq TestnetBalanceOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TestnetBalanceOptions -> TestnetBalanceOptions -> Bool
== :: TestnetBalanceOptions -> TestnetBalanceOptions -> Bool
$c/= :: TestnetBalanceOptions -> TestnetBalanceOptions -> Bool
/= :: TestnetBalanceOptions -> TestnetBalanceOptions -> Bool
Eq, Int -> TestnetBalanceOptions -> ShowS
[TestnetBalanceOptions] -> ShowS
TestnetBalanceOptions -> String
(Int -> TestnetBalanceOptions -> ShowS)
-> (TestnetBalanceOptions -> String)
-> ([TestnetBalanceOptions] -> ShowS)
-> Show TestnetBalanceOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TestnetBalanceOptions -> ShowS
showsPrec :: Int -> TestnetBalanceOptions -> ShowS
$cshow :: TestnetBalanceOptions -> String
show :: TestnetBalanceOptions -> String
$cshowList :: [TestnetBalanceOptions] -> ShowS
showList :: [TestnetBalanceOptions] -> ShowS
Show)

-- | These options determines balances of fake AVVM nodes which didn't really go
--   through vending, but pretend they did
data FakeAvvmOptions = FakeAvvmOptions
  { FakeAvvmOptions -> Word
faoCount :: !Word
  , FakeAvvmOptions -> Lovelace
faoOneBalance :: !Lovelace
  }
  deriving (FakeAvvmOptions -> FakeAvvmOptions -> Bool
(FakeAvvmOptions -> FakeAvvmOptions -> Bool)
-> (FakeAvvmOptions -> FakeAvvmOptions -> Bool)
-> Eq FakeAvvmOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: FakeAvvmOptions -> FakeAvvmOptions -> Bool
== :: FakeAvvmOptions -> FakeAvvmOptions -> Bool
$c/= :: FakeAvvmOptions -> FakeAvvmOptions -> Bool
/= :: FakeAvvmOptions -> FakeAvvmOptions -> Bool
Eq, Int -> FakeAvvmOptions -> ShowS
[FakeAvvmOptions] -> ShowS
FakeAvvmOptions -> String
(Int -> FakeAvvmOptions -> ShowS)
-> (FakeAvvmOptions -> String)
-> ([FakeAvvmOptions] -> ShowS)
-> Show FakeAvvmOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> FakeAvvmOptions -> ShowS
showsPrec :: Int -> FakeAvvmOptions -> ShowS
$cshow :: FakeAvvmOptions -> String
show :: FakeAvvmOptions -> String
$cshowList :: [FakeAvvmOptions] -> ShowS
showList :: [FakeAvvmOptions] -> ShowS
Show, (forall x. FakeAvvmOptions -> Rep FakeAvvmOptions x)
-> (forall x. Rep FakeAvvmOptions x -> FakeAvvmOptions)
-> Generic FakeAvvmOptions
forall x. Rep FakeAvvmOptions x -> FakeAvvmOptions
forall x. FakeAvvmOptions -> Rep FakeAvvmOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. FakeAvvmOptions -> Rep FakeAvvmOptions x
from :: forall x. FakeAvvmOptions -> Rep FakeAvvmOptions x
$cto :: forall x. Rep FakeAvvmOptions x -> FakeAvvmOptions
to :: forall x. Rep FakeAvvmOptions x -> FakeAvvmOptions
Generic)