summaryrefslogtreecommitdiff
path: root/exsamples/Main.hs
diff options
context:
space:
mode:
authorSam T <pxqr.sta@gmail.com>2013-06-14 07:12:53 +0400
committerSam T <pxqr.sta@gmail.com>2013-06-14 07:12:53 +0400
commit1fb701938aba43797124d2975c15f936ac71409a (patch)
treeac961d404775f234476ea2f00555648d087f9da8 /exsamples/Main.hs
parentb1413145f58be6c3d7e536574a19e1b6c333cd54 (diff)
~ Cosmetic changes.
Diffstat (limited to 'exsamples/Main.hs')
-rw-r--r--exsamples/Main.hs19
1 files changed, 11 insertions, 8 deletions
diff --git a/exsamples/Main.hs b/exsamples/Main.hs
index ebc81b02..4eb09043 100644
--- a/exsamples/Main.hs
+++ b/exsamples/Main.hs
@@ -15,15 +15,13 @@ main = do
15 [path] <- getArgs 15 [path] <- getArgs
16 torrent <- fromFile path 16 torrent <- fromFile path
17 17
18 client <- newClient 2 [] 18 print (contentLayout "./" (tInfo torrent))
19
20 client <- newClient 100 []
19 swarm <- newLeacher client torrent 21 swarm <- newLeacher client torrent
20 22
23 ref <- liftIO $ newIORef 0
21 discover swarm $ do 24 discover swarm $ do
22 ref <- liftIO $ newIORef 0
23
24 addr <- asks connectedPeerAddr
25 liftIO $ print $ "connected to" ++ show addr
26
27 forever $ do 25 forever $ do
28 e <- awaitEvent 26 e <- awaitEvent
29 case e of 27 case e of
@@ -33,9 +31,14 @@ main = do
33 Want bix -> liftIO $ print bix 31 Want bix -> liftIO $ print bix
34 Fragment blk -> do 32 Fragment blk -> do
35 33
34 sc <- liftIO $ getSessionCount swarm
35 addr <- asks connectedPeerAddr
36
36 liftIO $ do 37 liftIO $ do
37 readIORef ref >>= print 38 x <- atomicModifyIORef ref (\x -> (succ x, x))
38 modifyIORef ref succ 39 if x `mod` 100 == 0
40 then print (x, sc, addr)
41 else return ()
39 42
40 yieldEvent (Want (BlockIx 0 0 (16 * 1024))) 43 yieldEvent (Want (BlockIx 0 0 (16 * 1024)))
41 44