summaryrefslogtreecommitdiff
path: root/src/Network/Tox.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Network/Tox.hs')
-rw-r--r--src/Network/Tox.hs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/Network/Tox.hs b/src/Network/Tox.hs
index af8114f4..c587578d 100644
--- a/src/Network/Tox.hs
+++ b/src/Network/Tox.hs
@@ -155,6 +155,9 @@ gen g = let (bs, g') = randomBytesGenerate 24 g
155intKey :: DHT.TransactionId -> Int 155intKey :: DHT.TransactionId -> Int
156intKey (DHT.TransactionId (Nonce8 w) _) = fromIntegral w 156intKey (DHT.TransactionId (Nonce8 w) _) = fromIntegral w
157 157
158w64Key :: DHT.TransactionId -> Word64
159w64Key (DHT.TransactionId (Nonce8 w) _) = w
160
158nonceKey :: DHT.TransactionId -> Nonce8 161nonceKey :: DHT.TransactionId -> Nonce8
159nonceKey (DHT.TransactionId n _) = n 162nonceKey (DHT.TransactionId n _) = n
160 163
@@ -178,6 +181,7 @@ newClient drg net classify selfAddr handlers modifytbl modifynet = do
178 -- If we have 8-byte keys for IntMap, then use it for transaction lookups. 181 -- If we have 8-byte keys for IntMap, then use it for transaction lookups.
179 -- Otherwise, use ordinary Map. The details of which will be hidden by an 182 -- Otherwise, use ordinary Map. The details of which will be hidden by an
180 -- existential closure (see mkclient below). 183 -- existential closure (see mkclient below).
184 --
181 tblvar <- 185 tblvar <-
182 if fitsInInt (Proxy :: Proxy Word64) 186 if fitsInInt (Proxy :: Proxy Word64)
183 then do 187 then do
@@ -185,9 +189,9 @@ newClient drg net classify selfAddr handlers modifytbl modifynet = do
185 intmap_var <- atomically $ newTVar (drg, mempty) 189 intmap_var <- atomically $ newTVar (drg, mempty)
186 return $ Right (intmapT,intmap_var) 190 return $ Right (intmapT,intmap_var)
187 else do 191 else do
188 let mapT = transactionMethods (contramap nonceKey mapMethods) gen 192 let word64mapT = transactionMethods (contramap w64key w64MapMethods) gen
189 map_var <- atomically $ newTVar (drg, mempty) 193 map_var <- atomically $ newTVar (drg, mempty)
190 return $ Left (mapT,map_var) 194 return $ Left (word64mapT,map_var)
191 let dispatch tbl var handlers = DispatchMethods 195 let dispatch tbl var handlers = DispatchMethods
192 { classifyInbound = classify 196 { classifyInbound = classify
193 , lookupHandler = handlers -- var 197 , lookupHandler = handlers -- var