diff options
author | Sam T <pxqr.sta@gmail.com> | 2013-06-29 23:22:25 +0400 |
---|---|---|
committer | Sam T <pxqr.sta@gmail.com> | 2013-06-29 23:22:25 +0400 |
commit | f556bf196bf07308f024cc43c1a51dfd4c21188c (patch) | |
tree | 228de5a632e8b758d507df7ddabf7fd85d113694 /src/Network/BitTorrent.hs | |
parent | d4ada1b8a392d67f2835935084c5f0f3ecef2ab5 (diff) |
+ Scetch basic broadcasting.
Diffstat (limited to 'src/Network/BitTorrent.hs')
-rw-r--r-- | src/Network/BitTorrent.hs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/Network/BitTorrent.hs b/src/Network/BitTorrent.hs index b97db4b0..86c7802b 100644 --- a/src/Network/BitTorrent.hs +++ b/src/Network/BitTorrent.hs | |||
@@ -33,8 +33,15 @@ module Network.BitTorrent | |||
33 | , SessionCount | 33 | , SessionCount |
34 | , getSessionCount | 34 | , getSessionCount |
35 | 35 | ||
36 | -- * Storage | ||
37 | , Storage | ||
38 | , bindTo | ||
39 | , unbind | ||
40 | |||
36 | -- * Discovery | 41 | -- * Discovery |
37 | , discover | 42 | , discover |
43 | , exchange | ||
44 | |||
38 | 45 | ||
39 | -- * Peer to Peer | 46 | -- * Peer to Peer |
40 | , P2P | 47 | , P2P |
@@ -122,12 +129,13 @@ discover swarm action = do | |||
122 | -- \---------------------------/ | 129 | -- \---------------------------/ |
123 | -- | 130 | -- |
124 | 131 | ||
132 | |||
125 | -- | Default P2P action. | 133 | -- | Default P2P action. |
126 | exchange :: Storage -> P2P () | 134 | exchange :: Storage -> P2P () |
127 | exchange storage = handleEvent handler | 135 | exchange storage = handleEvent (\msg -> liftIO (print msg) >> handler msg) |
128 | where | 136 | where |
129 | handler (Available bf) | 137 | handler (Available bf) |
130 | | Just m <- findMin bf = return (Want (BlockIx m 0 10)) | 138 | | Just m <- findMin bf = return (Want (BlockIx m 0 262144)) |
131 | | otherwise = error "impossible" | 139 | | otherwise = error "impossible" |
132 | -- TODO findMin :: Bitfield -> PieceIx | 140 | -- TODO findMin :: Bitfield -> PieceIx |
133 | 141 | ||