summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMateusz Kowalczyk <fuuzetsu@fuuzetsu.co.uk>2014-08-01 20:46:56 +0200
committerMateusz Kowalczyk <fuuzetsu@fuuzetsu.co.uk>2014-08-01 20:46:56 +0200
commitfbff2b6e4681b75b54a918baec9c49ba8f110d75 (patch)
tree1bf931c40200bd75dea7a89181ff5fcfd8b69e87 /src
parentc503cd761c21ad2c7d1ff2d2fe7595ad965ab4aa (diff)
isLeft is in base-4.7.x, this is cleaner than CPP
Diffstat (limited to 'src')
-rw-r--r--src/Network/BitTorrent/DHT/Query.hs6
1 files changed, 1 insertions, 5 deletions
diff --git a/src/Network/BitTorrent/DHT/Query.hs b/src/Network/BitTorrent/DHT/Query.hs
index d4710ecf..f7657490 100644
--- a/src/Network/BitTorrent/DHT/Query.hs
+++ b/src/Network/BitTorrent/DHT/Query.hs
@@ -127,17 +127,13 @@ findNodeQ key NodeInfo {..} = do
127 NodeFound closest <- FindNode (toNodeId key) <@> nodeAddr 127 NodeFound closest <- FindNode (toNodeId key) <@> nodeAddr
128 return $ Right closest 128 return $ Right closest
129 129
130isLeft :: Either a b -> Bool
131isLeft (Right _) = False
132isLeft (Left _) = True
133
134getPeersQ :: Address ip => InfoHash -> Iteration ip PeerAddr 130getPeersQ :: Address ip => InfoHash -> Iteration ip PeerAddr
135getPeersQ topic NodeInfo {..} = do 131getPeersQ topic NodeInfo {..} = do
136 GotPeers {..} <- GetPeers topic <@> nodeAddr 132 GotPeers {..} <- GetPeers topic <@> nodeAddr
137 let dist = distance (toNodeId topic) nodeId 133 let dist = distance (toNodeId topic) nodeId
138 $(logInfoS) "getPeersQ" $ T.pack 134 $(logInfoS) "getPeersQ" $ T.pack
139 $ "distance: " <> render (pretty dist) <> " , result: " 135 $ "distance: " <> render (pretty dist) <> " , result: "
140 <> if isLeft peers then "NODES" else "PEERS" 136 <> case peers of { Left _ -> "NODES"; Right _ -> "PEERS" }
141 return peers 137 return peers
142 138
143announceQ :: Address ip => InfoHash -> PortNumber -> Iteration ip NodeAddr 139announceQ :: Address ip => InfoHash -> PortNumber -> Iteration ip NodeAddr