Skip to content
This repository was archived by the owner on Aug 1, 2023. It is now read-only.

Commit f4b3274

Browse files
committed
[GH-235] Fixing review suggestions, cleaner solution.
1 parent 3ae3383 commit f4b3274

File tree

5 files changed

+25
-31
lines changed

5 files changed

+25
-31
lines changed

app/Main.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ import Options.Applicative
2828
-- All here being - from all the features.
2929
data CLIArguments = CLIArguments
3030
!LoggingCLIArguments
31-
!(Last PartialWallet)
32-
!(Last PartialBlock)
33-
!(Last PartialCore)
31+
!PartialWallet
32+
!PartialBlock
33+
!PartialCore
3434

3535
main :: IO ()
3636
main = do
@@ -100,9 +100,9 @@ initializeAllFeatures partialConfig cardanoEnvironment = do
100100
let configBlock = pccBlock partialConfig
101101
let configWallet = pccWallet partialConfig
102102

103-
let pccCore' = liftA2 (<>) configCore coreCLI
104-
let pccBlock' = liftA2 (<>) configBlock blockCLI
105-
let pccWallet' = liftA2 (<>) configWallet walletCLI
103+
let pccCore' = configCore <> coreCLI
104+
let pccBlock' = configBlock <> blockCLI
105+
let pccWallet' = configWallet <> walletCLI
106106

107107
putTextLn "************************************************"
108108
putTextLn "CORE"

src/Cardano/Shell/Configuration/Lib.hs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,21 +58,18 @@ finaliseCardanoConfiguration PartialCardanoConfiguration{..} = do
5858
ccDBPath <- lastToEither "Unspecified ccDBPath" pccDBPath
5959
ccApplicationLockFile <- lastToEither "Unspecified ccApplicationLockFile"
6060
pccApplicationLockFile
61-
ccCore <- join $ finaliseCore <$>
62-
lastToEither "Unspecified ccCore" pccCore
61+
ccCore <- finaliseCore pccCore
6362
ccNTP <- lastToEither "Unspecified ccNTP" pccNTP
6463
ccUpdate <- lastToEither "Unspecified ccUpdate" pccUpdate
6564
ccTXP <- lastToEither "Unspecified ccTXP" pccTXP
6665
ccSSC <- lastToEither "Unspecified ccSSC" pccSSC
6766
ccDLG <- lastToEither "Unspecified ccDLG" pccDLG
68-
ccBlock <- join $ finaliseBlock <$>
69-
lastToEither "Unspecified ccBlock" pccBlock
67+
ccBlock <- finaliseBlock pccBlock
7068
ccNode <- join $ finaliseNode <$>
7169
lastToEither "Unspecified ccNode" pccNode
7270
ccTLS <- join $ finaliseTLS <$>
7371
lastToEither "Unspecified ccTLS" pccTLS
74-
ccWallet <- join $ finaliseWallet <$>
75-
lastToEither "Unspecified ccWallet" pccWallet
72+
ccWallet <- finaliseWallet pccWallet
7673

7774
pure CardanoConfiguration{..}
7875

src/Cardano/Shell/Constants/CLI.hs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ lastDoubleOption = lastAutoOption
4343
lastBoolOption :: Mod OptionFields Bool -> Parser (Last Bool)
4444
lastBoolOption = lastAutoOption
4545

46-
boolOption :: Mod OptionFields Bool -> Parser Bool
47-
boolOption = option auto
48-
4946
lastStrOption :: IsString a => Mod OptionFields a -> Parser (Last a)
5047
lastStrOption args = Last <$> optional (strOption args)
5148

@@ -54,8 +51,8 @@ lastStrOption args = Last <$> optional (strOption args)
5451
--------------------------------------------------------------------------------
5552

