diff options
author | Sam T <pxqr.sta@gmail.com> | 2013-06-12 02:23:37 +0400 |
---|---|---|
committer | Sam T <pxqr.sta@gmail.com> | 2013-06-12 02:23:37 +0400 |
commit | 7f27eec9bf34a513f7a28072468706e8975ef552 (patch) | |
tree | 92e7462a3347cd601bb56b2d52ae080127320616 /src/Network/BitTorrent.hs | |
parent | 7c14f44783d4f5e241ce37027dd60fefcc3f5382 (diff) |
~ Use lens.
Diffstat (limited to 'src/Network/BitTorrent.hs')
-rw-r--r-- | src/Network/BitTorrent.hs | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/Network/BitTorrent.hs b/src/Network/BitTorrent.hs index 8f0f42ce..e9b5f17d 100644 --- a/src/Network/BitTorrent.hs +++ b/src/Network/BitTorrent.hs | |||
@@ -21,10 +21,9 @@ module Network.BitTorrent | |||
21 | , discover | 21 | , discover |
22 | 22 | ||
23 | -- * Peer to Peer | 23 | -- * Peer to Peer |
24 | , P2P, PeerSession | 24 | , P2P |
25 | ( connectedPeerAddr, enabledExtensions | 25 | , PeerSession ( connectedPeerAddr, enabledExtensions ) |
26 | , peerBitfield, peerSessionStatus | 26 | , Block(..), BlockIx(..) |
27 | ) | ||
28 | 27 | ||
29 | , awaitEvent, signalEvent | 28 | , awaitEvent, signalEvent |
30 | ) where | 29 | ) where |
@@ -43,10 +42,13 @@ import Network.BitTorrent.Tracker | |||
43 | -- thus we can obtain unified interface | 42 | -- thus we can obtain unified interface |
44 | 43 | ||
45 | discover :: SwarmSession -> P2P () -> IO () | 44 | discover :: SwarmSession -> P2P () -> IO () |
46 | discover swarm @ SwarmSession {..} action = do | 45 | discover swarm action = do |
47 | let conn = TConnection (tAnnounce torrentMeta) (tInfoHash torrentMeta) | 46 | let conn = TConnection (tAnnounce (torrentMeta swarm)) |
48 | (clientPeerID clientSession) port | 47 | (tInfoHash (torrentMeta swarm)) |
49 | progress <- readIORef (currentProgress clientSession) | 48 | (clientPeerID (clientSession swarm)) |
49 | port | ||
50 | |||
51 | progress <- getCurrentProgress (clientSession swarm) | ||
50 | withTracker progress conn $ \tses -> do | 52 | withTracker progress conn $ \tses -> do |
51 | forever $ do | 53 | forever $ do |
52 | addr <- getPeerAddr tses | 54 | addr <- getPeerAddr tses |