summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2017-10-20 23:00:41 -0400
committerjoe <joe@jerkface.net>2017-10-20 23:00:41 -0400
commit236a71b57d25b4061d1fd20d0930407c340cc6d9 (patch)
treed3353b5edf0e95aee60912b0e7e81c10b824881b
parent987915fb21ac824bfb8fc49c5cceb3aa0f1440c2 (diff)
Some comments.
-rw-r--r--OnionRouter.hs23
1 files 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
50 -- currently stored here. It is inferred from the lookup key. Instead, 50 -- currently stored here. It is inferred from the lookup key. Instead,
51 -- a 'Nothing' is stored. 51 -- a 'Nothing' is stored.
52 pendingQueries :: TVar (Word64Map (OnionDestination RouteId)) 52 pendingQueries :: TVar (Word64Map (OnionDestination RouteId))
53 -- | The current 12 routes that may be assigned to outgoing packets.
53 , routeMap :: TVar (IntMap RouteRecord) 54 , routeMap :: TVar (IntMap RouteRecord)
55 -- | A set of nodes used to query for random route nodes. These aren't
56 -- used directly in onion routes, they are queried for route nodes that
57 -- are nearby randomly selected ids.
58 --
59 -- These nodes are chosen from the kademlia buckets and when one of them
60 -- is evicted from a bucket, it is no longer used as a trampoline node.
61 --
62 -- Also, currently our own address is (unnecessarily) stored here at
63 -- index (-1).
54 , trampolineNodes :: TVar (IntMap NodeInfo) 64 , trampolineNodes :: TVar (IntMap NodeInfo)
65 -- | This map associates 'NodeId' values with the corresponding
66 -- 'trampolineNodes' index.
55 , trampolineIds :: TVar (HashMap NodeId Int) 67 , trampolineIds :: TVar (HashMap NodeId Int)
68 -- | Indicates the current size of 'trampolineNodes'.
56 , trampolineCount :: TVar Int 69 , trampolineCount :: TVar Int
70 -- | The pseudo-random generator used to select onion routes.
57 , onionDRG :: TVar ChaChaDRG 71 , onionDRG :: TVar ChaChaDRG
72 -- | Building onion routes happens in a dedicated thread. See 'forkRouteBuilder'.
58 , routeThread :: ThreadId 73 , routeThread :: ThreadId
74 -- | Each of the 12 routes has a flag here that is set True when the
75 -- route should be discarded and replaced with a fresh one.
59 , pendingRoutes :: IntMap (TVar Bool) 76 , pendingRoutes :: IntMap (TVar Bool)
77 -- | Debug prints are written to this channel which is then flushed to
78 -- stderr from within the 'routeThread'.
60 , routeLog :: TChan String 79 , routeLog :: TChan String
61 } 80 }
62 81
63data RouteRecord = RouteRecord 82data RouteRecord = RouteRecord
64 { storedRoute :: OnionRoute 83 { storedRoute :: OnionRoute
65 , responseCount :: !Int 84 , responseCount :: !Int
66 , timeoutCount :: !Int 85 , timeoutCount :: !Int
67 } 86 }
68 87
69-- Onion paths have different timeouts depending on whether the path is 88-- Onion paths have different timeouts depending on whether the path is