summaryrefslogtreecommitdiff
path: root/src/Network/Tox.hs
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2018-06-19 16:34:03 -0400
committerjoe <joe@jerkface.net>2018-06-19 16:34:03 -0400
commita564eb632153b7e194c7b09fe646817d621c8f40 (patch)
tree2467c8beb405143e65060f40c344cd172af3e743 /src/Network/Tox.hs
parentc2df7b1192801862112a0f741014e27d490d12b3 (diff)
Slower onion queries improve performance.
Diffstat (limited to 'src/Network/Tox.hs')
-rw-r--r--src/Network/Tox.hs16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/Network/Tox.hs b/src/Network/Tox.hs
index ff42fb0d..4cff4f74 100644
--- a/src/Network/Tox.hs
+++ b/src/Network/Tox.hs
@@ -119,7 +119,6 @@ import Text.XXD
119import qualified Data.HashMap.Strict as HashMap 119import qualified Data.HashMap.Strict as HashMap
120import Data.HashMap.Strict (HashMap) 120import Data.HashMap.Strict (HashMap)
121import qualified Data.Map.Strict as Map 121import qualified Data.Map.Strict as Map
122import Control.Concurrent (threadDelay)
123import DPut 122import DPut
124import Network.Tox.Avahi 123import Network.Tox.Avahi
125 124
@@ -239,6 +238,8 @@ newClient drg net classify selfAddr handlers modifytbl modifynet = do
239 , clientPending = var 238 , clientPending = var
240 , clientAddress = selfAddr 239 , clientAddress = selfAddr
241 , clientResponseId = genNonce24 var 240 , clientResponseId = genNonce24 var
241 , clientEnterQuery = \_ -> return ()
242 , clientLeaveQuery = \_ _ -> return ()
242 } 243 }
243 in client 244 in client
244 return $ either mkclient mkclient tblvar handlers 245 return $ either mkclient mkclient tblvar handlers
@@ -407,6 +408,14 @@ getOnionAlias crypto dhtself remoteNode = atomically $ do
407 return $ Onion.OnionDestination Onion.SearchingAlias alias Nothing 408 return $ Onion.OnionDestination Onion.SearchingAlias alias Nothing
408 409
409 410
411retardSend micros client = do
412 mvar <- newMVar () :: IO (MVar ())
413 return client { clientEnterQuery = \tid -> do
414 takeMVar mvar
415 threadDelay micros
416 putMVar mvar ()
417 }
418
410newTox :: TVar Onion.AnnouncedKeys -- ^ Store of announced keys we are a rendezvous for. 419newTox :: TVar Onion.AnnouncedKeys -- ^ Store of announced keys we are a rendezvous for.
411 -> SockAddr -- ^ Bind-address to listen on. 420 -> SockAddr -- ^ Bind-address to listen on.
412 -> Maybe NetCryptoSessions -- ^ State of all one-on-one Tox links. 421 -> Maybe NetCryptoSessions -- ^ State of all one-on-one Tox links.
@@ -484,9 +493,12 @@ newTox keydb addr mbSessionsState suppliedDHTKey = do
484 (hookQueries orouter' DHT.transactionKey) 493 (hookQueries orouter' DHT.transactionKey)
485 (const id) 494 (const id)
486 495
496 -- onionclientSerialized <- serializeClient onionclient
497 onionRetarded <- retardSend 200000 onionclient
498
487 return Tox 499 return Tox
488 { toxDHT = dhtclient 500 { toxDHT = dhtclient
489 , toxOnion = onionclient 501 , toxOnion = onionRetarded
490 , toxToRoute = onInbound (updateContactInfo roster) dtacrypt 502 , toxToRoute = onInbound (updateContactInfo roster) dtacrypt
491 , toxCrypto = addHandler (hPutStrLn stderr) (sessionPacketH sessionsState) cryptonet 503 , toxCrypto = addHandler (hPutStrLn stderr) (sessionPacketH sessionsState) cryptonet
492 , toxHandshakes = addHandler (hPutStrLn stderr) (handshakeH sessionsState) handshakes 504 , toxHandshakes = addHandler (hPutStrLn stderr) (handshakeH sessionsState) handshakes