Skip to content

Commit

Permalink
Debug printing in Peer.
Browse files Browse the repository at this point in the history
  • Loading branch information
jlouis committed Apr 29, 2010
1 parent 03adac4 commit 96a460c
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/Process/Peer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -318,11 +318,15 @@ chokeMgrMsg msg = do
considerInterest
ChokePeer -> do choking <- gets weChoke
when (not choking)
(do outChan $ SenderQ.SenderOChoke
(do t <- liftIO myThreadId
debugP $ "Pid " ++ show t ++ " choking"
outChan $ SenderQ.SenderOChoke
modify (\s -> s {weChoke = True}))
UnchokePeer -> do choking <- gets weChoke
when choking
(do outChan $ SenderQ.SenderQM Unchoke
(do t <- liftIO myThreadId
debugP $ "Pid " ++ show t ++ " unchoking"
outChan $ SenderQ.SenderQM Unchoke
modify (\s -> s {weChoke = False}))
CancelBlock pn blk -> do
cf <- asks extConf
Expand Down Expand Up @@ -452,6 +456,7 @@ haveMsg pn = do
let (lo, hi) = bounds pm
if pn >= lo && pn <= hi
then do PS.insert pn =<< gets peerPieces
debugP $ "Peer has pn: " ++ show pn
msgPieceMgr (PeerHave [pn])
decMissingCounter 1
considerInterest
Expand Down Expand Up @@ -520,12 +525,14 @@ haveAllMsg = haveAllNoneMsg "HaveAll" True
requestMsg :: PieceNum -> Block -> Process CF ST ()
requestMsg pn blk = do
choking <- gets weChoke
unless (choking)
(outChan $ SenderQ.SenderQPiece pn blk)
unless choking
(do debugP $ "Peer requested: " ++ show pn ++ "(" ++ show blk ++ ")"
outChan $ SenderQ.SenderQPiece pn blk)

requestFastMsg :: PieceNum -> Block -> Process CF ST ()
requestFastMsg pn blk = do
choking <- gets weChoke
debugP $ "Peer fastRequested: " ++ show pn ++ "(" ++ show blk ++ ")"
if choking
then outChan $ SenderQ.SenderQM (RejectRequest pn blk)
else outChan $ SenderQ.SenderQPiece pn blk
Expand Down

0 comments on commit 96a460c

Please sign in to comment.