diff options
author | joe <joe@jerkface.net> | 2014-08-10 18:26:34 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2014-08-10 18:26:34 -0400 |
commit | 291b5b43374cf956fdd6a94639aac7969adae7f7 (patch) | |
tree | 4a283ee6388a02df3d94691a198b9fd8b05f0515 | |
parent | 8c9fc39fc4e40846db843fb6e49b1897c6c0e7ba (diff) |
renamed some variables in SybilLimit
-rw-r--r-- | SybilLimit.hs | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/SybilLimit.hs b/SybilLimit.hs index 91433ba..903ccd0 100644 --- a/SybilLimit.hs +++ b/SybilLimit.hs | |||
@@ -29,7 +29,7 @@ data ThisNode = ThisNode | |||
29 | -- ^ verificaiton counter by instance number. | 29 | -- ^ verificaiton counter by instance number. |
30 | , routeCount :: Int | 30 | , routeCount :: Int |
31 | -- ^ The r parameter of SybilLimit. | 31 | -- ^ The r parameter of SybilLimit. |
32 | , pendingVerifications :: Map NodeId PendingIntersection | 32 | , pendingChecks :: Map NodeId PendingSybilCheck |
33 | } | 33 | } |
34 | 34 | ||
35 | data FriendNode = FriendNode | 35 | data FriendNode = FriendNode |
@@ -44,12 +44,12 @@ data FriendNode = FriendNode | |||
44 | } | 44 | } |
45 | 45 | ||
46 | 46 | ||
47 | -- | When 'iPendingTails' is empty, the intersection condition is passed if and | 47 | -- | When 'sybPendingTails' is empty, the intersection condition is passed if and |
48 | -- only if 'iVerifiedTails' is not empty. | 48 | -- only if 'sybVerifiedTails' is not empty. |
49 | data PendingIntersection = PendingIntersection | 49 | data PendingSybilCheck = PendingSybilCheck |
50 | { iSuspect :: NodeId -- todo: neccessary? | 50 | { sybSuspect :: NodeId -- todo: neccessary? |
51 | , iPendingTails :: Map (NodeId,NodeId) [Int] | 51 | , sybPendingTails :: Map (NodeId,NodeId) [Int] |
52 | , iVerifiedTails :: Map (NodeId,NodeId) [Int] | 52 | , sybVerifiedTails :: Map (NodeId,NodeId) [Int] |
53 | } | 53 | } |
54 | 54 | ||
55 | data PeerMessage | 55 | data PeerMessage |
@@ -145,24 +145,24 @@ reactToMessage :: Int -> (NodeId,PeerMessage) -> ThisNode -> MessageReaction | |||
145 | reactToMessage w (srcId, msg@(RegistrationResponse {})) me = | 145 | reactToMessage w (srcId, msg@(RegistrationResponse {})) me = |
146 | MessageReaction me' [] sybils | 146 | MessageReaction me' [] sybils |
147 | where | 147 | where |
148 | me0 = me { pendingVerifications = vs' } | 148 | me0 = me { pendingChecks = vs' } |
149 | vs' :: Map NodeId PendingIntersection | 149 | vs' :: Map NodeId PendingSybilCheck |
150 | vs' = Map.adjust adj (rrSuspect msg) $ pendingVerifications me | 150 | vs' = Map.adjust adj (rrSuspect msg) $ pendingChecks me |
151 | tail = (rrRegisteredFrom msg, srcId) | 151 | tail = (rrRegisteredFrom msg, srcId) |
152 | adj p = p { iPendingTails = Map.delete tail $ iPendingTails p | 152 | adj p = p { sybPendingTails = Map.delete tail $ sybPendingTails p |
153 | , iVerifiedTails = | 153 | , sybVerifiedTails = |
154 | if rrValidRegistration msg then goodTail else iVerifiedTails p | 154 | if rrValidRegistration msg then goodTail else sybVerifiedTails p |
155 | } | 155 | } |
156 | where goodTail = Map.insert tail indexes | 156 | where goodTail = Map.insert tail indexes |
157 | $ iVerifiedTails p | 157 | $ sybVerifiedTails p |
158 | indexes = fromMaybe [] $ Map.lookup tail $ iPendingTails p | 158 | indexes = fromMaybe [] $ Map.lookup tail $ sybPendingTails p |
159 | icheck = pendingVerifications me0 Map.! rrSuspect msg | 159 | icheck = pendingChecks me0 Map.! rrSuspect msg |
160 | (me',sybils) = if Map.null (iPendingTails icheck) then bcheck else (me0, []) | 160 | (me',sybils) = if Map.null (sybPendingTails icheck) then bcheck else (me0, []) |
161 | where bcheck = if Map.null (iVerifiedTails icheck) | 161 | where bcheck = if Map.null (sybVerifiedTails icheck) |
162 | then (me0, dishonest) | 162 | then (me0, dishonest) |
163 | else balanceCheck | 163 | else balanceCheck |
164 | dishonest = [SybilCheck (rrSuspect msg) False] | 164 | dishonest = [SybilCheck (rrSuspect msg) False] |
165 | indexes = fromMaybe [] $ Map.lookup tail $ iVerifiedTails icheck | 165 | indexes = fromMaybe [] $ Map.lookup tail $ sybVerifiedTails icheck |
166 | balanceCheck = second chk $ balanceCondition tail indexes me0 | 166 | balanceCheck = second chk $ balanceCondition tail indexes me0 |
167 | where chk = (:[]) . SybilCheck (rrSuspect msg) | 167 | where chk = (:[]) . SybilCheck (rrSuspect msg) |
168 | second f (x,y) = (x,f y) | 168 | second f (x,y) = (x,f y) |