Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,11 @@ source-repository-package
location: https://github.com/f-f/ekg-forward
tag: b24b3aba2806ce223c62f8ce3e267ec92dcc52e2
--sha256: sha256-s5Hxxm04HmFVmdBjAnFEsJEhTqr5Z/uiB4K1s2VaVwE=

source-repository-package
type: git
location: https://github.com/IntersectMBO/cardano-base
tag: 0cb3b722c9af9e9afbee25d4fa66b5cab917d781
--sha256: sha256-QtJ9Q56fPQm6S1AYMcKbj9WAbtAyxZxb8x0NSQNbKMs=
subdir:
cardano-config
3 changes: 1 addition & 2 deletions cardano-node-capi/cardano-node-capi.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ library
import: project-config
exposed-modules: Node
build-depends: base >= 4.14 && < 5
, aeson
, bytestring
, cardano-config
, cardano-node
, optparse-applicative
hs-source-dirs: src
12 changes: 6 additions & 6 deletions cardano-node-capi/src/Node.hs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
module Node where

import Cardano.Node.Parsers (nodeCLIParser, parserHelpHeader, parserHelpOptions,
renderHelpDoc)
import qualified Cardano.Configuration as CC
import Cardano.Node.Run (runNode)

import Data.Aeson (eitherDecodeStrict)
import Data.ByteString.Char8 (pack)
import Options.Applicative

import Foreign.C (CString, peekCString)
Expand All @@ -19,10 +16,13 @@ foreign export ccall "runNode" crunNode :: Int -> Ptr CString -> IO ()
crunNode :: Int -> Ptr CString -> IO ()
crunNode argc argv = peekArray argc argv >>= mapM peekCString >>= \args ->
case execParserPure pref opts args of
Success pnc -> runNode pnc
Success cli -> runNode cli
Failure f -> print f
CompletionInvoked _ -> putStrLn "Completion Invoked?"
where
pref = prefs showHelpOnEmpty
opts = info nodeCLIParser
opts = info (nodeRunParser <**> helper)
( fullDesc <> progDesc "Start node of the Cardano blockchain." )
nodeRunParser =
subparser $
command "run" (info (CC.parseCliArgs <**> helper) (progDesc "Run the node."))
26 changes: 7 additions & 19 deletions cardano-node/app/cardano-node.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,20 @@
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TemplateHaskell #-}

import qualified Cardano.Configuration as CC
import qualified Cardano.Crypto.Init as Crypto
import Cardano.Git.Rev (gitRev)
import Cardano.Node.Configuration.POM (PartialNodeConfiguration (..))
import Cardano.Node.Handlers.TopLevel
import Cardano.Node.Parsers (nodeCLIParser)
import Cardano.Node.Run (runNode)
import Cardano.Node.Tracing.Documentation (TraceDocumentationCmd (..),
parseTraceDocumentationCmd, runTraceDocumentationCmd)

import Data.Monoid (Last (getLast))
import qualified Data.Text as Text
import qualified Data.Text.IO as Text
import Data.Version (showVersion)
import Options.Applicative
import qualified Options.Applicative as Opt
import System.Info (arch, compilerName, compilerVersion, os)
import System.IO (hPutStrLn, stderr)

import Paths_cardano_node (version)

Expand All @@ -32,28 +29,16 @@ main = do
cmd <- Opt.customExecParser p opts

case cmd of
RunCmd args -> do
warnIfSet args pncMaybeMempoolCapacityOverride "mempool-capacity-override" "MempoolCapacityBytesOverride"
runNode args
RunCmd args -> runNode args
TraceDocumentation tdc -> runTraceDocumentationCmd tdc
VersionCmd -> runVersionCommand

where
p = Opt.prefs Opt.showHelpOnEmpty

warnIfSet :: PartialNodeConfiguration -> (PartialNodeConfiguration -> Last a) -> String -> String -> IO ()
warnIfSet args f name key =
maybe
(pure ())
(\_ -> hPutStrLn stderr $ "WARNING: Option --" ++ name ++ " was set via CLI flags.\
\ This CLI flag will be removed in upcoming node releases.\
\ Please, set this configuration option in the configuration file instead with key " ++ key ++ ".")
$ getLast
$ f args

opts :: Opt.ParserInfo Command
opts =
Opt.info (fmap RunCmd nodeCLIParser
Opt.info (fmap RunCmd nodeRunParser
<|> fmap TraceDocumentation parseTraceDocumentationCmd
<|> parseVersionCmd
<**> helper)
Expand All @@ -62,8 +47,11 @@ main = do
Opt.progDesc "Start node of the Cardano blockchain."
)

-- | The node's CLI, parsed by @cardano-config@, under the @run@ subcommand.
nodeRunParser :: Parser CC.CliArgs
nodeRunParser = Opt.subparser $ command' "run" "Run the node." CC.parseCliArgs

data Command = RunCmd PartialNodeConfiguration
data Command = RunCmd CC.CliArgs
| TraceDocumentation TraceDocumentationCmd
| VersionCmd

Expand Down
6 changes: 4 additions & 2 deletions cardano-node/cardano-node.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ library

hs-source-dirs: src

exposed-modules: Cardano.Node.Configuration.NodeAddress
exposed-modules: Cardano.Node.Configuration.Adapter
Cardano.Node.Configuration.NodeAddress
Cardano.Node.Configuration.POM
Cardano.Node.Configuration.LedgerDB
Cardano.Node.Configuration.Socket
Cardano.Node.Configuration.TopologyP2P
Cardano.Node.Handlers.Shutdown
Cardano.Node.Handlers.TopLevel
Cardano.Node.Orphans
Cardano.Node.Parsers
Cardano.Node.Pretty
Cardano.Node.Protocol
Cardano.Node.Protocol.Alonzo
Expand Down Expand Up @@ -124,6 +124,7 @@ library
, base16-bytestring
, bytestring
, cardano-api ^>= 11.3
, cardano-config
, cardano-data
, cardano-crypto-class ^>=2.5
, cardano-crypto-wrapper
Expand Down Expand Up @@ -206,6 +207,7 @@ executable cardano-node
autogen-modules: Paths_cardano_node

build-depends: base
, cardano-config
, cardano-crypto-class
, cardano-git-rev
, cardano-node
Expand Down
Loading
Loading