diff --git a/apps/smp-server/Main.hs b/apps/smp-server/Main.hs index 03fc60990..d43c97193 100644 --- a/apps/smp-server/Main.hs +++ b/apps/smp-server/Main.hs @@ -3,9 +3,9 @@ module Main where import Simplex.Messaging.Server (runSMPServer) import Simplex.Messaging.Server.Env.STM -cfg :: Config +cfg :: ServerConfig cfg = - Config + ServerConfig { tcpPort = "5223", tbqSize = 16, queueIdBytes = 12, diff --git a/src/Simplex/Messaging/Server.hs b/src/Simplex/Messaging/Server.hs index 41b84ddb2..8e0de05d5 100644 --- a/src/Simplex/Messaging/Server.hs +++ b/src/Simplex/Messaging/Server.hs @@ -35,8 +35,8 @@ import UnliftIO.Exception import UnliftIO.IO import UnliftIO.STM -runSMPServer :: (MonadRandom m, MonadUnliftIO m) => Config -> m () -runSMPServer cfg@Config {tcpPort} = do +runSMPServer :: (MonadRandom m, MonadUnliftIO m) => ServerConfig -> m () +runSMPServer cfg@ServerConfig {tcpPort} = do env <- newEnv cfg runReaderT smpServer env where diff --git a/src/Simplex/Messaging/Server/Env/STM.hs b/src/Simplex/Messaging/Server/Env/STM.hs index 6a7bf0ed9..37324d65d 100644 --- a/src/Simplex/Messaging/Server/Env/STM.hs +++ b/src/Simplex/Messaging/Server/Env/STM.hs @@ -15,7 +15,7 @@ import Simplex.Messaging.Server.QueueStore.STM import Simplex.Messaging.Server.Transmission import UnliftIO.STM -data Config = Config +data ServerConfig = ServerConfig { tcpPort :: ServiceName, tbqSize :: Natural, queueIdBytes :: Int, @@ -23,7 +23,7 @@ data Config = Config } data Env = Env - { config :: Config, + { config :: ServerConfig, server :: Server, queueStore :: QueueStore, msgStore :: STMMsgStore, @@ -66,7 +66,7 @@ newSubscription = do delivered <- newEmptyTMVar return Sub {subThread = NoSub, delivered} -newEnv :: (MonadUnliftIO m, MonadRandom m) => Config -> m Env +newEnv :: (MonadUnliftIO m, MonadRandom m) => ServerConfig -> m Env newEnv config = do server <- atomically $ newServer (tbqSize config) queueStore <- atomically newQueueStore diff --git a/tests/SMPClient.hs b/tests/SMPClient.hs index f7bc3eb8d..9a122e035 100644 --- a/tests/SMPClient.hs +++ b/tests/SMPClient.hs @@ -31,9 +31,9 @@ testSMPClient client = do then client h else error "not connected" -cfg :: Config +cfg :: ServerConfig cfg = - Config + ServerConfig { tcpPort = testPort, tbqSize = 1, queueIdBytes = 12,