diff options
-rw-r--r-- | src/Network/Tox/Onion/Handlers.hs | 25 |
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) | |||
142 | toOnionDestination :: AnnouncedRoute -> OnionDestination r | 142 | toOnionDestination :: AnnouncedRoute -> OnionDestination r |
143 | toOnionDestination (AnnouncedRoute ni rpath) = OnionToOwner ni rpath | 143 | toOnionDestination (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 | -- | ||
145 | data AnnouncedKeys = AnnouncedKeys | 160 | data 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 | ||