]> git.rkrishnan.org Git - functorrent.git/blobdiff - src/FuncTorrent/Peer.hs
Peer: debug prints
[functorrent.git] / 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)