From 236a71b57d25b4061d1fd20d0930407c340cc6d9 Mon Sep 17 00:00:00 2001 From: joe Date: Fri, 20 Oct 2017 23:00:41 -0400 Subject: Some comments. --- OnionRouter.hs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/OnionRouter.hs b/OnionRouter.hs index 7125fa10..9467f626 100644 --- a/OnionRouter.hs +++ b/OnionRouter.hs @@ -50,20 +50,39 @@ data OnionRouter = OnionRouter -- currently stored here. It is inferred from the lookup key. Instead, -- a 'Nothing' is stored. pendingQueries :: TVar (Word64Map (OnionDestination RouteId)) + -- | The current 12 routes that may be assigned to outgoing packets. , routeMap :: TVar (IntMap RouteRecord) + -- | A set of nodes used to query for random route nodes. These aren't + -- used directly in onion routes, they are queried for route nodes that + -- are nearby randomly selected ids. + -- + -- These nodes are chosen from the kademlia buckets and when one of them + -- is evicted from a bucket, it is no longer used as a trampoline node. + -- + -- Also, currently our own address is (unnecessarily) stored here at + -- index (-1). , trampolineNodes :: TVar (IntMap NodeInfo) + -- | This map associates 'NodeId' values with the corresponding + -- 'trampolineNodes' index. , trampolineIds :: TVar (HashMap NodeId Int) + -- | Indicates the current size of 'trampolineNodes'. , trampolineCount :: TVar Int + -- | The pseudo-random generator used to select onion routes. , onionDRG :: TVar ChaChaDRG + -- | Building onion routes happens in a dedicated thread. See 'forkRouteBuilder'. , routeThread :: ThreadId + -- | Each of the 12 routes has a flag here that is set True when the + -- route should be discarded and replaced with a fresh one. , pendingRoutes :: IntMap (TVar Bool) + -- | Debug prints are written to this channel which is then flushed to + -- stderr from within the 'routeThread'. , routeLog :: TChan String } data RouteRecord = RouteRecord - { storedRoute :: OnionRoute + { storedRoute :: OnionRoute , responseCount :: !Int - , timeoutCount :: !Int + , timeoutCount :: !Int } -- Onion paths have different timeouts depending on whether the path is -- cgit v1.2.3