@@ -111,9 +111,6 @@ module Simplex.Messaging.Agent
111
111
execAgentStoreSQL ,
112
112
getAgentMigrations ,
113
113
debugAgentLocks ,
114
- getAgentStats ,
115
- resetAgentStats ,
116
- getMsgCounts ,
117
114
getAgentSubscriptions ,
118
115
logConnection ,
119
116
)
@@ -126,7 +123,7 @@ import Control.Monad.Reader
126
123
import Control.Monad.Trans.Except
127
124
import Crypto.Random (ChaChaDRG )
128
125
import qualified Data.Aeson as J
129
- import Data.Bifunctor (bimap , first , second )
126
+ import Data.Bifunctor (bimap , first )
130
127
import Data.ByteString.Char8 (ByteString )
131
128
import qualified Data.ByteString.Char8 as B
132
129
import Data.Composition ((.:) , (.:.) , (.::) , (.::.) )
@@ -591,16 +588,6 @@ resetAgentServersStats :: AgentClient -> AE ()
591
588
resetAgentServersStats c = withAgentEnv c $ resetAgentServersStats' c
592
589
{-# INLINE resetAgentServersStats #-}
593
590
594
- getAgentStats :: AgentClient -> IO [(AgentStatsKey , Int )]
595
- getAgentStats c = readTVarIO (agentStats c) >>= mapM (\ (k, cnt) -> (k,) <$> readTVarIO cnt) . M. assocs
596
-
597
- resetAgentStats :: AgentClient -> IO ()
598
- resetAgentStats = atomically . TM. clear . agentStats
599
- {-# INLINE resetAgentStats #-}
600
-
601
- getMsgCounts :: AgentClient -> IO [(ConnId , (Int , Int ))] -- (total, duplicates)
602
- getMsgCounts c = readTVarIO (msgCounts c) >>= mapM (\ (connId, cnt) -> (connId,) <$> readTVarIO cnt) . M. assocs
603
-
604
591
withAgentEnv' :: AgentClient -> AM' a -> IO a
605
592
withAgentEnv' c = (`runReaderT` agentEnv c)
606
593
{-# INLINE withAgentEnv' #-}
@@ -2270,7 +2257,6 @@ processSMPTransmissions c@AgentClient {subQ} (tSess@(_, srv, _), _v, sessId, ts)
2270
2257
_ -> pure ()
2271
2258
let encryptedMsgHash = C. sha256Hash encAgentMessage
2272
2259
g <- asks random
2273
- atomically updateTotalMsgCount
2274
2260
tryAgentError (agentClientMsg g encryptedMsgHash) >>= \ case
2275
2261
Right (Just (msgId, msgMeta, aMessage, rcPrev)) -> do
2276
2262
conn'' <- resetRatchetSync
@@ -2304,7 +2290,6 @@ processSMPTransmissions c@AgentClient {subQ} (tSess@(_, srv, _), _v, sessId, ts)
2304
2290
| otherwise = pure conn'
2305
2291
Right Nothing -> prohibited " msg: bad agent msg" >> ack
2306
2292
Left e@ (AGENT A_DUPLICATE ) -> do
2307
- atomically updateDupMsgCount
2308
2293
atomically $ incSMPServerStat c userId srv recvDuplicates
2309
2294
withStore' c (\ db -> getLastMsg db connId srvMsgId) >>= \ case
2310
2295
Just RcvMsg {internalId, msgMeta, msgBody = agentMsgBody, userAck}
@@ -2339,20 +2324,6 @@ processSMPTransmissions c@AgentClient {subQ} (tSess@(_, srv, _), _v, sessId, ts)
2339
2324
checkDuplicateHash e encryptedMsgHash =
2340
2325
unlessM (withStore' c $ \ db -> checkRcvMsgHashExists db connId encryptedMsgHash) $
2341
2326
throwE e
2342
- updateTotalMsgCount :: STM ()
2343
- updateTotalMsgCount =
2344
- TM. lookup connId (msgCounts c) >>= \ case
2345
- Just v -> modifyTVar' v $ first (+ 1 )
2346
- Nothing -> addMsgCount 0
2347
- updateDupMsgCount :: STM ()
2348
- updateDupMsgCount =
2349
- TM. lookup connId (msgCounts c) >>= \ case
2350
- Just v -> modifyTVar' v $ second (+ 1 )
2351
- Nothing -> addMsgCount 1
2352
- addMsgCount :: Int -> STM ()
2353
- addMsgCount duplicate = do
2354
- counts <- newTVar (1 , duplicate)
2355
- TM. insert connId counts (msgCounts c)
2356
2327
agentClientMsg :: TVar ChaChaDRG -> ByteString -> AM (Maybe (InternalId , MsgMeta , AMessage , CR. RatchetX448 ))
2357
2328
agentClientMsg g encryptedMsgHash = withStore c $ \ db -> runExceptT $ do
2358
2329
rc <- ExceptT $ getRatchet db connId -- ratchet state pre-decryption - required for processing EREADY
0 commit comments