summaryrefslogtreecommitdiff
path: root/src/Network/BitTorrent/DHT/Session.hs
diff options
context:
space:
mode:
authorSam Truzjan <pxqr.sta@gmail.com>2014-02-16 23:53:11 +0400
committerSam Truzjan <pxqr.sta@gmail.com>2014-02-16 23:53:11 +0400
commit81fb820ce0469a7ff3677e278ed5e3b3c491f569 (patch)
treee0c7cba820d9d89404dd50f687e74e87264c0fe1 /src/Network/BitTorrent/DHT/Session.hs
parent3d2408eb3f680117d841e5f90e120ff018009f03 (diff)
Remove getNodeId function
Diffstat (limited to 'src/Network/BitTorrent/DHT/Session.hs')
-rw-r--r--src/Network/BitTorrent/DHT/Session.hs21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/Network/BitTorrent/DHT/Session.hs b/src/Network/BitTorrent/DHT/Session.hs
index cbdc9ff8..11e1c81a 100644
--- a/src/Network/BitTorrent/DHT/Session.hs
+++ b/src/Network/BitTorrent/DHT/Session.hs
@@ -23,12 +23,16 @@ module Network.BitTorrent.DHT.Session
23 -- * Session 23 -- * Session
24 , Node 24 , Node
25 , options 25 , options
26 , thisNodeId
27
28 -- ** Initialization
26 , LogFun 29 , LogFun
27 , NodeHandler 30 , NodeHandler
28 , startNode 31 , startNode
29 32
30 -- * DHT 33 -- * DHT
31 -- | Use @asks options@ to get options passed to 'startNode'. 34 -- | Use @asks options@ to get options passed to 'startNode'
35 -- or @asks thisNodeId@ to get id of locally running node.
32 , DHT 36 , DHT
33 , runDHT 37 , runDHT
34 38
@@ -38,7 +42,6 @@ module Network.BitTorrent.DHT.Session
38 42
39 -- * Routing table 43 -- * Routing table
40 , getTable 44 , getTable
41 , getNodeId
42 , getClosest 45 , getClosest
43 , insertNode 46 , insertNode
44 47
@@ -225,8 +228,12 @@ type LogFun = Loc -> LogSource -> LogLevel -> LogStr -> IO ()
225 228
226-- | DHT session keep track state of /this/ node. 229-- | DHT session keep track state of /this/ node.
227data Node ip = Node 230data Node ip = Node
228 { options :: !Options -- ^ session configuration; 231 { -- | Session configuration;
229 , thisNodeId :: !NodeId -- ^ session identifier; 232 options :: !Options
233
234 -- | Pseudo-unique self-assigned session identifier. This value is
235 -- constant during DHT session and (optionally) between sessions.
236 , thisNodeId :: !NodeId
230 , manager :: !(Manager (DHT ip)) -- ^ RPC manager; 237 , manager :: !(Manager (DHT ip)) -- ^ RPC manager;
231 , routingTable :: !(MVar (Table ip)) -- ^ search table; 238 , routingTable :: !(MVar (Table ip)) -- ^ search table;
232 , contactInfo :: !(TVar (PeerStore ip)) -- ^ published by other nodes; 239 , contactInfo :: !(TVar (PeerStore ip)) -- ^ published by other nodes;
@@ -361,10 +368,6 @@ getTable = do
361 var <- asks routingTable 368 var <- asks routingTable
362 liftIO (readMVar var) 369 liftIO (readMVar var)
363 370
364-- | Get id of /this/ node. This value is constant during DHT session.
365getNodeId :: DHT ip NodeId
366getNodeId = asks thisNodeId
367
368-- | Find a set of closest nodes from routing table of this node. (in 371-- | Find a set of closest nodes from routing table of this node. (in
369-- no particular order) 372-- no particular order)
370-- 373--
@@ -440,7 +443,7 @@ deleteTopic ih p = do
440queryNode :: forall a b ip. Address ip => KRPC (Query a) (Response b) 443queryNode :: forall a b ip. Address ip => KRPC (Query a) (Response b)
441 => NodeAddr ip -> a -> DHT ip (NodeId, b) 444 => NodeAddr ip -> a -> DHT ip (NodeId, b)
442queryNode addr q = do 445queryNode addr q = do
443 nid <- getNodeId 446 nid <- asks thisNodeId
444 Response remoteId r <- query (toSockAddr addr) (Query nid q) 447 Response remoteId r <- query (toSockAddr addr) (Query nid q)
445 insertNode (NodeInfo remoteId addr) 448 insertNode (NodeInfo remoteId addr)
446 return (remoteId, r) 449 return (remoteId, r)