summaryrefslogtreecommitdiff
path: root/Announcer/Tox.hs
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2018-06-18 04:58:15 -0400
committerjoe <joe@jerkface.net>2018-06-18 04:58:15 -0400
commit2dbb1e710d6d58fc00126d84763ec3597d92437d (patch)
treeac9b3a9d13c1bd7f093492ab057175fe2c74fc2c /Announcer/Tox.hs
parentbbefd12b49de18f0608d2c2a0cbc52cab4266349 (diff)
Use combined IPv6/IPv4 announce item for announcing toxid.
Diffstat (limited to 'Announcer/Tox.hs')
-rw-r--r--Announcer/Tox.hs10
1 files changed, 4 insertions, 6 deletions
diff --git a/Announcer/Tox.hs b/Announcer/Tox.hs
index eab974bc..c9164d22 100644
--- a/Announcer/Tox.hs
+++ b/Announcer/Tox.hs
@@ -14,7 +14,6 @@ import Announcer
14import qualified Data.MinMaxPSQ as MM 14import qualified Data.MinMaxPSQ as MM
15import Data.Wrapper.PSQ as PSQ 15import Data.Wrapper.PSQ as PSQ
16import InterruptibleDelay 16import InterruptibleDelay
17import Network.Kademlia.Routing as R
18import Network.Kademlia.Search 17import Network.Kademlia.Search
19 18
20import Control.Concurrent.Lifted.Instrument 19import Control.Concurrent.Lifted.Instrument
@@ -68,9 +67,8 @@ data AnnounceMethod r = forall nid ni sr addr tok a.
68 -- [Right] The action requires a "token" from the destination 67 -- [Right] The action requires a "token" from the destination
69 -- node. This is the more typical "announce" semantics for 68 -- node. This is the more typical "announce" semantics for
70 -- Kademlia. 69 -- Kademlia.
71 , aBuckets :: TVar (R.BucketList ni) 70 , aNearestNodes :: nid -> STM [ni]
72 -- ^ Set this to the current Kademlia routing table buckets. 71 -- ^ Method to obtain starting nodes from an iterative Kademlia search.
73 -- TODO: List of TVars to have separate routing tables for IPv6 and IPv4?
74 , aTarget :: nid 72 , aTarget :: nid
75 -- ^ This is the Kademlia node-id of the item being announced. 73 -- ^ This is the Kademlia node-id of the item being announced.
76 , aInterval :: POSIXTime 74 , aInterval :: POSIXTime
@@ -118,7 +116,7 @@ reAnnounce checkFin announce interval = \announcer k now -> do
118 116
119-- | Schedule a recurring Search + Announce sequence. 117-- | Schedule a recurring Search + Announce sequence.
120schedule :: Announcer -> AnnounceKey -> AnnounceMethod r -> r -> IO () 118schedule :: Announcer -> AnnounceKey -> AnnounceMethod r -> r -> IO ()
121schedule announcer k AnnounceMethod{aSearch,aPublish,aBuckets,aTarget,aInterval} r = do 119schedule announcer k AnnounceMethod{aSearch,aPublish,aNearestNodes,aTarget,aInterval} r = do
122 st <- atomically $ newSearch aSearch aTarget [] 120 st <- atomically $ newSearch aSearch aTarget []
123 ns <- atomically $ newTVar MM.empty 121 ns <- atomically $ newTVar MM.empty
124 let astate = AnnounceState st ns 122 let astate = AnnounceState st ns
@@ -156,7 +154,7 @@ schedule announcer k AnnounceMethod{aSearch,aPublish,aBuckets,aTarget,aInterval}
156 isfin <- searchIsFinished st -- Always True, since we canceled. 154 isfin <- searchIsFinished st -- Always True, since we canceled.
157 return $ when isfin $ void $ fork search 155 return $ when isfin $ void $ fork search
158 search = do -- thread to fork 156 search = do -- thread to fork
159 atomically $ reset aBuckets aSearch aTarget st 157 atomically $ reset aNearestNodes aSearch aTarget st
160 searchLoop aSearch aTarget onResult st 158 searchLoop aSearch aTarget onResult st
161 fork $ do -- Announce to any nodes we haven't already announced to. 159 fork $ do -- Announce to any nodes we haven't already announced to.
162 is <- atomically $ do 160 is <- atomically $ do