bittorrent-0.0.0.3: Bittorrent protocol implementation.

Portabilityportable
Stabilityexperimental
Maintainerpxqr.sta@gmail.com
Safe HaskellNone

Data.Torrent.Progress

Contents

Description

Progress used to track amount downloaded/left/upload bytes either on per client or per torrent basis. This value is used to notify the tracker and usually shown to the user. To aggregate total progress you can use the Monoid instance.

Synopsis

Progress

data Progress Source

Progress data is considered as dynamic within one client session. This data also should be shared across client application sessions (e.g. files), otherwise use startProgress to get initial Progress value.

Constructors

Progress 

Fields

_downloaded :: !Word64

Total amount of bytes downloaded;

_left :: !Word64

Total amount of bytes left;

_uploaded :: !Word64

Total amount of bytes uploaded.

Instances

Eq Progress 
Read Progress 
Show Progress 
ToJSON Progress 
FromJSON Progress 
Monoid Progress

Can be used to aggregate total progress.

S.Serialize Progress

UDP tracker compatible encoding.

Default Progress 
URLEncode Progress

HTTP Tracker protocol compatible encoding.

Pretty Progress 

Lens

Construction

startProgress :: Integer -> ProgressSource

Initial progress is used when there are no session before.

Please note that tracker might penalize client some way if the do not accumulate progress. If possible and save Progress between client sessions to avoid that.

downloadedProgress :: Int -> Progress -> ProgressSource

Used when the client download some data from any peer.

enqueuedProgress :: Integer -> Progress -> ProgressSource

Used when leecher join client session.

uploadedProgress :: Int -> Progress -> ProgressSource

Used when the client upload some data to any peer.

dequeuedProgress :: Integer -> Progress -> ProgressSource

Used when leecher leave client session. (e.g. user deletes not completed torrent)

Query

canDownload :: Ratio Int -> Progress -> BoolSource

Check global download limit by uploaded / downloaded ratio.

canUpload :: Ratio Int -> Progress -> BoolSource

Check global upload limit by downloaded / uploaded ratio.