{-# LANGUAGE TypeApplications #-} module Testnet.Commands.Bcc ( BccOptions(..) , cmdBcc , runBccOptions ) where import GHC.Enum import Data.Eq import Data.Function import Data.Int import Data.Maybe import Data.Semigroup import Options.Applicative import System.IO (IO) import Testnet.Bcc import Testnet.Run (runTestnet) import Text.Read import Text.Show import qualified Options.Applicative as OA data BccOptions = BccOptions { BccOptions -> Maybe Int maybeTestnetMagic :: Maybe Int , BccOptions -> TestnetOptions testnetOptions :: TestnetOptions } deriving (BccOptions -> BccOptions -> Bool (BccOptions -> BccOptions -> Bool) -> (BccOptions -> BccOptions -> Bool) -> Eq BccOptions forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a /= :: BccOptions -> BccOptions -> Bool $c/= :: BccOptions -> BccOptions -> Bool == :: BccOptions -> BccOptions -> Bool $c== :: BccOptions -> BccOptions -> Bool Eq, Int -> BccOptions -> ShowS [BccOptions] -> ShowS BccOptions -> String (Int -> BccOptions -> ShowS) -> (BccOptions -> String) -> ([BccOptions] -> ShowS) -> Show BccOptions forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a showList :: [BccOptions] -> ShowS $cshowList :: [BccOptions] -> ShowS show :: BccOptions -> String $cshow :: BccOptions -> String showsPrec :: Int -> BccOptions -> ShowS $cshowsPrec :: Int -> BccOptions -> ShowS Show) optsTestnet :: Parser TestnetOptions optsTestnet :: Parser TestnetOptions optsTestnet = Int -> Int -> Era -> Int -> Double -> Double -> TestnetOptions TestnetOptions (Int -> Int -> Era -> Int -> Double -> Double -> TestnetOptions) -> Parser Int -> Parser (Int -> Era -> Int -> Double -> Double -> TestnetOptions) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> ReadM Int -> Mod OptionFields Int -> Parser Int forall a. ReadM a -> Mod OptionFields a -> Parser a OA.option ReadM Int forall a. Read a => ReadM a auto ( String -> Mod OptionFields Int forall (f :: * -> *) a. HasName f => String -> Mod f a OA.long String "num-bft-nodes" Mod OptionFields Int -> Mod OptionFields Int -> Mod OptionFields Int forall a. Semigroup a => a -> a -> a <> String -> Mod OptionFields Int forall (f :: * -> *) a. String -> Mod f a OA.help String "Number of BFT nodes" Mod OptionFields Int -> Mod OptionFields Int -> Mod OptionFields Int forall a. Semigroup a => a -> a -> a <> String -> Mod OptionFields Int forall (f :: * -> *) a. HasMetavar f => String -> Mod f a OA.metavar String "COUNT" Mod OptionFields Int -> Mod OptionFields Int -> Mod OptionFields Int forall a. Semigroup a => a -> a -> a <> Mod OptionFields Int forall a (f :: * -> *). Show a => Mod f a OA.showDefault Mod OptionFields Int -> Mod OptionFields Int -> Mod OptionFields Int forall a. Semigroup a => a -> a -> a <> Int -> Mod OptionFields Int forall (f :: * -> *) a. HasValue f => a -> Mod f a OA.value (TestnetOptions -> Int numBftNodes TestnetOptions defaultTestnetOptions) ) Parser (Int -> Era -> Int -> Double -> Double -> TestnetOptions) -> Parser Int -> Parser (Era -> Int -> Double -> Double -> TestnetOptions) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> ReadM Int -> Mod OptionFields Int -> Parser Int forall a. ReadM a -> Mod OptionFields a -> Parser a OA.option ReadM Int forall a. Read a => ReadM a auto ( String -> Mod OptionFields Int forall (f :: * -> *) a. HasName f => String -> Mod f a OA.long String "num-pool-nodes" Mod OptionFields Int -> Mod OptionFields Int -> Mod OptionFields Int forall a. Semigroup a => a -> a -> a <> String -> Mod OptionFields Int forall (f :: * -> *) a. String -> Mod f a OA.help String "Number of pool nodes" Mod OptionFields Int -> Mod OptionFields Int -> Mod OptionFields Int forall a. Semigroup a => a -> a -> a <> String -> Mod OptionFields Int forall (f :: * -> *) a. HasMetavar f => String -> Mod f a OA.metavar String "COUNT" Mod OptionFields Int -> Mod OptionFields Int -> Mod OptionFields Int forall a. Semigroup a => a -> a -> a <> Mod OptionFields Int forall a (f :: * -> *). Show a => Mod f a OA.showDefault Mod OptionFields Int -> Mod OptionFields Int -> Mod OptionFields Int forall a. Semigroup a => a -> a -> a <> Int -> Mod OptionFields Int forall (f :: * -> *) a. HasValue f => a -> Mod f a OA.value (TestnetOptions -> Int numPoolNodes TestnetOptions defaultTestnetOptions) ) Parser (Era -> Int -> Double -> Double -> TestnetOptions) -> Parser Era -> Parser (Int -> Double -> Double -> TestnetOptions) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> ReadM Era -> Mod OptionFields Era -> Parser Era forall a. ReadM a -> Mod OptionFields a -> Parser a OA.option ((String -> Either String Era) -> ReadM Era forall a. (String -> Either String a) -> ReadM a OA.eitherReader String -> Either String Era forall a. Read a => String -> Either String a readEither) ( String -> Mod OptionFields Era forall (f :: * -> *) a. HasName f => String -> Mod f a OA.long String "era" Mod OptionFields Era -> Mod OptionFields Era -> Mod OptionFields Era forall a. Semigroup a => a -> a -> a <> String -> Mod OptionFields Era forall (f :: * -> *) a. String -> Mod f a OA.help (String "Era to upgrade to. " String -> ShowS forall a. Semigroup a => a -> a -> a <> [Era] -> String forall a. Show a => a -> String show @[Era] [Era forall a. Bounded a => a minBound .. Era forall a. Bounded a => a maxBound]) Mod OptionFields Era -> Mod OptionFields Era -> Mod OptionFields Era forall a. Semigroup a => a -> a -> a <> String -> Mod OptionFields Era forall (f :: * -> *) a. HasMetavar f => String -> Mod f a OA.metavar String "ERA" Mod OptionFields Era -> Mod OptionFields Era -> Mod OptionFields Era forall a. Semigroup a => a -> a -> a <> Mod OptionFields Era forall a (f :: * -> *). Show a => Mod f a OA.showDefault Mod OptionFields Era -> Mod OptionFields Era -> Mod OptionFields Era forall a. Semigroup a => a -> a -> a <> Era -> Mod OptionFields Era forall (f :: * -> *) a. HasValue f => a -> Mod f a OA.value (TestnetOptions -> Era era TestnetOptions defaultTestnetOptions) ) Parser (Int -> Double -> Double -> TestnetOptions) -> Parser Int -> Parser (Double -> Double -> TestnetOptions) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> ReadM Int -> Mod OptionFields Int -> Parser Int forall a. ReadM a -> Mod OptionFields a -> Parser a OA.option ReadM Int forall a. Read a => ReadM a auto ( String -> Mod OptionFields Int forall (f :: * -> *) a. HasName f => String -> Mod f a OA.long String "epoch-length" Mod OptionFields Int -> Mod OptionFields Int -> Mod OptionFields Int forall a. Semigroup a => a -> a -> a <> String -> Mod OptionFields Int forall (f :: * -> *) a. String -> Mod f a OA.help String "Epoch length" Mod OptionFields Int -> Mod OptionFields Int -> Mod OptionFields Int forall a. Semigroup a => a -> a -> a <> String -> Mod OptionFields Int forall (f :: * -> *) a. HasMetavar f => String -> Mod f a OA.metavar String "MILLISECONDS" Mod OptionFields Int -> Mod OptionFields Int -> Mod OptionFields Int forall a. Semigroup a => a -> a -> a <> Mod OptionFields Int forall a (f :: * -> *). Show a => Mod f a OA.showDefault Mod OptionFields Int -> Mod OptionFields Int -> Mod OptionFields Int forall a. Semigroup a => a -> a -> a <> Int -> Mod OptionFields Int forall (f :: * -> *) a. HasValue f => a -> Mod f a OA.value (TestnetOptions -> Int epochLength TestnetOptions defaultTestnetOptions) ) Parser (Double -> Double -> TestnetOptions) -> Parser Double -> Parser (Double -> TestnetOptions) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> ReadM Double -> Mod OptionFields Double -> Parser Double forall a. ReadM a -> Mod OptionFields a -> Parser a OA.option ReadM Double forall a. Read a => ReadM a auto ( String -> Mod OptionFields Double forall (f :: * -> *) a. HasName f => String -> Mod f a OA.long String "slot-length" Mod OptionFields Double -> Mod OptionFields Double -> Mod OptionFields Double forall a. Semigroup a => a -> a -> a <> String -> Mod OptionFields Double forall (f :: * -> *) a. String -> Mod f a OA.help String "Slot length" Mod OptionFields Double -> Mod OptionFields Double -> Mod OptionFields Double forall a. Semigroup a => a -> a -> a <> String -> Mod OptionFields Double forall (f :: * -> *) a. HasMetavar f => String -> Mod f a OA.metavar String "SECONDS" Mod OptionFields Double -> Mod OptionFields Double -> Mod OptionFields Double forall a. Semigroup a => a -> a -> a <> Mod OptionFields Double forall a (f :: * -> *). Show a => Mod f a OA.showDefault Mod OptionFields Double -> Mod OptionFields Double -> Mod OptionFields Double forall a. Semigroup a => a -> a -> a <> Double -> Mod OptionFields Double forall (f :: * -> *) a. HasValue f => a -> Mod f a OA.value (TestnetOptions -> Double slotLength TestnetOptions defaultTestnetOptions) ) Parser (Double -> TestnetOptions) -> Parser Double -> Parser TestnetOptions forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> ReadM Double -> Mod OptionFields Double -> Parser Double forall a. ReadM a -> Mod OptionFields a -> Parser a OA.option ReadM Double forall a. Read a => ReadM a auto ( String -> Mod OptionFields Double forall (f :: * -> *) a. HasName f => String -> Mod f a OA.long String "active-slots-coeff" Mod OptionFields Double -> Mod OptionFields Double -> Mod OptionFields Double forall a. Semigroup a => a -> a -> a <> String -> Mod OptionFields Double forall (f :: * -> *) a. String -> Mod f a OA.help String "Active slots co-efficient" Mod OptionFields Double -> Mod OptionFields Double -> Mod OptionFields Double forall a. Semigroup a => a -> a -> a <> String -> Mod OptionFields Double forall (f :: * -> *) a. HasMetavar f => String -> Mod f a OA.metavar String "DOUBLE" Mod OptionFields Double -> Mod OptionFields Double -> Mod OptionFields Double forall a. Semigroup a => a -> a -> a <> Mod OptionFields Double forall a (f :: * -> *). Show a => Mod f a OA.showDefault Mod OptionFields Double -> Mod OptionFields Double -> Mod OptionFields Double forall a. Semigroup a => a -> a -> a <> Double -> Mod OptionFields Double forall (f :: * -> *) a. HasValue f => a -> Mod f a OA.value (TestnetOptions -> Double activeSlotsCoeff TestnetOptions defaultTestnetOptions) ) optsBcc :: Parser BccOptions optsBcc :: Parser BccOptions optsBcc = Maybe Int -> TestnetOptions -> BccOptions BccOptions (Maybe Int -> TestnetOptions -> BccOptions) -> Parser (Maybe Int) -> Parser (TestnetOptions -> BccOptions) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Parser Int -> Parser (Maybe Int) forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a) optional ( ReadM Int -> Mod OptionFields Int -> Parser Int forall a. ReadM a -> Mod OptionFields a -> Parser a OA.option ReadM Int forall a. Read a => ReadM a auto ( String -> Mod OptionFields Int forall (f :: * -> *) a. HasName f => String -> Mod f a long String "testnet-magic" Mod OptionFields Int -> Mod OptionFields Int -> Mod OptionFields Int forall a. Semigroup a => a -> a -> a <> String -> Mod OptionFields Int forall (f :: * -> *) a. String -> Mod f a help String "Testnet magic" Mod OptionFields Int -> Mod OptionFields Int -> Mod OptionFields Int forall a. Semigroup a => a -> a -> a <> String -> Mod OptionFields Int forall (f :: * -> *) a. HasMetavar f => String -> Mod f a metavar String "INT" ) ) Parser (TestnetOptions -> BccOptions) -> Parser TestnetOptions -> Parser BccOptions forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> Parser TestnetOptions optsTestnet runBccOptions :: BccOptions -> IO () runBccOptions :: BccOptions -> IO () runBccOptions BccOptions options = Maybe Int -> (Conf -> Integration TestnetRuntime) -> IO () forall a. Maybe Int -> (Conf -> Integration a) -> IO () runTestnet (BccOptions -> Maybe Int maybeTestnetMagic BccOptions options) ((Conf -> Integration TestnetRuntime) -> IO ()) -> (Conf -> Integration TestnetRuntime) -> IO () forall a b. (a -> b) -> a -> b $ TestnetOptions -> Conf -> Integration TestnetRuntime Testnet.Bcc.testnet (BccOptions -> TestnetOptions testnetOptions BccOptions options) cmdBcc :: Mod CommandFields (IO ()) cmdBcc :: Mod CommandFields (IO ()) cmdBcc = String -> ParserInfo (IO ()) -> Mod CommandFields (IO ()) forall a. String -> ParserInfo a -> Mod CommandFields a command String "bcc" (ParserInfo (IO ()) -> Mod CommandFields (IO ())) -> ParserInfo (IO ()) -> Mod CommandFields (IO ()) forall a b. (a -> b) -> a -> b $ (Parser (IO ()) -> InfoMod (IO ()) -> ParserInfo (IO ())) -> InfoMod (IO ()) -> Parser (IO ()) -> ParserInfo (IO ()) forall a b c. (a -> b -> c) -> b -> a -> c flip Parser (IO ()) -> InfoMod (IO ()) -> ParserInfo (IO ()) forall a. Parser a -> InfoMod a -> ParserInfo a info InfoMod (IO ()) forall m. Monoid m => m idm (Parser (IO ()) -> ParserInfo (IO ())) -> Parser (IO ()) -> ParserInfo (IO ()) forall a b. (a -> b) -> a -> b $ BccOptions -> IO () runBccOptions (BccOptions -> IO ()) -> Parser BccOptions -> Parser (IO ()) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Parser BccOptions optsBcc