zgo-backend/app/Main.hs

35 lines
877 B
Haskell
Raw Normal View History

2022-04-22 16:15:23 +00:00
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Control.Concurrent (forkIO, threadDelay)
import Data.SecureMem
import qualified Data.Text as T
import Database.MongoDB
import ZGoBackend
passkey :: SecureMem
passkey = secureMemFromByteString "superSecret"
nodeAddress :: T.Text
nodeAddress =
"zs1xnpqd2tae9d95f8fhe4l0q7j44a5vf993m0pcnnvr56uqr4lgqlamesk5v4c5rhtvywc6lvlduy"
dbUser :: T.Text
dbUser = "zgo"
dbPassword :: T.Text
dbPassword = "zcashrules"
main :: IO ()
main = do
putStrLn "Starting Server..."
pipe <- connect $ host "127.0.0.1"
2022-04-30 12:59:49 +00:00
j <- access pipe master "zgo" (auth dbUser dbPassword)
2022-05-17 17:47:27 +00:00
_ <- forkIO (setInterval 60 (checkZcashPrices pipe "zgo"))
_ <- forkIO (setInterval 75 (scanZcash nodeAddress pipe "zgo"))
2022-04-22 16:15:23 +00:00
if j
then putStrLn "Connected to MongoDB!"
else fail "MongoDB connection failed!"
2022-04-30 12:59:49 +00:00
app pipe "zgo" passkey nodeAddress