summaryrefslogtreecommitdiff
path: root/src/Network/BitTorrent/Internal.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Network/BitTorrent/Internal.hs')
-rw-r--r--src/Network/BitTorrent/Internal.hs15
1 files changed, 3 insertions, 12 deletions
diff --git a/src/Network/BitTorrent/Internal.hs b/src/Network/BitTorrent/Internal.hs
index 8ce7afbf..5ac58d46 100644
--- a/src/Network/BitTorrent/Internal.hs
+++ b/src/Network/BitTorrent/Internal.hs
@@ -56,6 +56,7 @@ module Network.BitTorrent.Internal
56 -- * Peer 56 -- * Peer
57 , PeerSession( PeerSession, connectedPeerAddr 57 , PeerSession( PeerSession, connectedPeerAddr
58 , swarmSession, enabledExtensions 58 , swarmSession, enabledExtensions
59 , sessionState
59 ) 60 )
60 , SessionState 61 , SessionState
61 , withPeerSession 62 , withPeerSession
@@ -352,7 +353,8 @@ waitVacancy se =
352 Peer session 353 Peer session
353-----------------------------------------------------------------------} 354-----------------------------------------------------------------------}
354 355
355-- | Peer session contain all data necessary for peer to peer communication. 356-- | Peer session contain all data necessary for peer to peer
357-- communication.
356data PeerSession = PeerSession { 358data PeerSession = PeerSession {
357 -- | Used as unique 'PeerSession' identifier within one 359 -- | Used as unique 'PeerSession' identifier within one
358 -- 'SwarmSession'. 360 -- 'SwarmSession'.
@@ -409,17 +411,6 @@ instance Eq PeerSession where
409instance Ord PeerSession where 411instance Ord PeerSession where
410 compare = comparing connectedPeerAddr 412 compare = comparing connectedPeerAddr
411 413
412instance (MonadIO m, MonadReader PeerSession m)
413 => MonadState SessionState m where
414 get = do
415 ref <- asks sessionState
416 st <- liftIO (readIORef ref)
417 liftIO $ print (completeness (_bitfield st))
418 return st
419
420 put !s = asks sessionState >>= \ref -> liftIO $ writeIORef ref s
421
422
423-- | Exceptions used to interrupt the current P2P session. This 414-- | Exceptions used to interrupt the current P2P session. This
424-- exceptions will NOT affect other P2P sessions, DHT, peer <-> 415-- exceptions will NOT affect other P2P sessions, DHT, peer <->
425-- tracker, or any other session. 416-- tracker, or any other session.