Skip to content

Commit 2864041

Browse files
committed
The Big Reformatting Commit
- enable ImportQualifiedPost - apply fourmolu code styler to all files
1 parent 86e06b2 commit 2864041

File tree

660 files changed

+100803
-89187
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

660 files changed

+100803
-89187
lines changed

ouroboros-consensus-cardano/app/DBAnalyser/Parsers.hs

+262-181
Large diffs are not rendered by default.

ouroboros-consensus-cardano/app/DBSynthesizer/Parsers.hs

+41-35
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
module DBSynthesizer.Parsers (parseCommandLine) where
22

3-
import Cardano.Tools.DBSynthesizer.Types
4-
import Data.Word (Word64)
5-
import Options.Applicative as Opt
6-
import Ouroboros.Consensus.Block.Abstract (SlotNo (..))
7-
3+
import Cardano.Tools.DBSynthesizer.Types
4+
import Data.Word (Word64)
5+
import Options.Applicative as Opt
6+
import Ouroboros.Consensus.Block.Abstract (SlotNo (..))
87

98
parseCommandLine :: IO (NodeFilePaths, NodeCredentials, DBSynthesizerOptions)
109
parseCommandLine =
11-
Opt.customExecParser p opts
12-
where
13-
p = Opt.prefs Opt.showHelpOnEmpty
14-
opts = Opt.info parserCommandLine mempty
10+
Opt.customExecParser p opts
11+
where
12+
p = Opt.prefs Opt.showHelpOnEmpty
13+
opts = Opt.info parserCommandLine mempty
1514

1615
parserCommandLine :: Parser (NodeFilePaths, NodeCredentials, DBSynthesizerOptions)
1716
parserCommandLine =
@@ -42,9 +41,12 @@ parseDBSynthesizerOptions =
4241

4342
parseForgeOptions :: Parser ForgeLimit
4443
parseForgeOptions =
45-
ForgeLimitSlot <$> parseSlotLimit
46-
<|> ForgeLimitBlock <$> parseBlockLimit
47-
<|> ForgeLimitEpoch <$> parseEpochLimit
44+
ForgeLimitSlot
45+
<$> parseSlotLimit
46+
<|> ForgeLimitBlock
47+
<$> parseBlockLimit
48+
<|> ForgeLimitEpoch
49+
<$> parseEpochLimit
4850

4951
parseChainDBFilePath :: Parser FilePath
5052
parseChainDBFilePath =
@@ -102,47 +104,51 @@ parseBulkFilePath =
102104

103105
parseSlotLimit :: Parser SlotNo
104106
parseSlotLimit =
105-
SlotNo <$> option auto
106-
( short 's'
107-
<> long "slots"
108-
<> metavar "NUMBER"
109-
<> help "Amount of slots to process"
110-
)
107+
SlotNo
108+
<$> option
109+
auto
110+
( short 's'
111+
<> long "slots"
112+
<> metavar "NUMBER"
113+
<> help "Amount of slots to process"
114+
)
111115

