From d7df7e201bd7e0893910d77c1ea172ea0c59cd3f Mon Sep 17 00:00:00 2001 From: Sam T Date: Wed, 1 May 2013 09:31:32 +0400 Subject: ~ Fix documentation and typos. --- src/Network/BitTorrent/PeerWire/Handshake.hs | 15 ++++++++------- src/Network/BitTorrent/PeerWire/Message.hs | 5 ++++- src/Network/BitTorrent/Tracker/Scrape.hs | 2 +- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/Network/BitTorrent/PeerWire/Handshake.hs b/src/Network/BitTorrent/PeerWire/Handshake.hs index 7a250782..3fdb48be 100644 --- a/src/Network/BitTorrent/PeerWire/Handshake.hs +++ b/src/Network/BitTorrent/PeerWire/Handshake.hs @@ -5,13 +5,18 @@ -- Stability : experimental -- Portability : portable -- +-- In order to establish the connection between peers we should send +-- 'Handshake' message. The 'Handshake' is a required message and +-- must be the first message transmitted by the peer to the another +-- peer. +-- {-# LANGUAGE OverloadedStrings #-} module Network.BitTorrent.PeerWire.Handshake ( Handshake - , handshakeMaxSize - , defaultBTProtocol, defaultReserved, defaultHandshake , handshake , ppHandshake + , defaultHandshake, defaultBTProtocol, defaultReserved + , handshakeMaxSize ) where import Control.Applicative @@ -28,11 +33,6 @@ import Network.BitTorrent.PeerID import Network.BitTorrent.PeerWire.ClientInfo --- | In order to establish the connection between peers we should send --- 'Handshake' message. The 'Handshake' is a required message and --- must be the first message transmitted by the peer to the another --- peer. --- data Handshake = Handshake { -- | Identifier of the protocol. hsProtocol :: ByteString @@ -70,6 +70,7 @@ instance Serialize Handshake where <*> get -- TODO add reserved bits info +-- | Format handshake in human readable form. ppHandshake :: Handshake -> String ppHandshake hs = BC.unpack (hsProtocol hs) ++ " " ++ ppClientInfo (clientInfo (hsPeerID hs)) diff --git a/src/Network/BitTorrent/PeerWire/Message.hs b/src/Network/BitTorrent/PeerWire/Message.hs index e833ba03..3f6647dd 100644 --- a/src/Network/BitTorrent/PeerWire/Message.hs +++ b/src/Network/BitTorrent/PeerWire/Message.hs @@ -132,7 +132,10 @@ instance Serialize Message where put (AllowedFast ix) = putInt 5 >> putWord8 0x11 >> putInt ix --- | Compact output for logging: only useful information but not payload bytes. +-- | Format messages in human readable form. Note that output is +-- compact and suitable for logging: only useful information but not +-- payload bytes. +-- ppMessage :: Message -> String ppMessage (Bitfield _) = "Bitfield " ppMessage (Piece blk) = "Piece " ++ ppBlock blk diff --git a/src/Network/BitTorrent/Tracker/Scrape.hs b/src/Network/BitTorrent/Tracker/Scrape.hs index 49451a57..c3f4ee64 100644 --- a/src/Network/BitTorrent/Tracker/Scrape.hs +++ b/src/Network/BitTorrent/Tracker/Scrape.hs @@ -5,7 +5,7 @@ -- Stability : experimental -- Portability : portable -- --- By convention most trackers support anouther form of request, +-- By convention most trackers support another form of request, -- which queries the state of a given torrent (or all torrents) that the -- tracker is managing. This module provides a way to easily request -- scrape info for a particular torrent list. -- cgit v1.2.3