class QuartzTorrent::TorrentData

Class used by PeerClientHandler to keep track of information associated with a single torrent being downloaded/uploaded.

Attributes

alarms[R]

Alarms object for this torrent

blockState[RW]
bytesDownloaded[RW]
bytesDownloadedDataOnly[RW]
bytesUploaded[RW]
bytesUploadedDataOnly[RW]
checkMetadataPieceManagerTimer[RW]

Timer handle for timer that checks metadata piece manager results

checkPieceManagerTimer[RW]

Timer handle for timer that checks piece manager results

downRateLimit[RW]

The RateLimit for downloading this torrent.

downloadCompletedTime[RW]

Time at which we completely downloaded all bytes of the torrent.

info[RW]

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)

infoHash[RW]

The infoHash of the torrent

isEndgame[RW]
magnet[RW]

The MagnetURI object, if this torrent was created from a magnet link. Nil for torrents not created from magnets.

managePeersTimer[RW]

Timer handle for timer that manages peers.

metainfoPieceState[RW]
metainfoRequestTimer[RW]

The timer handle for the timer that requests metainfo pieces. This is used to cancel the timer when the metadata is completely downloaded.

paused[RW]

Is the torrent paused

peerChangeListener[RW]
peerManager[RW]
peers[RW]
pieceManager[RW]
pieceManagerMetainfoRequestMetadata[RW]

Metadata associated with outstanding requests to the PieceManager responsible for the pieces of the torrent metainfo.

pieceManagerRequestMetadata[RW]

Metadata associated with outstanding requests to the PieceManager responsible for the pieces of the torrent data.

queued[RW]

Is the torrent queued

ratio[RW]

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.

requestBlocksTimer[RW]

Timer handle for timer that requests blocks

state[RW]

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.
trackerClient[RW]
upRateLimit[RW]

The RateLimit for uploading to peers for this torrent.

uploadDuration[RW]

Maximum amount of time in seconds that the torrent can be in the uploading state before it’s paused.

Public Class Methods

new(infoHash, info, trackerClient) click to toggle source
# 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