summaryrefslogtreecommitdiff
path: root/src/Network/BitTorrent/DHT/Query.hs
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2017-06-05 03:21:25 -0400
committerjoe <joe@jerkface.net>2017-06-05 03:31:23 -0400
commit24df9a12a9240aaed8741d60e4b0b9cbf59a9fd9 (patch)
tree04791746bb576c40851f441ebc851c9d0d8da777 /src/Network/BitTorrent/DHT/Query.hs
parent219d72ebde4bab5a516a86608dcb3aede75c1611 (diff)
WIP: Adapting DHT to Tox network (part 2).
Diffstat (limited to 'src/Network/BitTorrent/DHT/Query.hs')
-rw-r--r--src/Network/BitTorrent/DHT/Query.hs9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/Network/BitTorrent/DHT/Query.hs b/src/Network/BitTorrent/DHT/Query.hs
index c7e48920..a1934014 100644
--- a/src/Network/BitTorrent/DHT/Query.hs
+++ b/src/Network/BitTorrent/DHT/Query.hs
@@ -14,6 +14,7 @@
14{-# LANGUAGE ScopedTypeVariables #-} 14{-# LANGUAGE ScopedTypeVariables #-}
15{-# LANGUAGE TemplateHaskell #-} 15{-# LANGUAGE TemplateHaskell #-}
16{-# LANGUAGE TupleSections #-} 16{-# LANGUAGE TupleSections #-}
17{-# LANGUAGE GADTs #-}
17module Network.BitTorrent.DHT.Query 18module Network.BitTorrent.DHT.Query
18 ( -- * Handler 19 ( -- * Handler
19 -- | To bind specific set of handlers you need to pass 20 -- | To bind specific set of handlers you need to pass
@@ -71,6 +72,7 @@ import Data.Either
71import Data.List as L 72import Data.List as L
72import Data.Monoid 73import Data.Monoid
73import Data.Text as T 74import Data.Text as T
75import Data.BEncode (BValue)
74import qualified Data.Set as Set 76import qualified Data.Set as Set
75 ;import Data.Set (Set) 77 ;import Data.Set (Set)
76import Network 78import Network
@@ -89,14 +91,17 @@ import Network.BitTorrent.DHT.Routing as R
89import Network.BitTorrent.DHT.Session 91import Network.BitTorrent.DHT.Session
90import Control.Concurrent.STM 92import Control.Concurrent.STM
91import qualified Network.BitTorrent.DHT.Search as Search 93import qualified Network.BitTorrent.DHT.Search as Search
94import Network.DHT.Mainline
92 95
93{----------------------------------------------------------------------- 96{-----------------------------------------------------------------------
94-- Handlers 97-- Handlers
95-----------------------------------------------------------------------} 98-----------------------------------------------------------------------}
96 99
97nodeHandler :: Address ip => KRPC (Query a) (Response b) 100nodeHandler :: ( Address ip
101 , KRPC (Query a) (Response b)
102 , Envelope (Query a) (Response b) ~ BValue )
98 => (NodeAddr ip -> a -> DHT ip b) -> NodeHandler ip 103 => (NodeAddr ip -> a -> DHT ip b) -> NodeHandler ip
99nodeHandler action = handler $ \ sockAddr qry -> do 104nodeHandler action = handler mainline $ \ sockAddr qry -> do
100 let remoteId = queringNodeId qry 105 let remoteId = queringNodeId qry
101 read_only = queryIsReadOnly qry 106 read_only = queryIsReadOnly qry
102 q = queryParams qry 107 q = queryParams qry