Skip to content

Commit 22f7aad

Browse files
committed
Switch to cardano-config
1 parent 37507ce commit 22f7aad

8 files changed

Lines changed: 468 additions & 531 deletions

File tree

cabal.project

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,3 +186,11 @@ source-repository-package
186186
location: https://github.com/f-f/ekg-forward
187187
tag: b24b3aba2806ce223c62f8ce3e267ec92dcc52e2
188188
--sha256: sha256-s5Hxxm04HmFVmdBjAnFEsJEhTqr5Z/uiB4K1s2VaVwE=
189+
190+
source-repository-package
191+
type: git
192+
location: https://github.com/IntersectMBO/cardano-base
193+
tag: 0cb3b722c9af9e9afbee25d4fa66b5cab917d781
194+
--sha256: sha256-QtJ9Q56fPQm6S1AYMcKbj9WAbtAyxZxb8x0NSQNbKMs=
195+
subdir:
196+
cardano-config

cardano-node-capi/cardano-node-capi.cabal

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ library
2121
import: project-config
2222
exposed-modules: Node
2323
build-depends: base >= 4.14 && < 5
24-
, aeson
25-
, bytestring
24+
, cardano-config
2625
, cardano-node
2726
, optparse-applicative
2827
hs-source-dirs: src

cardano-node-capi/src/Node.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
module Node where
22

3-
import Cardano.Node.Parsers (nodeCLIParser, parserHelpHeader, parserHelpOptions,
4-
renderHelpDoc)
3+
import qualified Cardano.Configuration as CC
54
import Cardano.Node.Run (runNode)
65

7-
import Data.Aeson (eitherDecodeStrict)
8-
import Data.ByteString.Char8 (pack)
96
import Options.Applicative
107

118
import Foreign.C (CString, peekCString)
@@ -19,10 +16,13 @@ foreign export ccall "runNode" crunNode :: Int -> Ptr CString -> IO ()
1916
crunNode :: Int -> Ptr CString -> IO ()
2017
crunNode argc argv = peekArray argc argv >>= mapM peekCString >>= \args ->
2118
case execParserPure pref opts args of
22-
Success pnc -> runNode pnc
19+
Success cli -> runNode cli
2320
Failure f -> print f
2421
CompletionInvoked _ -> putStrLn "Completion Invoked?"
2522
where
2623
pref = prefs showHelpOnEmpty
27-
opts = info nodeCLIParser
24+
opts = info (nodeRunParser <**> helper)
2825
( fullDesc <> progDesc "Start node of the Cardano blockchain." )
26+
nodeRunParser =
27+
subparser $
28+
command "run" (info (CC.parseCliArgs <**> helper) (progDesc "Run the node."))

cardano-node/app/cardano-node.hs

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,20 @@
44
{-# LANGUAGE RankNTypes #-}
55
{-# LANGUAGE TemplateHaskell #-}
66

7+
import qualified Cardano.Configuration as CC
78
import qualified Cardano.Crypto.Init as Crypto
89
import Cardano.Git.Rev (gitRev)
9-
import Cardano.Node.Configuration.POM (PartialNodeConfiguration (..))
1010
import Cardano.Node.Handlers.TopLevel
11-
import Cardano.Node.Parsers (nodeCLIParser)
1211
import Cardano.Node.Run (runNode)
1312
import Cardano.Node.Tracing.Documentation (TraceDocumentationCmd (..),
1413
parseTraceDocumentationCmd, runTraceDocumentationCmd)
1514

16-
import Data.Monoid (Last (getLast))
1715
import qualified Data.Text as Text
1816
import qualified Data.Text.IO as Text
1917
import Data.Version (showVersion)
2018
import Options.Applicative
2119
import qualified Options.Applicative as Opt
2220
import System.Info (arch, compilerName, compilerVersion, os)
23-
import System.IO (hPutStrLn, stderr)
2421

2522
import Paths_cardano_node (version)
2623

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

3431
case cmd of
35-
RunCmd args -> do
36-
warnIfSet args pncMaybeMempoolCapacityOverride "mempool-capacity-override" "MempoolCapacityBytesOverride"
37-
runNode args
32+
RunCmd args -> runNode args
3833
TraceDocumentation tdc -> runTraceDocumentationCmd tdc
3934
VersionCmd -> runVersionCommand
4035

4136
where
4237
p = Opt.prefs Opt.showHelpOnEmpty
4338

44-
warnIfSet :: PartialNodeConfiguration -> (PartialNodeConfiguration -> Last a) -> String -> String -> IO ()
45-
warnIfSet args f name key =
46-
maybe
47-
(pure ())
48-
(\_ -> hPutStrLn stderr $ "WARNING: Option --" ++ name ++ " was set via CLI flags.\
49-
\ This CLI flag will be removed in upcoming node releases.\
50-
\ Please, set this configuration option in the configuration file instead with key " ++ key ++ ".")
51-
$ getLast
52-
$ f args
53-
5439
opts :: Opt.ParserInfo Command
5540
opts =
56-
Opt.info (fmap RunCmd nodeCLIParser
41+
Opt.info (fmap RunCmd nodeRunParser
5742
<|> fmap TraceDocumentation parseTraceDocumentationCmd
5843
<|> parseVersionCmd
5944
<**> helper)
@@ -62,8 +47,11 @@ main = do
6247
Opt.progDesc "Start node of the Cardano blockchain."
6348
)
6449

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

66-
data Command = RunCmd PartialNodeConfiguration
54+
data Command = RunCmd CC.CliArgs
6755
| TraceDocumentation TraceDocumentationCmd
6856
| VersionCmd
6957

cardano-node/cardano-node.cabal

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,15 @@ library
5959

6060
hs-source-dirs: src
6161

62-
exposed-modules: Cardano.Node.Configuration.NodeAddress
62+
exposed-modules: Cardano.Node.Configuration.Adapter
63+
Cardano.Node.Configuration.NodeAddress
6364
Cardano.Node.Configuration.POM
6465
Cardano.Node.Configuration.LedgerDB
6566
Cardano.Node.Configuration.Socket
6667
Cardano.Node.Configuration.TopologyP2P
6768
Cardano.Node.Handlers.Shutdown
6869
Cardano.Node.Handlers.TopLevel
6970
Cardano.Node.Orphans
70-
Cardano.Node.Parsers
7171
Cardano.Node.Pretty
7272
Cardano.Node.Protocol
7373
Cardano.Node.Protocol.Alonzo
@@ -124,6 +124,7 @@ library
124124
, base16-bytestring
125125
, bytestring
126126
, cardano-api ^>= 11.3
127+
, cardano-config
127128
, cardano-data
128129
, cardano-crypto-class ^>=2.5
129130
, cardano-crypto-wrapper
@@ -206,6 +207,7 @@ executable cardano-node
206207
autogen-modules: Paths_cardano_node
207208

208209
build-depends: base
210+
, cardano-config
209211
, cardano-crypto-class
210212
, cardano-git-rev
211213
, cardano-node

0 commit comments

Comments
 (0)