summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSam Truzjan <pxqr.sta@gmail.com>2014-02-19 23:34:58 +0400
committerSam Truzjan <pxqr.sta@gmail.com>2014-02-19 23:34:58 +0400
commit60f38ddcf742883f4028c659e2abdb245e8e473a (patch)
tree6f9e906e1a918fde5e5ce4e26c209b08a5c0df4a /src
parent333347b468b33faf4a97a25be15de24fcf5d5601 (diff)
Link query handlers to the underlying messages in documentation
Diffstat (limited to 'src')
-rw-r--r--src/Network/BitTorrent/DHT/Query.hs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/Network/BitTorrent/DHT/Query.hs b/src/Network/BitTorrent/DHT/Query.hs
index 9c52220e..4ba88b46 100644
--- a/src/Network/BitTorrent/DHT/Query.hs
+++ b/src/Network/BitTorrent/DHT/Query.hs
@@ -72,21 +72,25 @@ nodeHandler action = handler $ \ sockAddr (Query remoteId q) -> do
72 case fromSockAddr sockAddr of 72 case fromSockAddr sockAddr of
73 Nothing -> throwIO BadAddress 73 Nothing -> throwIO BadAddress
74 Just naddr -> do 74 Just naddr -> do
75 insertNode (NodeInfo remoteId naddr) 75 insertNode (NodeInfo remoteId naddr) -- TODO need to block. why?
76 Response <$> asks thisNodeId <*> action naddr q 76 Response <$> asks thisNodeId <*> action naddr q
77 77
78-- | Default 'Ping' handler.
78pingH :: Address ip => NodeHandler ip 79pingH :: Address ip => NodeHandler ip
79pingH = nodeHandler $ \ _ Ping -> do 80pingH = nodeHandler $ \ _ Ping -> do
80 return Ping 81 return Ping
81 82
83-- | Default 'FindNode' handler.
82findNodeH :: Address ip => NodeHandler ip 84findNodeH :: Address ip => NodeHandler ip
83findNodeH = nodeHandler $ \ _ (FindNode nid) -> do 85findNodeH = nodeHandler $ \ _ (FindNode nid) -> do
84 NodeFound <$> getClosest nid 86 NodeFound <$> getClosest nid
85 87
88-- | Default 'GetPeers' handler.
86getPeersH :: Address ip => NodeHandler ip 89getPeersH :: Address ip => NodeHandler ip
87getPeersH = nodeHandler $ \ naddr (GetPeers ih) -> do 90getPeersH = nodeHandler $ \ naddr (GetPeers ih) -> do
88 GotPeers <$> getPeerList ih <*> grantToken naddr 91 GotPeers <$> getPeerList ih <*> grantToken naddr
89 92
93-- | Default 'Announce' handler.
90announceH :: Address ip => NodeHandler ip 94announceH :: Address ip => NodeHandler ip
91announceH = nodeHandler $ \ naddr @ NodeAddr {..} (Announce {..}) -> do 95announceH = nodeHandler $ \ naddr @ NodeAddr {..} (Announce {..}) -> do
92 valid <- checkToken naddr sessionToken 96 valid <- checkToken naddr sessionToken