diff options
author | Sam T <pxqr.sta@gmail.com> | 2013-06-02 06:43:00 +0400 |
---|---|---|
committer | Sam T <pxqr.sta@gmail.com> | 2013-06-02 06:43:00 +0400 |
commit | 4de96724e4006589022e08b6ed247784f958b508 (patch) | |
tree | 7c7807a4e9425fca1151e1fed909a3643238278f /src/Network/BitTorrent/PeerWire/Handshake.hs | |
parent | dea6c9b2ea1037ee54f1908ebc6a5e193e0cfac6 (diff) |
~ Use pretty package for pretty print.
This is a bit faster and pretty!
Diffstat (limited to 'src/Network/BitTorrent/PeerWire/Handshake.hs')
-rw-r--r-- | src/Network/BitTorrent/PeerWire/Handshake.hs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/Network/BitTorrent/PeerWire/Handshake.hs b/src/Network/BitTorrent/PeerWire/Handshake.hs index 6f4598ae..ff768cae 100644 --- a/src/Network/BitTorrent/PeerWire/Handshake.hs +++ b/src/Network/BitTorrent/PeerWire/Handshake.hs | |||
@@ -11,6 +11,7 @@ | |||
11 | -- peer. | 11 | -- peer. |
12 | -- | 12 | -- |
13 | {-# LANGUAGE OverloadedStrings #-} | 13 | {-# LANGUAGE OverloadedStrings #-} |
14 | {-# LANGUAGE RecordWildCards #-} | ||
14 | module Network.BitTorrent.PeerWire.Handshake | 15 | module Network.BitTorrent.PeerWire.Handshake |
15 | ( Handshake(..), handshakeCaps | 16 | ( Handshake(..), handshakeCaps |
16 | , handshake | 17 | , handshake |
@@ -27,6 +28,8 @@ import Data.ByteString (ByteString) | |||
27 | import qualified Data.ByteString as B | 28 | import qualified Data.ByteString as B |
28 | import qualified Data.ByteString.Char8 as BC | 29 | import qualified Data.ByteString.Char8 as BC |
29 | import Data.Serialize as S | 30 | import Data.Serialize as S |
31 | import Text.PrettyPrint | ||
32 | |||
30 | import Network | 33 | import Network |
31 | import Network.Socket.ByteString | 34 | import Network.Socket.ByteString |
32 | 35 | ||
@@ -77,9 +80,9 @@ handshakeCaps :: Handshake -> Capabilities | |||
77 | handshakeCaps = hsReserved | 80 | handshakeCaps = hsReserved |
78 | 81 | ||
79 | -- | Format handshake in human readable form. | 82 | -- | Format handshake in human readable form. |
80 | ppHandshake :: Handshake -> String | 83 | ppHandshake :: Handshake -> Doc |
81 | ppHandshake hs = BC.unpack (hsProtocol hs) ++ " " | 84 | ppHandshake Handshake {..} = |
82 | ++ ppClientInfo (clientInfo (hsPeerID hs)) | 85 | text (BC.unpack hsProtocol) <+> ppClientInfo (clientInfo hsPeerID) |
83 | 86 | ||
84 | -- | Get handshake message size in bytes from the length of protocol string. | 87 | -- | Get handshake message size in bytes from the length of protocol string. |
85 | handshakeSize :: Word8 -> Int | 88 | handshakeSize :: Word8 -> Int |