summaryrefslogtreecommitdiff
path: root/src/Network/BitTorrent/Exchange/Session.hs
diff options
context:
space:
mode:
authorSam Truzjan <pxqr.sta@gmail.com>2013-12-05 03:26:56 +0400
committerSam Truzjan <pxqr.sta@gmail.com>2013-12-05 03:26:56 +0400
commit32b0f3570237e4d4742fc8874980f2b479c1ae75 (patch)
treeace6425ecb6170679c36327bbf3694d80d472574 /src/Network/BitTorrent/Exchange/Session.hs
parent1e8a6a7d5267811d035afda764e90092eb0e994c (diff)
Add Wire module
Diffstat (limited to 'src/Network/BitTorrent/Exchange/Session.hs')
-rw-r--r--src/Network/BitTorrent/Exchange/Session.hs29
1 files changed, 5 insertions, 24 deletions
diff --git a/src/Network/BitTorrent/Exchange/Session.hs b/src/Network/BitTorrent/Exchange/Session.hs
index ffc7816e..d2a9aaaf 100644
--- a/src/Network/BitTorrent/Exchange/Session.hs
+++ b/src/Network/BitTorrent/Exchange/Session.hs
@@ -22,6 +22,11 @@ import Network.BitTorrent.Exchange.Status
22 22
23type Extension = () 23type Extension = ()
24 24
25data ExchangeError
26 = InvalidPieceIx PieceIx
27 | InvalidBlock BlockIx
28 | CorruptedPiece PieceIx
29
25-- | Peer session contain all data necessary for peer to peer 30-- | Peer session contain all data necessary for peer to peer
26-- communication. 31-- communication.
27data ExchangeSession = ExchangeSession 32data ExchangeSession = ExchangeSession
@@ -69,30 +74,6 @@ $(makeLenses ''SessionState)
69--getSessionState :: PeerSession -> IO SessionState 74--getSessionState :: PeerSession -> IO SessionState
70--getSessionState PeerSession {..} = readIORef sessionState 75--getSessionState PeerSession {..} = readIORef sessionState
71 76
72{-----------------------------------------------------------------------
73-- Exceptions
74-----------------------------------------------------------------------}
75
76-- | Exceptions used to interrupt the current P2P session. This
77-- exceptions will NOT affect other P2P sessions, DHT, peer <->
78-- tracker, or any other session.
79--
80data ExchangeFailure
81 = PeerDisconnected
82 | ProtocolError Doc
83 | UnknownTorrent InfoHash
84 deriving (Show, Typeable)
85
86instance Exception ExchangeFailure
87
88-- | Do nothing with exception, used with 'handle' or 'try'.
89isSessionException :: Monad m => ExchangeFailure -> m ()
90isSessionException _ = return ()
91
92-- | The same as 'isSessionException' but output to stdout the catched
93-- exception, for debugging purposes only.
94putSessionException :: ExchangeFailure -> IO ()
95putSessionException = print
96{- 77{-
97{----------------------------------------------------------------------- 78{-----------------------------------------------------------------------
98-- Broadcasting: Have, Cancel, Bitfield, SuggestPiece 79-- Broadcasting: Have, Cancel, Bitfield, SuggestPiece