From 291b5b43374cf956fdd6a94639aac7969adae7f7 Mon Sep 17 00:00:00 2001 From: joe Date: Sun, 10 Aug 2014 18:26:34 -0400 Subject: renamed some variables in SybilLimit --- SybilLimit.hs | 38 +++++++++++++++++++------------------- 1 file 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 -- ^ verificaiton counter by instance number. , routeCount :: Int -- ^ The r parameter of SybilLimit. - , pendingVerifications :: Map NodeId PendingIntersection + , pendingChecks :: Map NodeId PendingSybilCheck } data FriendNode = FriendNode @@ -44,12 +44,12 @@ data FriendNode = FriendNode } --- | When 'iPendingTails' is empty, the intersection condition is passed if and --- only if 'iVerifiedTails' is not empty. -data PendingIntersection = PendingIntersection - { iSuspect :: NodeId -- todo: neccessary? - , iPendingTails :: Map (NodeId,NodeId) [Int] - , iVerifiedTails :: Map (NodeId,NodeId) [Int] +-- | When 'sybPendingTails' is empty, the intersection condition is passed if and +-- only if 'sybVerifiedTails' is not empty. +data PendingSybilCheck = PendingSybilCheck + { sybSuspect :: NodeId -- todo: neccessary? + , sybPendingTails :: Map (NodeId,NodeId) [Int] + , sybVerifiedTails :: Map (NodeId,NodeId) [Int] } data PeerMessage @@ -145,24 +145,24 @@ reactToMessage :: Int -> (NodeId,PeerMessage) -> ThisNode -> MessageReaction reactToMessage w (srcId, msg@(RegistrationResponse {})) me = MessageReaction me' [] sybils where - me0 = me { pendingVerifications = vs' } - vs' :: Map NodeId PendingIntersection - vs' = Map.adjust adj (rrSuspect msg) $ pendingVerifications me + me0 = me { pendingChecks = vs' } + vs' :: Map NodeId PendingSybilCheck + vs' = Map.adjust adj (rrSuspect msg) $ pendingChecks me tail = (rrRegisteredFrom msg, srcId) - adj p = p { iPendingTails = Map.delete tail $ iPendingTails p - , iVerifiedTails = - if rrValidRegistration msg then goodTail else iVerifiedTails p + adj p = p { sybPendingTails = Map.delete tail $ sybPendingTails p + , sybVerifiedTails = + if rrValidRegistration msg then goodTail else sybVerifiedTails p } where goodTail = Map.insert tail indexes - $ iVerifiedTails p - indexes = fromMaybe [] $ Map.lookup tail $ iPendingTails p - icheck = pendingVerifications me0 Map.! rrSuspect msg - (me',sybils) = if Map.null (iPendingTails icheck) then bcheck else (me0, []) - where bcheck = if Map.null (iVerifiedTails icheck) + $ sybVerifiedTails p + indexes = fromMaybe [] $ Map.lookup tail $ sybPendingTails p + icheck = pendingChecks me0 Map.! rrSuspect msg + (me',sybils) = if Map.null (sybPendingTails icheck) then bcheck else (me0, []) + where bcheck = if Map.null (sybVerifiedTails icheck) then (me0, dishonest) else balanceCheck dishonest = [SybilCheck (rrSuspect msg) False] - indexes = fromMaybe [] $ Map.lookup tail $ iVerifiedTails icheck + indexes = fromMaybe [] $ Map.lookup tail $ sybVerifiedTails icheck balanceCheck = second chk $ balanceCondition tail indexes me0 where chk = (:[]) . SybilCheck (rrSuspect msg) second f (x,y) = (x,f y) -- cgit v1.2.3