]> git.rkrishnan.org Git - functorrent.git/commitdiff
Peer: debug prints
authorRamakrishnan Muthukrishnan <ram@rkrishnan.org>
Fri, 24 Jul 2015 14:08:54 +0000 (19:38 +0530)
committerRamakrishnan Muthukrishnan <ram@rkrishnan.org>
Fri, 24 Jul 2015 14:08:54 +0000 (19:38 +0530)
src/FuncTorrent/Peer.hs

index dba33bc288e876bf720dc174317d9c8d9af22575..d74333a28f26b5af751300b303da19e31a569efc 100644 (file)
@@ -272,6 +272,15 @@ downloadPiece h index pieceLength = do
   let chunks = splitNum pieceLength 16384
   forM (zip [0..] chunks) (\(i, pLen) -> do
                               sendMsg h (RequestMsg index (i*pLen) pLen)
-                              putStrLn $ "--> " ++ "RequestMsg for Piece " ++ (show index) ++ ", part: " ++ show i ++ " of length: " ++ show pLen
-                              -- putStrLn $ "--> RequestMsg for Piece " ++ (show workPiece) ++ "to peer: " ++ show (peer state) ++ " of length: " ++ show pLen
-                              getMsg h)
+                              putStrLn $ "--> " ++ "RequestMsg for Piece "
+                                ++ (show index) ++ ", part: " ++ show i ++ " of length: "
+                                ++ show pLen
+                              rMsg <- getMsg h
+                              case rMsg of
+                               PieceMsg index begin block ->
+                                 putStrLn $ " <-- PieceMsg for Piece: "
+                                 ++ show index
+                                 ++ ", offset: "
+                                 ++ show begin
+                               _ -> putStrLn " <-- UnKnown msg from Peer"
+                              return rMsg)