From af041b29775b1f0df4b47d2ab1592ef61eeb1ce8 Mon Sep 17 00:00:00 2001
From: Ramakrishnan Muthukrishnan <ram@rkrishnan.org>
Date: Fri, 24 Jul 2015 19:38:54 +0530
Subject: [PATCH] Peer: debug prints

---
 src/FuncTorrent/Peer.hs | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/FuncTorrent/Peer.hs b/src/FuncTorrent/Peer.hs
index dba33bc..d74333a 100644
--- a/src/FuncTorrent/Peer.hs
+++ b/src/FuncTorrent/Peer.hs
@@ -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)
-- 
2.45.2