{-# LANGUAGE NamedFieldPuns #-}

-- | This tool synthesizes a valid ChainDB, replicating cardano-node's UX
--
-- Usage: db-synthesizer --config FILE --db PATH
--                       [--byron-delegation-certificate FILE]
--                       [--byron-signing-key FILE]
--                       [--shelley-kes-key FILE | --shelley-kes-agent-socket PATH]
--                       [--shelley-vrf-key FILE]
--                       [--shelley-operational-certificate 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
--   -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
--
-- The credential options are cardano-node's own (they come from
-- @cardano-config@), so @--help@ documents them the way the node does.
module Main (main) where

import Cardano.Crypto.Init (cryptoInit)
import Cardano.Tools.Config (withConfigErrorHandling)
import Cardano.Tools.DBSynthesizer.Run
import DBSynthesizer.Parsers
import Main.Utf8 (withStdTerminalHandles)

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
$ IO () -> IO ()
forall a. IO a -> IO a
withConfigErrorHandling (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$ do
  IO ()
cryptoInit
  Options{configFile, chainDBDir, credentials, synthOptions} <- IO Options
parseCommandLine
  (shelleyGenesis, protocol) <- initialize configFile credentials
  result <- synthesize genTxs synthOptions shelleyGenesis chainDBDir protocol
  putStrLn $ "--> done; result: " ++ show result
 where
  genTxs :: p -> p -> p -> p -> f [a]
genTxs p
_ p
_ p
_ p
_ = [a] -> f [a]
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure []