diff options
author | Sam Truzjan <pxqr.sta@gmail.com> | 2014-01-02 17:57:55 +0400 |
---|---|---|
committer | Sam Truzjan <pxqr.sta@gmail.com> | 2014-01-02 17:57:55 +0400 |
commit | c8cb893aabfefa2274e789abbe05b312140b5523 (patch) | |
tree | 0e9f41e66bd2daaa1a5f0a0e74af70e0a9ad1935 | |
parent | 5d707daf963bdd13c1e3c16a2abf2006764ed170 (diff) |
Add non operator version of (<@>)
-rw-r--r-- | src/Network/BitTorrent/DHT/Session.hs | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/Network/BitTorrent/DHT/Session.hs b/src/Network/BitTorrent/DHT/Session.hs index a76880d7..a6c56d70 100644 --- a/src/Network/BitTorrent/DHT/Session.hs +++ b/src/Network/BitTorrent/DHT/Session.hs | |||
@@ -33,7 +33,11 @@ module Network.BitTorrent.DHT.Session | |||
33 | , getPeerList | 33 | , getPeerList |
34 | 34 | ||
35 | -- * Messaging | 35 | -- * Messaging |
36 | -- ** Initiate | ||
37 | , queryNode | ||
36 | , (<@>) | 38 | , (<@>) |
39 | |||
40 | -- ** Accept | ||
37 | , NodeHandler | 41 | , NodeHandler |
38 | , nodeHandler | 42 | , nodeHandler |
39 | ) where | 43 | ) where |
@@ -90,7 +94,7 @@ data Options = Options | |||
90 | , optK :: {-# UNPACK #-} !K | 94 | , optK :: {-# UNPACK #-} !K |
91 | 95 | ||
92 | -- | RPC timeout. | 96 | -- | RPC timeout. |
93 | , optTimeout :: {-# UNPACK #-} !NominalDiffTime | 97 | , optTimeout :: !NominalDiffTime |
94 | 98 | ||
95 | -- , optReannounceInterval :: NominalDiffTime | 99 | -- , optReannounceInterval :: NominalDiffTime |
96 | -- , optDataExpiredTimeout :: NominalDiffTime | 100 | -- , optDataExpiredTimeout :: NominalDiffTime |
@@ -312,9 +316,9 @@ getPeerList ih = do | |||
312 | -----------------------------------------------------------------------} | 316 | -----------------------------------------------------------------------} |
313 | 317 | ||
314 | -- | Throws exception if node is not responding. | 318 | -- | Throws exception if node is not responding. |
315 | (<@>) :: forall a b ip. Address ip => KRPC (Query a) (Response b) | 319 | queryNode :: forall a b ip. Address ip => KRPC (Query a) (Response b) |
316 | => a -> NodeAddr ip -> DHT ip b | 320 | => NodeAddr ip -> a -> DHT ip b |
317 | q <@> addr = do | 321 | queryNode addr q = do |
318 | nid <- getNodeId | 322 | nid <- getNodeId |
319 | 323 | ||
320 | let Method name = method :: Method (Query a) (Response b) | 324 | let Method name = method :: Method (Query a) (Response b) |
@@ -334,6 +338,12 @@ q <@> addr = do | |||
334 | insertNode (NodeInfo remoteId addr) | 338 | insertNode (NodeInfo remoteId addr) |
335 | return r | 339 | return r |
336 | 340 | ||
341 | -- | Infix version of 'queryNode' function. | ||
342 | (<@>) :: Address ip => KRPC (Query a) (Response b) | ||
343 | => a -> NodeAddr ip -> DHT ip b | ||
344 | (<@>) = flip queryNode | ||
345 | {-# INLINE (<@>) #-} | ||
346 | |||
337 | type NodeHandler ip = Handler (DHT ip) | 347 | type NodeHandler ip = Handler (DHT ip) |
338 | 348 | ||
339 | nodeHandler :: Address ip => KRPC (Query a) (Response b) | 349 | nodeHandler :: Address ip => KRPC (Query a) (Response b) |