summaryrefslogtreecommitdiff
path: root/src/Network/Tox/Onion/Handlers.hs
diff options
context:
space:
mode:
authorJames Crayne <jim.crayne@gmail.com>2018-05-24 21:19:21 +0000
committerJames Crayne <jim.crayne@gmail.com>2018-05-24 21:19:21 +0000
commit4c1ddc8c38841cf1e72871d781d92e9b16b8cdb5 (patch)
tree056bf2e2141ec5fdb22a4416b0aada4729dece86 /src/Network/Tox/Onion/Handlers.hs
parent32d1428b8ca30a8d8fb334a126895afe5f54b611 (diff)
Document AnnouncedKeys type
Diffstat (limited to 'src/Network/Tox/Onion/Handlers.hs')
-rw-r--r--src/Network/Tox/Onion/Handlers.hs25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/Network/Tox/Onion/Handlers.hs b/src/Network/Tox/Onion/Handlers.hs
index af515315..8c3a9a86 100644
--- a/src/Network/Tox/Onion/Handlers.hs
+++ b/src/Network/Tox/Onion/Handlers.hs
@@ -142,9 +142,30 @@ data AnnouncedRoute = AnnouncedRoute NodeInfo (ReturnPath N3)
142toOnionDestination :: AnnouncedRoute -> OnionDestination r 142toOnionDestination :: AnnouncedRoute -> OnionDestination r
143toOnionDestination (AnnouncedRoute ni rpath) = OnionToOwner ni rpath 143toOnionDestination (AnnouncedRoute ni rpath) = OnionToOwner ni rpath
144 144
145-- |
146-- The type 'NodeId' was originally made for the DHT key, but here
147-- we reuse it for user keys (public key/real key).
148--
149-- To find someone using their user (public) key, you search for it on
150-- kademlia. At each iteration of the search, you get a response with
151-- closest known nodes(DHT keys) to the key you are searching for.
152--
153-- To do an 'Announce' so your friends can find you, you do a search to
154-- find the closest nodes to your own user(public) key. At those nodes,
155-- you store a route back to yourself (using Announce message) so your
156-- friends can contact you. This means each node needs to store the
157-- saved routes, and that is the purpose of the 'AnnouncedKeys' data
158-- structure.
159--
145data AnnouncedKeys = AnnouncedKeys 160data AnnouncedKeys = AnnouncedKeys
146 { keyByAge :: !(PSQ NodeId (Down POSIXTime)) -- TODO: timeout of 300 seconds 161 { keyByAge :: !(PSQ NodeId (Down POSIXTime{-Time at which they announced to you-})) -- TODO: timeout of 300 seconds
147 , keyAssoc :: !(MinMaxPSQ' NodeId NodeDistance (Int,AnnouncedRoute)) 162 , keyAssoc :: !(MinMaxPSQ' NodeId NodeDistance (Int{-count of route usage-},AnnouncedRoute))
163 -- ^ PSQ using NodeId(user/public key) as Key
164 -- and using 'NodeDistance' as priority.
165 -- (smaller number is higher priority)
166 --
167 -- Keeping in a MinMaxPSQ will help us later when we want to make the structure
168 -- bounded. (We simply throw away the most NodeDistant keys.
148 } 169 }
149 170
150 171