summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSam Truzjan <pxqr.sta@gmail.com>2014-04-26 10:10:27 +0400
committerSam Truzjan <pxqr.sta@gmail.com>2014-04-26 10:10:27 +0400
commit116cf5a631785b7b28de08dc287cca7ce9795216 (patch)
tree2a7f0916d19d962539e8aeca9fbf13106cd355f2 /src
parenta7fda9d39ed82cb9d3ad0c28e76e88e59539a492 (diff)
Simplify "mktorrent get" command
Diffstat (limited to 'src')
-rw-r--r--src/Network/BitTorrent/Exchange.hs1
-rw-r--r--src/Network/BitTorrent/Exchange/Session.hs12
2 files changed, 11 insertions, 2 deletions
diff --git a/src/Network/BitTorrent/Exchange.hs b/src/Network/BitTorrent/Exchange.hs
index ce71e286..143bf090 100644
--- a/src/Network/BitTorrent/Exchange.hs
+++ b/src/Network/BitTorrent/Exchange.hs
@@ -27,6 +27,7 @@ module Network.BitTorrent.Exchange
27 27
28 -- * Connections 28 -- * Connections
29 , connect 29 , connect
30 , connectSink
30 ) where 31 ) where
31 32
32import Network.BitTorrent.Exchange.Manager 33import Network.BitTorrent.Exchange.Manager
diff --git a/src/Network/BitTorrent/Exchange/Session.hs b/src/Network/BitTorrent/Exchange/Session.hs
index 30b7ed0e..2bd275bd 100644
--- a/src/Network/BitTorrent/Exchange/Session.hs
+++ b/src/Network/BitTorrent/Exchange/Session.hs
@@ -16,6 +16,7 @@ module Network.BitTorrent.Exchange.Session
16 16
17 -- * Connection Set 17 -- * Connection Set
18 , connect 18 , connect
19 , connectSink
19 , establish 20 , establish
20 21
21 -- * Query 22 -- * Query
@@ -29,12 +30,13 @@ import Control.Concurrent.Chan.Split as CS
29import Control.Concurrent.STM 30import Control.Concurrent.STM
30import Control.Exception hiding (Handler) 31import Control.Exception hiding (Handler)
31import Control.Lens 32import Control.Lens
33import Control.Monad as M
32import Control.Monad.Logger 34import Control.Monad.Logger
33import Control.Monad.Reader 35import Control.Monad.Reader
34import Data.ByteString as BS 36import Data.ByteString as BS
35import Data.ByteString.Lazy as BL 37import Data.ByteString.Lazy as BL
36import Data.Conduit 38import Data.Conduit as C
37import Data.Conduit.List as CL (iterM) 39import Data.Conduit.List as C
38import Data.Map as M 40import Data.Map as M
39import Data.Monoid 41import Data.Monoid
40import Data.Set as S 42import Data.Set as S
@@ -333,6 +335,12 @@ establish :: PendingConnection -> Session -> IO ()
333establish conn = runConnection (acceptWire conn) (closePending conn) 335establish conn = runConnection (acceptWire conn) (closePending conn)
334 (pendingPeer conn) 336 (pendingPeer conn)
335 337
338-- | Conduit version of 'connect'.
339connectSink :: MonadIO m => Session -> Sink [PeerAddr IPv4] m ()
340connectSink s = C.mapM_ (liftIO . connectBatch)
341 where
342 connectBatch = M.mapM_ (\ addr -> connect (IPv4 <$> addr) s)
343
336-- | Why do we need this message? 344-- | Why do we need this message?
337type BroadcastMessage = ExtendedCaps -> Message 345type BroadcastMessage = ExtendedCaps -> Message
338 346