Skip to content
This repository has been archived by the owner on Aug 18, 2020. It is now read-only.

Commit

Permalink
Merge pull request #3771 from input-output-hk/devops-1099
Browse files Browse the repository at this point in the history
[DEVOPS-1099] make the wallet documentation optional, and default it to off
  • Loading branch information
disassembler authored Nov 5, 2018
2 parents 88b1edc + cf68c04 commit ac25049
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 18 deletions.
4 changes: 2 additions & 2 deletions lib/src/Pos/Client/CLI/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ walletAddressOption na =
where
helpMsg = "IP and port for backend wallet API."

docAddressOption :: Maybe NetworkAddress -> Opt.Parser NetworkAddress
docAddressOption :: Maybe NetworkAddress -> Opt.Parser (Maybe NetworkAddress)
docAddressOption na =
Opt.option (fromParsec addrParser) $
Opt.optional $ Opt.option (fromParsec addrParser) $
Opt.long "wallet-doc-address"
<> Opt.metavar "IP:PORT"
<> Opt.help helpMsg
Expand Down
9 changes: 4 additions & 5 deletions wallet-new/src/Cardano/Wallet/Action.hs
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,16 @@ actionWithWallet params genesisConfig walletConfig txpConfig ntpConfig nodeParam
, unsupportedMimeTypeMiddleware
])

-- The corresponding wallet documention, served as a different
-- server which doesn't require client x509 certificates to
-- connect, but still serves the doc through TLS
, ("doc worker", Plugins.docServer params)

-- Periodically compact & snapshot the acid-state database.
, ("acid state cleanup", Plugins.acidStateSnapshots (view Kernel.Internal.wallets (snd w)) params dbMode)

-- A @Plugin@ to watch and store incoming update proposals
, ("update watcher", Plugins.updateWatcher)
]
-- The corresponding wallet documention, served as a different
-- server which doesn't require client x509 certificates to
-- connect, but still serves the doc through TLS
, maybe [] (pure . ("doc server",)) (Plugins.docServer params)
-- The monitoring API for the Core node.
, Plugins.monitoringServer params
]
Expand Down
6 changes: 3 additions & 3 deletions wallet-new/src/Cardano/Wallet/Server/CLI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ data WalletBackendParams = WalletBackendParams
-- ^ The TLS parameters.
, walletAddress :: !NetworkAddress
-- ^ The wallet address.
, walletDocAddress :: !NetworkAddress
, walletDocAddress :: !(Maybe NetworkAddress)
-- ^ The wallet documentation address.
, walletRunMode :: !RunMode
-- ^ The mode this node is running in.
Expand Down Expand Up @@ -157,8 +157,8 @@ walletBackendParamsParser = WalletBackendParams <$> enableMonitoringApiParser
addressParser :: Parser NetworkAddress
addressParser = CLI.walletAddressOption $ Just (localhost, 8090)

docAddressParser :: Parser NetworkAddress
docAddressParser = CLI.docAddressOption $ Just (localhost, 8091)
docAddressParser :: Parser (Maybe NetworkAddress)
docAddressParser = CLI.docAddressOption Nothing

runModeParser :: Parser RunMode
runModeParser = (\debugMode -> if debugMode then DebugMode else ProductionMode) <$>
Expand Down
6 changes: 3 additions & 3 deletions wallet-new/src/Cardano/Wallet/Server/LegacyPlugins.hs
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ walletDocumentation
:: (HasConfigurations, HasCompileInfo)
=> WalletBackendParams
-> Plugin WalletWebMode
walletDocumentation WalletBackendParams {..} = pure ("wallet doc worker", const worker)
walletDocumentation WalletBackendParams {..} = maybe [] (\addr -> [ ("wallet doc worker", const $ worker addr) ]) walletDocAddress
where
worker = walletDocumentationImpl
worker addr = walletDocumentationImpl
application
walletDocAddress
addr
tls
(Just defaultSettings)
Nothing
Expand Down
12 changes: 7 additions & 5 deletions wallet-new/src/Cardano/Wallet/Server/Plugins.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# LANGUAGE NamedFieldPuns #-}

{- | A collection of plugins used by this edge node.
A @Plugin@ is essentially a set of actions which will be run in
a particular monad, at some point in time.
Expand Down Expand Up @@ -124,17 +126,17 @@ apiServer (NewWalletBackendParams WalletBackendParams{..}) (passiveLayer, passiv
docServer
:: (HasConfigurations, HasCompileInfo)
=> NewWalletBackendParams
-> Plugin Kernel.WalletMode
docServer (NewWalletBackendParams WalletBackendParams{..}) = const $
serveDocImpl
-> Maybe (Plugin Kernel.WalletMode)
docServer (NewWalletBackendParams WalletBackendParams{walletDocAddress = Nothing}) = Nothing
docServer (NewWalletBackendParams WalletBackendParams{walletDocAddress = Just (ip, port), walletRunMode, walletTLSParams}) = Just (const $ makeWalletServer)
where
makeWalletServer = serveDocImpl
application
(BS8.unpack ip)
port
(if isDebugMode walletRunMode then Nothing else walletTLSParams)
(Just defaultSettings)
Nothing
where
(ip, port) = walletDocAddress

application :: Kernel.WalletMode Application
application =
Expand Down

0 comments on commit ac25049

Please sign in to comment.