-- | This tool synthesizes a valid ChainDB, replicating cardano-node's UX
--
-- Usage: db-synthesizer --config FILE --db PATH
--                       [--shelley-operational-certificate FILE]
--                       [--shelley-vrf-key FILE] [--shelley-kes-key FILE]
--                       [--bulk-credentials-file FILE]
--                       ((-s|--slots NUMBER) | (-b|--blocks NUMBER) |
--                         (-e|--epochs NUMBER)) [-f | -a]
--
-- Available options:
--   --config FILE            Path to the node's config.json
--   --db PATH                Path to the Chain DB
--   --shelley-operational-certificate FILE
--                            Path to the delegation certificate
--   --shelley-vrf-key FILE   Path to the VRF signing key
--   --shelley-kes-key FILE   Path to the KES signing key
--   --bulk-credentials-file FILE
--                            Path to the bulk credentials file
--   -s,--slots NUMBER        Amount of slots to process
--   -b,--blocks NUMBER       Amount of blocks to forge
--   -e,--epochs NUMBER       Amount of epochs to process
--   -f                       Force overwrite an existing Chain DB
--   -a                       Append to an existing Chain DB
module Main (main) where

import           Cardano.Crypto.Init (cryptoInit)
import           Cardano.Tools.DBSynthesizer.Run
import           DBSynthesizer.Parsers
import           Main.Utf8 (withStdTerminalHandles)
import           System.Exit


main :: IO ()
IO ()
main = IO () -> IO ()
forall (m :: * -> *) r. (MonadIO m, MonadMask m) => m r -> m r
withStdTerminalHandles (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$ do
    IO ()
cryptoInit
    (paths, creds, forgeOpts) <- IO (NodeFilePaths, NodeCredentials, DBSynthesizerOptions)
parseCommandLine
    let
      genTxs p
_ p
_ p
_ p
_ = [a] -> f [a]
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
    result <- initialize paths creds forgeOpts >>= either die (uncurry (synthesize genTxs))
    putStrLn $ "--> done; result: " ++ show result