diff options
Diffstat (limited to 'dht/Announcer/Tox.hs')
-rw-r--r-- | dht/Announcer/Tox.hs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/dht/Announcer/Tox.hs b/dht/Announcer/Tox.hs index 38e5bbfa..58b6621b 100644 --- a/dht/Announcer/Tox.hs +++ b/dht/Announcer/Tox.hs | |||
@@ -13,6 +13,8 @@ module Announcer.Tox where | |||
13 | import Announcer | 13 | import Announcer |
14 | import qualified Data.MinMaxPSQ as MM | 14 | import qualified Data.MinMaxPSQ as MM |
15 | import Data.Wrapper.PSQ as PSQ | 15 | import Data.Wrapper.PSQ as PSQ |
16 | import DebugTag | ||
17 | import DPut | ||
16 | import Network.Kademlia.Search | 18 | import Network.Kademlia.Search |
17 | 19 | ||
18 | import Control.Concurrent.Lifted.Instrument | 20 | import Control.Concurrent.Lifted.Instrument |
@@ -36,6 +38,7 @@ data AnnounceState = forall nid addr tok ni r qk. AnnounceState | |||
36 | -- a Kademlia network. | 38 | -- a Kademlia network. |
37 | data AnnounceMethod r = forall nid ni sr addr tok a qk. | 39 | data AnnounceMethod r = forall nid ni sr addr tok a qk. |
38 | ( Show nid | 40 | ( Show nid |
41 | , Show ni | ||
39 | , Hashable nid | 42 | , Hashable nid |
40 | , Hashable ni | 43 | , Hashable ni |
41 | , Ord addr | 44 | , Ord addr |
@@ -175,11 +178,21 @@ scheduleAnnounce announcer k AnnounceMethod{aSearch,aPublish,aNearestNodes,aTar | |||
175 | nq <- readTVar ns | 178 | nq <- readTVar ns |
176 | return $ filter (\(Binding ni _ _) -> not $ isJust $ MM.lookup' ni nq) | 179 | return $ filter (\(Binding ni _ _) -> not $ isJust $ MM.lookup' ni nq) |
177 | $ MM.toList bs | 180 | $ MM.toList bs |
181 | let ns = map (\(Binding ni mtok _) -> ni) is | ||
182 | dput XPublish $ unlines $ "Announcing to nodes of finished search." | ||
183 | : map (mappend " " . show) ns | ||
178 | publishToNodes is | 184 | publishToNodes is |
179 | putMVar mutex () | 185 | putMVar mutex () |
180 | Nothing -> do | 186 | Nothing -> do |
181 | -- Previous search did not finish. Instead of starting a new search, | 187 | -- Previous search did not finish. Instead of starting a new search, |
182 | -- we will re-announce only. | 188 | -- we will re-announce only. |
189 | do | ||
190 | is <- atomically $ do | ||
191 | bs <- readTVar (searchInformant st {- :: TVar (MinMaxPSQ' ni nid tok -}) | ||
192 | return $ MM.toList bs | ||
193 | let ns = map (\(Binding ni mtok _) -> ni) is | ||
194 | dput XPublish $ unlines $ "Announcing to nodes of in-progress search." | ||
195 | : map (mappend " " . show) ns | ||
183 | announce | 196 | announce |
184 | -- Cancel search so that a new one can start in the nest period. | 197 | -- Cancel search so that a new one can start in the nest period. |
185 | atomically $ searchCancel st | 198 | atomically $ searchCancel st |