diff options
author | joe <joe@jerkface.net> | 2018-06-17 21:29:50 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2018-06-17 21:29:50 -0400 |
commit | faf3144fe3a2781db381f5ad722a3a3bfe375061 (patch) | |
tree | 9639236dee4eff67476859540eb4f5fd31428a82 /Connection | |
parent | eda92679a6d7d27ebb5757ba7056fc452384faac (diff) |
Connection.Tox: Deleted dead code.
Diffstat (limited to 'Connection')
-rw-r--r-- | Connection/Tox.hs | 40 |
1 files changed, 10 insertions, 30 deletions
diff --git a/Connection/Tox.hs b/Connection/Tox.hs index 0156806e..7b304050 100644 --- a/Connection/Tox.hs +++ b/Connection/Tox.hs | |||
@@ -85,16 +85,10 @@ launch lbl st f = do | |||
85 | return $ StatefulTask tid stvar | 85 | return $ StatefulTask tid stvar |
86 | 86 | ||
87 | 87 | ||
88 | data SessionTasks = SessionTasks | ||
89 | { persuing :: StatefulTask (G.Status ToxProgress) | ||
90 | , refreshing :: StatefulTask (G.Status ToxProgress) | ||
91 | } | ||
92 | |||
93 | data SessionState = SessionState | 88 | data SessionState = SessionState |
94 | { connPolicy :: TVar Policy | 89 | { connPolicy :: TVar Policy |
95 | , connPingLogic :: PingMachine | 90 | , connPingLogic :: PingMachine |
96 | , sessionTasks :: TVar SessionTasks | 91 | , handshakeTask :: TVar (StatefulTask (G.Status ToxProgress)) |
97 | -- , transient :: TVar (DSum Transient Identity) | ||
98 | } | 92 | } |
99 | 93 | ||
100 | newSessionState :: IO SessionState | 94 | newSessionState :: IO SessionState |
@@ -103,27 +97,19 @@ newSessionState = do | |||
103 | 25000 -- 25 ms send ping | 97 | 25000 -- 25 ms send ping |
104 | 30000 -- 30 ms timed out | 98 | 30000 -- 30 ms timed out |
105 | a <- fork $ return () | 99 | a <- fork $ return () |
106 | b <- fork $ return () | ||
107 | atomically $ do | 100 | atomically $ do |
108 | av <- newTVar G.Dormant | 101 | av <- newTVar G.Dormant |
109 | bv <- newTVar G.Dormant | 102 | let tasks = StatefulTask a av |
110 | let tasks = SessionTasks (StatefulTask a av) (StatefulTask b bv) | ||
111 | SessionState <$> newTVar G.RefusingToConnect <*> pure pings <*> newTVar tasks | 103 | SessionState <$> newTVar G.RefusingToConnect <*> pure pings <*> newTVar tasks |
112 | 104 | ||
113 | 105 | ||
114 | sessionStatus :: SessionState -> G.Connection ToxProgress | 106 | sessionStatus :: SessionState -> G.Connection ToxProgress |
115 | sessionStatus st = G.Connection | 107 | sessionStatus st = G.Connection |
116 | { G.connStatus = combinedStatus =<< readTVar (sessionTasks st) | 108 | { G.connStatus = readTVar . taskState =<< readTVar (handshakeTask st) |
117 | , G.connPolicy = readTVar (connPolicy st) | 109 | , G.connPolicy = readTVar (connPolicy st) |
118 | , G.connPingLogic = connPingLogic st | 110 | , G.connPingLogic = connPingLogic st |
119 | } | 111 | } |
120 | 112 | ||
121 | combinedStatus :: SessionTasks -> STM (G.Status ToxProgress) | ||
122 | combinedStatus tasks = do | ||
123 | p <- readTVar (taskState $ persuing tasks) | ||
124 | r <- readTVar (taskState $ refreshing tasks) | ||
125 | return $ maximum [p,r] | ||
126 | |||
127 | lookupForPolicyChange :: TVar (Map.Map Key SessionState) | 113 | lookupForPolicyChange :: TVar (Map.Map Key SessionState) |
128 | -> Key -> Policy -> IO (Maybe SessionState) | 114 | -> Key -> Policy -> IO (Maybe SessionState) |
129 | lookupForPolicyChange conmap k policy = do | 115 | lookupForPolicyChange conmap k policy = do |
@@ -195,17 +181,12 @@ setToxPolicy params conmap k@(Key me them) policy = do | |||
195 | hPutStrLn stderr $ "C.mst="++show (fmap (const ()) mst) | 181 | hPutStrLn stderr $ "C.mst="++show (fmap (const ()) mst) |
196 | forM_ mst $ \st -> do | 182 | forM_ mst $ \st -> do |
197 | let getPolicy = readTVar $ connPolicy st | 183 | let getPolicy = readTVar $ connPolicy st |
198 | tasks <- atomically $ readTVar (sessionTasks st) | 184 | tasks <- atomically $ readTVar (handshakeTask st) |
199 | persuing <- launch ("persue:"++show k) | 185 | persuing <- launch ("persue:"++show k) |
200 | (G.InProgress $ toEnum 0) | 186 | (G.InProgress $ toEnum 0) |
201 | $ persueContact getPolicy get_status persue_methods | 187 | $ persueContact getPolicy get_status persue_methods |
202 | {- | ||
203 | refreshing <- launch ("refresh:"++show k) | ||
204 | (G.InProgress $ toEnum 0) | ||
205 | $ freshenContact getPolicy get_status freshen_methods | ||
206 | -} | ||
207 | atomically $ do | 188 | atomically $ do |
208 | writeTVar (sessionTasks st) $ SessionTasks persuing _refreshing | 189 | writeTVar (handshakeTask st) $ persuing |
209 | let routing = dhtRouting params | 190 | let routing = dhtRouting params |
210 | Key _ nid = k | 191 | Key _ nid = k |
211 | registerNodeCallback routing $ NodeInfoCallback | 192 | registerNodeCallback routing $ NodeInfoCallback |
@@ -231,12 +212,11 @@ setToxPolicy params conmap k@(Key me them) policy = do | |||
231 | Key _ nid = k | 212 | Key _ nid = k |
232 | unregisterNodeCallback callbackId routing nid | 213 | unregisterNodeCallback callbackId routing nid |
233 | atomically $ do | 214 | atomically $ do |
234 | tasks <- readTVar (sessionTasks st) | 215 | tasks <- readTVar (handshakeTask st) |
235 | p <- readTVar $ taskState (persuing tasks) | 216 | p <- readTVar $ taskState tasks |
236 | r <- readTVar $ taskState (refreshing tasks) | 217 | case p of |
237 | case (p,r) of | 218 | G.Dormant -> return () |
238 | (G.Dormant,G.Dormant) -> return () | 219 | _ -> retry |
239 | _ -> retry | ||
240 | OpenToConnect -> do -- passively accept connections if they initiate. | 220 | OpenToConnect -> do -- passively accept connections if they initiate. |
241 | mst <- lookupForPolicyChange conmap k policy | 221 | mst <- lookupForPolicyChange conmap k policy |
242 | r <- atomically $ lookupContact k (roster params) | 222 | r <- atomically $ lookupContact k (roster params) |