class QuartzTorrent::TorrentData
Class used by PeerClientHandler
to keep track of information associated with a single torrent being downloaded/uploaded.
Attributes
Alarms
object for this torrent
Timer handle for timer that checks metadata piece manager results
Timer handle for timer that checks piece manager results
The RateLimit
for downloading this torrent.
Time at which we completely downloaded all bytes of the torrent.
The torrents Metainfo.Info struct. This is nil if the torrent has no metadata and we need to download it (i.e. a magnet link)
The infoHash of the torrent
The MagnetURI
object, if this torrent was created from a magnet link. Nil for torrents not created from magnets.
Timer handle for timer that manages peers.
The timer handle for the timer that requests metainfo pieces. This is used to cancel the timer when the metadata is completely downloaded.
Is the torrent paused
Metadata associated with outstanding requests to the PieceManager
responsible for the pieces of the torrent metainfo.
Metadata associated with outstanding requests to the PieceManager
responsible for the pieces of the torrent data.
Is the torrent queued
After we have completed downloading a torrent, we will continue to upload until we have uploaded ratio * torrent_size bytes. If nil, no limit on upload.
Timer handle for timer that requests blocks
State of the torrent. Is one of the following states:
:initializing Datastructures have been created, but no work started. :checking_pieces Checking piece hashes on startup :downloading_metainfo Downloading the torrent metainfo :uploading The torrent is complete and we are only uploading :running The torrent is incomplete and we are downloading and uploading :error There was an unrecoverable error with the torrent.
The RateLimit
for uploading to peers for this torrent.
Maximum amount of time in seconds that the torrent can be in the uploading state before it’s paused.
Public Class Methods
# File lib/quartz_torrent/peerclient.rb, line 35 def initialize(infoHash, info, trackerClient) @infoHash = infoHash @info = info @trackerClient = trackerClient @peerManager = PeerManager.new @pieceManagerRequestMetadata = {} @pieceManagerMetainfoRequestMetadata = {} @bytesDownloadedDataOnly = 0 @bytesUploadedDataOnly = 0 @bytesDownloaded = 0 @bytesUploaded = 0 @magnet = nil @peers = PeerHolder.new @state = :initializing @blockState = nil @metainfoPieceState = nil @metainfoRequestTimer = nil @managePeersTimer = nil @checkMetadataPieceManagerTimer = nil @checkPieceManagerTimer = nil @requestBlocksTimer = nil @paused = false @queued = false @downRateLimit = nil @upRateLimit = nil @ratio = nil @uploadDuration = nil @downloadCompletedTime = nil @isEndgame = false @alarms = Alarms.new end