112116
parseBlockLimit :: Parser Word64
113117
parseBlockLimit =
114-
option auto
115-
( short 'b'
116-
<> long "blocks"
117-
<> metavar "NUMBER"
118-
<> help "Amount of blocks to forge"
118+
option
119+
auto
120+
( short 'b'
121+
<> long "blocks"
122+
<> metavar "NUMBER"
123+
<> help "Amount of blocks to forge"
119124
)
120125

121126
parseEpochLimit :: Parser Word64
122127
parseEpochLimit =
123-
option auto
124-
( short 'e'
125-
<> long "epochs"
126-
<> metavar "NUMBER"
127-
<> help "Amount of epochs to process"
128+
option
129+
auto
130+
( short 'e'
131+
<> long "epochs"
132+
<> metavar "NUMBER"
133+
<> help "Amount of epochs to process"
128134
)
129135

130136
parseForce :: Parser Bool
131137
parseForce =
132138
switch
133-
( short 'f'
134-
<> help "Force overwrite an existing Chain DB"
139+
( short 'f'
140+
<> help "Force overwrite an existing Chain DB"
135141
)
136142

137143
parseAppend :: Parser Bool
138144
parseAppend =
139145
switch
140-
( short 'a'
141-
<> help "Append to an existing Chain DB"
146+
( short 'a'
147+
<> help "Append to an existing Chain DB"
142148
)
143149

144150
parseOpenMode :: Parser DBSynthesizerOpenMode
145151
parseOpenMode =
146-
(parseForce *> pure OpenCreateForce)
147-
<|> (parseAppend *> pure OpenAppend)
148-
<|> pure OpenCreate
152+
(parseForce *> pure OpenCreateForce)
153+
<|> (parseAppend *> pure OpenAppend)
154+
<|> pure OpenCreate

ouroboros-consensus-cardano/app/DBTruncater/Parsers.hs

+18-14
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,49 @@
11
module DBTruncater.Parsers (commandLineParser) where
22

3-
import Cardano.Tools.DBTruncater.Types
4-
import DBAnalyser.Parsers
5-
import Options.Applicative
6-
import Ouroboros.Consensus.Block.Abstract
3+
import Cardano.Tools.DBTruncater.Types
4+
import DBAnalyser.Parsers
5+
import Options.Applicative
6+
import Ouroboros.Consensus.Block.Abstract
77

88
commandLineParser :: Parser (DBTruncaterConfig, BlockType)
99
commandLineParser = (,) <$> parseDBTruncaterConfig <*> blockTypeParser
1010

1111
parseDBTruncaterConfig :: Parser DBTruncaterConfig
12-
parseDBTruncaterConfig = DBTruncaterConfig
12+
parseDBTruncaterConfig =
13+
DBTruncaterConfig
1314
<$> parseChainDBPath
1415
<*> parseTruncateAfter
1516
<*> parseVerbose
16-
where
17-
parseChainDBPath = strOption $
17+
where
18+
parseChainDBPath =
19+
strOption $
1820
mconcat
1921
[ long "db"
2022
, help "Path of the chain DB"
2123
, metavar "PATH"
2224
]
23-
parseVerbose = switch (long "verbose" <> help "Enable verbose logging")
25+
parseVerbose = switch (long "verbose" <> help "Enable verbose logging")
2426
parseTruncateAfter :: Parser TruncateAfter
2527
parseTruncateAfter =
2628
fmap TruncateAfterSlot slotNoOption <|> fmap TruncateAfterBlock blockNoOption
2729

2830
slotNoOption :: Parser SlotNo
2931
slotNoOption =
30-
SlotNo <$> option auto mods
31-
where
32-
mods = mconcat
32+
SlotNo <$> option auto mods
33+
where
34+
mods =
35+
mconcat
3336
[ long "truncate-after-slot"
3437
, metavar "SLOT_NUMBER"
3538
, help "Remove all blocks with a higher slot number"
3639
]
3740

3841
blockNoOption :: Parser BlockNo
3942
blockNoOption =
40-
BlockNo <$> option auto mods
41-
where
42-
mods = mconcat
43+
BlockNo <$> option auto mods
44+
where
45+
mods =
46+
mconcat
4347
[ long "truncate-after-block"
4448
, metavar "BLOCK_NUMBER"
4549
, help "The block number of the intended new tip of the chain after truncation"
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,74 @@
11
module GenHeader.Parsers (parseOptions) where
22

3-
import Cardano.Tools.Headers (Options (..))
4-
import Data.Version (showVersion)
5-
import Options.Applicative (Parser, ParserInfo, auto, command,
6-
execParser, help, helper, hsubparser, info, long, metavar,
7-
option, progDesc, short, (<**>))
8-
import Paths_ouroboros_consensus_cardano (version)
3+
import Cardano.Tools.Headers (Options (..))
4+
import Data.Version (showVersion)
5+
import Options.Applicative
6+
( Parser
7+
, ParserInfo
8+
, auto
9+
, command
10+
, execParser
11+
, help
12+
, helper
13+
, hsubparser
14+
, info
15+
, long
16+
, metavar
17+
, option
18+
, progDesc
19+
, short
20+
, (<**>)
21+
)
22+
import Paths_ouroboros_consensus_cardano (version)
923

1024
parseOptions :: IO Options
1125
parseOptions = execParser argsParser
1226

1327
argsParser :: ParserInfo Options
1428
argsParser =
15-
info
16-
(optionsParser <**> helper)
17-
( progDesc $
18-
unlines
19-
[ "gen-header - A utility to generate valid and invalid Praos headers for testing purpose"
20-
, "version: " <> showVersion version
21-
]
22-
)
29+
info
30+
(optionsParser <**> helper)
31+
( progDesc $
32+
unlines
33+
[ "gen-header - A utility to generate valid and invalid Praos headers for testing purpose"
34+
, "version: " <> showVersion version
35+
]
36+
)
2337

2438
optionsParser :: Parser Options
2539
optionsParser =
26-
hsubparser
27-
( command "generate" (info generateOptionsParser (progDesc "Generate Praos headers context and valid/invalid headers. Writes JSON formatted context to stdout and headers to stdout."))
28-
<> command "validate" (info validateOptionsParser (progDesc "Validate a sample of Praos headers within a context. Reads JSON formatted sample from stdin."))
40+
hsubparser
41+
( command
42+
"generate"
43+
( info
44+
generateOptionsParser
45+
( progDesc
46+
"Generate Praos headers context and valid/invalid headers. Writes JSON formatted context to stdout and headers to stdout."
47+
)
2948
)
49+
<> command
50+
"validate"
51+
( info
52+
validateOptionsParser
53+
( progDesc
54+
"Validate a sample of Praos headers within a context. Reads JSON formatted sample from stdin."
55+
)
56+
)
57+
)
3058

3159
validateOptionsParser :: Parser Options
3260
validateOptionsParser = pure Validate
3361

3462
generateOptionsParser :: Parser Options
3563
generateOptionsParser =
36-
Generate <$> countParser
64+
Generate <$> countParser
3765

3866
countParser :: Parser Int
3967
countParser =
40-
option
41-
auto
42-
( long "count"
43-
<> short 'c'
44-
<> metavar "INT"
45-
<> help "Number of headers to generate"
46-
)
68+
option
69+
auto
70+
( long "count"
71+
<> short 'c'
72+
<> metavar "INT"
73+
<> help "Number of headers to generate"
74+
)

ouroboros-consensus-cardano/app/db-analyser.hs

+33-23
Original file line numberDiff line numberDiff line change
@@ -17,32 +17,42 @@
1717
-- [--num-blocks-to-process INT] COMMAND
1818
module Main (main) where
1919

20-
import Cardano.Crypto.Init (cryptoInit)
21-
import Cardano.Tools.DBAnalyser.Run
22-
import Cardano.Tools.DBAnalyser.Types
23-
import Cardano.Tools.GitRev (gitRev)
24-
import Control.Monad (void)
25-
import qualified Data.Text as T
26-
import DBAnalyser.Parsers
27-
import Main.Utf8 (withStdTerminalHandles)
28-
import Options.Applicative (execParser, footer, fullDesc, helper,
29-
info, progDesc, (<**>))
30-
20+
import Cardano.Crypto.Init (cryptoInit)
21+
import Cardano.Tools.DBAnalyser.Run
22+
import Cardano.Tools.DBAnalyser.Types
23+
import Cardano.Tools.GitRev (gitRev)
24+
import Control.Monad (void)
25+
import DBAnalyser.Parsers
26+
import Data.Text qualified as T
27+
import Main.Utf8 (withStdTerminalHandles)
28+
import Options.Applicative
29+
( execParser
30+
, footer
31+
, fullDesc
32+
, helper
33+
, info
34+
, progDesc
35+
, (<**>)
36+
)
3137

3238
main :: IO ()
3339
main = withStdTerminalHandles $ do
34-
cryptoInit
35-
(conf, blocktype) <- getCmdLine
36-
void $ case blocktype of
37-
ByronBlock args -> analyse conf args
38-
ShelleyBlock args -> analyse conf args
39-
CardanoBlock args -> analyse conf args
40+
cryptoInit
41+
(conf, blocktype) <- getCmdLine
42+
void $ case blocktype of
43+
ByronBlock args -> analyse conf args
44+
ShelleyBlock args -> analyse conf args
45+
CardanoBlock args -> analyse conf args
4046

4147
getCmdLine :: IO (DBAnalyserConfig, BlockType)
4248
getCmdLine = execParser opts
43-
where
44-
opts = info (parseCmdLine <**> helper) (mconcat [
45-
fullDesc
46-
, progDesc "Simple framework used to analyse a Chain DB"
47-
, footer $ "ouroboros-consensus commit: " <> T.unpack gitRev
48-
])
49+
where
50+
opts =
51+
info
52+
(parseCmdLine <**> helper)
53+
( mconcat
54+
[ fullDesc
55+
, progDesc "Simple framework used to analyse a Chain DB"
56+
, footer $ "ouroboros-consensus commit: " <> T.unpack gitRev
57+
]
58+
)

0 commit comments

Comments
 (0)