From: Ramakrishnan Muthukrishnan Date: Fri, 24 Jul 2015 14:08:54 +0000 (+0530) Subject: Peer: debug prints X-Git-Url: https://git.rkrishnan.org/listings/vdrive/%22doc.html/index.php?a=commitdiff_plain;h=af041b29775b1f0df4b47d2ab1592ef61eeb1ce8;p=functorrent.git Peer: debug prints --- 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)