Add fields to config
This commit is contained in:
parent
a60534a5c2
commit
b66d0d9563
4 changed files with 26 additions and 7 deletions
|
@ -205,11 +205,12 @@ main = do
|
|||
config <- load ["$(HOME)/Zenith/zenith.cfg"]
|
||||
args <- getArgs
|
||||
dbFilePath <- require config "dbFilePath"
|
||||
{-nodeUser <- require config "nodeUser"-}
|
||||
{-nodePwd <- require config "nodePwd"-}
|
||||
nodeUser <- require config "nodeUser"
|
||||
nodePwd <- require config "nodePwd"
|
||||
zebraPort <- require config "zebraPort"
|
||||
zebraHost <- require config "zebraHost"
|
||||
let myConfig = Config dbFilePath zebraHost zebraPort
|
||||
nodePort <- require config "nodePort"
|
||||
let myConfig = Config dbFilePath zebraHost zebraPort nodeUser nodePwd nodePort
|
||||
if not (null args)
|
||||
then do
|
||||
case head args
|
||||
|
|
|
@ -827,7 +827,13 @@ appEvent (BT.AppEvent t) = do
|
|||
_ <-
|
||||
liftIO $
|
||||
syncWallet
|
||||
(Config (s ^. dbPath) (s ^. zebraHost) (s ^. zebraPort))
|
||||
(Config
|
||||
(s ^. dbPath)
|
||||
(s ^. zebraHost)
|
||||
(s ^. zebraPort)
|
||||
"user"
|
||||
"pwd"
|
||||
8080)
|
||||
selWallet
|
||||
BT.modify $ set displayBox BlankDisplay
|
||||
BT.modify $ set barValue 0.0
|
||||
|
|
|
@ -92,12 +92,16 @@ data Config = Config
|
|||
{ c_dbPath :: !T.Text
|
||||
, c_zebraHost :: !T.Text
|
||||
, c_zebraPort :: !Int
|
||||
, c_zenithUser :: !BS.ByteString
|
||||
, c_zenithPwd :: !BS.ByteString
|
||||
, c_zenithPort :: !Int
|
||||
} deriving (Eq, Prelude.Show)
|
||||
|
||||
-- ** Zenith methods
|
||||
data ZenithMethod
|
||||
= GetInfo
|
||||
| Test
|
||||
| UnknownMethod
|
||||
deriving (Eq, Prelude.Show)
|
||||
|
||||
instance FromJSON ZenithMethod where
|
||||
|
@ -105,10 +109,11 @@ instance FromJSON ZenithMethod where
|
|||
withText "ZenithMethod" $ \case
|
||||
"getinfo" -> pure GetInfo
|
||||
"test" -> pure Test
|
||||
_ -> fail "Invalid method"
|
||||
_ -> pure UnknownMethod
|
||||
|
||||
data ZenithParams
|
||||
= GetInfoParams
|
||||
= BlankParams
|
||||
| BadParams
|
||||
| TestParams !T.Text
|
||||
deriving (Eq, Prelude.Show)
|
||||
|
||||
|
@ -127,7 +132,12 @@ instance FromJSON RpcCall where
|
|||
i <- obj .: "id"
|
||||
m <- obj .: "method"
|
||||
case m of
|
||||
GetInfo -> pure $ RpcCall v i GetInfo GetInfoParams
|
||||
UnknownMethod -> pure $ RpcCall v i UnknownMethod BlankParams
|
||||
GetInfo -> do
|
||||
p <- obj .: "params"
|
||||
if null (p :: [Value])
|
||||
then pure $ RpcCall v i GetInfo BlankParams
|
||||
else pure $ RpcCall v i GetInfo BadParams
|
||||
Test -> do
|
||||
p <- obj .: "params"
|
||||
pure $ RpcCall v i Test (TestParams $ head p)
|
||||
|
|
|
@ -47,6 +47,7 @@ library
|
|||
, base64-bytestring
|
||||
, brick
|
||||
, bytestring
|
||||
, configurator
|
||||
, data-default
|
||||
, directory
|
||||
, filepath
|
||||
|
@ -132,6 +133,7 @@ executable zenithserver
|
|||
app
|
||||
build-depends:
|
||||
base >=4.12 && <5
|
||||
, configurator
|
||||
, wai-extra
|
||||
, warp
|
||||
, servant-server
|
||||
|
|
Loading…
Reference in a new issue