5653
-- | The parser for the logging specific arguments.
57-
configCoreCLIParser :: Parser (Last PartialCore)
58-
configCoreCLIParser = lastOption $ PartialCore
54+
configCoreCLIParser :: Parser PartialCore
55+
configCoreCLIParser = PartialCore
5956
<$> lastStrOption
6057
( long "genesis-file"
6158
<> metavar "FILEPATH"
@@ -154,9 +151,9 @@ configNodeCLIParser =
154151
--------------------------------------------------------------------------------
155152

156153
-- | Block CLI parser.
157-
configBlockCLIParser :: Parser (Last PartialBlock)
154+
configBlockCLIParser :: Parser PartialBlock
158155
configBlockCLIParser =
159-
lastOption $ PartialBlock
156+
PartialBlock
160157
<$> lastIntOption
161158
( long "network-diameter"
162159
<> metavar "NETWORK-DIAMETER-TIME"
@@ -245,9 +242,9 @@ configCertificateCLIParser =
245242
--------------------------------------------------------------------------------
246243

247244
-- | Wallet CLI parser.
248-
configWalletCLIParser :: Parser (Last PartialWallet)
245+
configWalletCLIParser :: Parser PartialWallet
249246
configWalletCLIParser =
250-
lastOption $ PartialWallet
247+
PartialWallet
251248
<$> lastBoolOption
252249
( long "th-enabled"
253250
<> metavar "TH-ENABLED"

src/Cardano/Shell/Constants/PartialTypes.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@ data PartialCardanoConfiguration = PartialCardanoConfiguration
2626
, pccLogConfig :: !(Last FilePath)
2727
, pccDBPath :: !(Last FilePath)
2828
, pccApplicationLockFile :: !(Last FilePath)
29-
, pccCore :: !(Last PartialCore)
29+
, pccCore :: !PartialCore
3030
, pccNTP :: !(Last NTP)
3131
, pccUpdate :: !(Last Update)
3232
, pccTXP :: !(Last TXP)
3333
, pccSSC :: !(Last SSC)
3434
, pccDLG :: !(Last DLG)
35-
, pccBlock :: !(Last PartialBlock)
35+
, pccBlock :: !PartialBlock
3636
, pccNode :: !(Last PartialNode)
3737
, pccTLS :: !(Last PartialTLS)
38-
, pccWallet :: !(Last PartialWallet)
38+
, pccWallet :: !PartialWallet
3939
} deriving (Eq, Show, Generic)
4040

4141
-- | Partial @Core@ configuration.

src/Cardano/Shell/Presets.hs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ mainnetConfiguration =
2929
, pccDBPath = pure "./db/"
3030
, pccApplicationLockFile = pure ""
3131
, pccCore =
32-
pure PartialCore
32+
PartialCore
3333
{ pcoGenesisFile = pure "mainnet-genesis.json"
3434
, pcoGenesisHash = pure "89d9b5a5b8ddc8d7e5a6795e9774d97faf1efea59b2caf7eaf9f8c5b32059df4"
3535
, pcoStaticKeySigningKeyFile = pure "TEST"
@@ -73,9 +73,9 @@ mainnetConfiguration =
7373
DLG { dlgCacheParam = 500
7474
, dlgMessageCacheTimeout = 30
7575
}
76-
, pccBlock = pure
76+
, pccBlock =
7777
PartialBlock
78-
{ pblNetworkDiameter = mempty --pure 18
78+
{ pblNetworkDiameter = pure 18
7979
, pblRecoveryHeadersMessage = pure 2200
8080
, pblStreamWindow = pure 2048
8181
, pblNonCriticalCQBootstrap = pure 0.95
@@ -125,7 +125,7 @@ mainnetConfiguration =
125125
}
126126
}
127127
, pccWallet =
128-
pure PartialWallet
128+
PartialWallet
129129
{ pthEnabled = pure False
130130
, pthRate = pure 0
131131
, pthPeriod = pure ""
@@ -145,7 +145,7 @@ devConfiguration =
145145
, pccLogConfig = pure "./log-config.yaml"
146146
, pccApplicationLockFile = pure ""
147147
, pccCore =
148-
pure PartialCore
148+
PartialCore
149149
{ pcoGenesisFile = pure "testnet-genesis.json"
150150
, pcoGenesisHash = pure "7f141ea26e189c9cb09e2473f6499561011d5d3c90dd642fde859ce02282a3ae"
151151
, pcoStaticKeySigningKeyFile = mempty
@@ -190,7 +190,7 @@ devConfiguration =
190190
{ dlgCacheParam = 500
191191
, dlgMessageCacheTimeout = 30
192192
}
193-
, pccBlock = pure
193+
, pccBlock =
194194
PartialBlock
195195
{ pblNetworkDiameter = pure 3
196196
, pblRecoveryHeadersMessage = pure 20
@@ -242,7 +242,7 @@ devConfiguration =
242242
}
243243
}
244244
, pccWallet =
245-
pure PartialWallet
245+
PartialWallet
246246
{ pthEnabled = pure False
247247
, pthRate = pure 0
248248
, pthPeriod = pure ""

0 commit comments

Comments
 (0)