summaryrefslogtreecommitdiff
path: root/src/Network/Tox/DHT/Handlers.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Network/Tox/DHT/Handlers.hs')
-rw-r--r--src/Network/Tox/DHT/Handlers.hs30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/Network/Tox/DHT/Handlers.hs b/src/Network/Tox/DHT/Handlers.hs
index d3d36525..c1f57177 100644
--- a/src/Network/Tox/DHT/Handlers.hs
+++ b/src/Network/Tox/DHT/Handlers.hs
@@ -150,24 +150,24 @@ newRouting addr crypto update4 update6 = do
150 SockAddrInet {} -> return Nothing 150 SockAddrInet {} -> return Nothing
151 _ -> global6 151 _ -> global6
152 atomically $ do 152 atomically $ do
153 let nobkts = R.defaultBucketCount :: Int 153 -- We defer initializing the refreshSearch and refreshPing until we
154 tbl4 <- newTVar $ R.nullTable (comparing nodeId) (\s -> hashWithSalt s . nodeId) tentative_info4 nobkts 154 -- have a client to send queries with.
155 tbl6 <- newTVar $ R.nullTable (comparing nodeId) (\s -> hashWithSalt s . nodeId) tentative_info6 nobkts 155 let nullPing = const $ return False
156 nullSearch = Search
157 { searchSpace = toxSpace
158 , searchNodeAddress = nodeIP &&& nodePort
159 , searchQuery = \_ _ -> return Nothing
160 }
161 refresher4 <- newBucketRefresher toxSpace tentative_info nullSearch nullPing
162 refresher6 <- newBucketRefresher toxSpace tentative_info6 nullSearch nullPing
163 let tbl4 = refreshBuckets refresher4
164 tbl6 = refreshBuckets refresher6
156 committee4 <- newTriadCommittee (update4 tbl4) -- updateIPVote tbl4 addr4 165 committee4 <- newTriadCommittee (update4 tbl4) -- updateIPVote tbl4 addr4
157 committee6 <- newTriadCommittee (update6 tbl6) -- updateIPVote tbl6 addr6 166 committee6 <- newTriadCommittee (update6 tbl6) -- updateIPVote tbl6 addr6
158 sched4 <- newTVar Int.empty
159 sched6 <- newTVar Int.empty
160 return $ \client -> 167 return $ \client ->
161 let refresher sched bkts = BucketRefresher 168 -- Now we have a client, so tell the BucketRefresher how to search and ping.
162 { refreshInterval = 15 * 60 169 let updIO r = updateRefresherIO (nodeSearch client) (ping client) r
163 , refreshQueue = sched 170 in Routing tentative_info committee4 committee6 (updIO refresher4) (updIO refresher6)
164 , refreshSearch = nodeSearch client
165 , refreshBuckets = bkts
166 , refreshPing = ping client
167 }
168 refresher4 = refresher sched4 tbl6
169 refresher6 = refresher sched6 tbl6
170 in Routing tentative_info committee4 committee6 refresher4 refresher6
171 171
172 172
173-- TODO: This should cover more cases 173-- TODO: This should cover more cases