diff options
Diffstat (limited to 'src/Network/BitTorrent/DHT/Session.hs')
-rw-r--r-- | src/Network/BitTorrent/DHT/Session.hs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/Network/BitTorrent/DHT/Session.hs b/src/Network/BitTorrent/DHT/Session.hs index a4f10bb1..3c37ea9a 100644 --- a/src/Network/BitTorrent/DHT/Session.hs +++ b/src/Network/BitTorrent/DHT/Session.hs | |||
@@ -152,6 +152,7 @@ invalidateTokens curTime ts @ SessionTokens {..} | |||
152 | 152 | ||
153 | data Node ip = Node | 153 | data Node ip = Node |
154 | { options :: !Options | 154 | { options :: !Options |
155 | , thisNodeId :: !NodeId | ||
155 | , manager :: !(Manager (DHT ip)) | 156 | , manager :: !(Manager (DHT ip)) |
156 | , routingTable :: !(MVar (Table ip)) | 157 | , routingTable :: !(MVar (Table ip)) |
157 | , contactInfo :: !(TVar (PeerStore ip)) | 158 | , contactInfo :: !(TVar (PeerStore ip)) |
@@ -196,7 +197,7 @@ runDHT handlers opts naddr action = runResourceT $ do | |||
196 | let nodeAddr = toSockAddr naddr | 197 | let nodeAddr = toSockAddr naddr |
197 | (_, m) <- allocate (newManager rpcOpts nodeAddr handlers) closeManager | 198 | (_, m) <- allocate (newManager rpcOpts nodeAddr handlers) closeManager |
198 | myId <- liftIO genNodeId | 199 | myId <- liftIO genNodeId |
199 | node <- liftIO $ Node opts m | 200 | node <- liftIO $ Node opts myId m |
200 | <$> newMVar (nullTable myId (optBucketCount opts)) | 201 | <$> newMVar (nullTable myId (optBucketCount opts)) |
201 | <*> newTVarIO def | 202 | <*> newTVarIO def |
202 | <*> (newTVarIO =<< nullSessionTokens) | 203 | <*> (newTVarIO =<< nullSessionTokens) |
@@ -270,9 +271,9 @@ getTable = do | |||
270 | var <- asks routingTable | 271 | var <- asks routingTable |
271 | liftIO (readMVar var) | 272 | liftIO (readMVar var) |
272 | 273 | ||
273 | -- FIXME no blocking | 274 | -- | Get id of /this/ node. This value is constant during DHT session. |
274 | getNodeId :: DHT ip NodeId | 275 | getNodeId :: DHT ip NodeId |
275 | getNodeId = thisId <$> getTable | 276 | getNodeId = asks thisNodeId |
276 | 277 | ||
277 | getClosest :: Eq ip => NodeId -> DHT ip [NodeInfo ip] | 278 | getClosest :: Eq ip => NodeId -> DHT ip [NodeInfo ip] |
278 | getClosest nid = do | 279 | getClosest nid = do |