Class: QuartzTorrent::TorrentData
- Inherits:
-
Object
- Object
- QuartzTorrent::TorrentData
- Defined in:
- lib/quartz_torrent/peerclient.rb
Overview
Class used by PeerClientHandler to keep track of information associated with a single torrent being downloaded/uploaded.
Instance Attribute Summary collapse
-
#alarms ⇒ Object
readonly
Alarms object for this torrent.
-
#blockState ⇒ Object
Returns the value of attribute blockState.
-
#bytesDownloaded ⇒ Object
Returns the value of attribute bytesDownloaded.
-
#bytesDownloadedDataOnly ⇒ Object
Returns the value of attribute bytesDownloadedDataOnly.
-
#bytesUploaded ⇒ Object
Returns the value of attribute bytesUploaded.
-
#bytesUploadedDataOnly ⇒ Object
Returns the value of attribute bytesUploadedDataOnly.
-
#checkMetadataPieceManagerTimer ⇒ Object
Timer handle for timer that checks metadata piece manager results.
-
#checkPieceManagerTimer ⇒ Object
Timer handle for timer that checks piece manager results.
-
#downloadCompletedTime ⇒ Object
Time at which we completely downloaded all bytes of the torrent.
-
#downRateLimit ⇒ Object
The RateLimit for downloading this torrent.
-
#info ⇒ Object
The torrents Metainfo.Info struct.
-
#infoHash ⇒ Object
The infoHash of the torrent.
-
#isEndgame ⇒ Object
Returns the value of attribute isEndgame.
-
#magnet ⇒ Object
The MagnetURI object, if this torrent was created from a magnet link.
-
#managePeersTimer ⇒ Object
Timer handle for timer that manages peers.
-
#metainfoPieceState ⇒ Object
Returns the value of attribute metainfoPieceState.
-
#metainfoRequestTimer ⇒ Object
The timer handle for the timer that requests metainfo pieces.
-
#paused ⇒ Object
Is the torrent paused.
-
#peerChangeListener ⇒ Object
Returns the value of attribute peerChangeListener.
-
#peerManager ⇒ Object
Returns the value of attribute peerManager.
-
#peers ⇒ Object
Returns the value of attribute peers.
-
#pieceManager ⇒ Object
Returns the value of attribute pieceManager.
-
#pieceManagerMetainfoRequestMetadata ⇒ Object
Metadata associated with outstanding requests to the PieceManager responsible for the pieces of the torrent metainfo.
-
#pieceManagerRequestMetadata ⇒ Object
Metadata associated with outstanding requests to the PieceManager responsible for the pieces of the torrent data.
-
#queued ⇒ Object
Is the torrent queued.
-
#ratio ⇒ Object
After we have completed downloading a torrent, we will continue to upload until we have uploaded ratio * torrent_size bytes.
-
#requestBlocksTimer ⇒ Object
Timer handle for timer that requests blocks.
-
#state ⇒ Object
State of the torrent.
-
#trackerClient ⇒ Object
Returns the value of attribute trackerClient.
-
#uploadDuration ⇒ Object
Maximum amount of time in seconds that the torrent can be in the uploading state before it’s paused.
-
#upRateLimit ⇒ Object
The RateLimit for uploading to peers for this torrent.
Instance Method Summary collapse
-
#initialize(infoHash, info, trackerClient) ⇒ TorrentData
constructor
A new instance of TorrentData.
Constructor Details
#initialize(infoHash, info, trackerClient) ⇒ TorrentData
Returns a new instance of TorrentData.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# 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 = nil = 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 |
Instance Attribute Details
#alarms ⇒ Object (readonly)
Alarms object for this torrent
124 125 126 |
# File 'lib/quartz_torrent/peerclient.rb', line 124 def alarms @alarms end |
#blockState ⇒ Object
Returns the value of attribute blockState.
76 77 78 |
# File 'lib/quartz_torrent/peerclient.rb', line 76 def blockState @blockState end |
#bytesDownloaded ⇒ Object
Returns the value of attribute bytesDownloaded.
85 86 87 |
# File 'lib/quartz_torrent/peerclient.rb', line 85 def bytesDownloaded @bytesDownloaded end |
#bytesDownloadedDataOnly ⇒ Object
Returns the value of attribute bytesDownloadedDataOnly.
83 84 85 |
# File 'lib/quartz_torrent/peerclient.rb', line 83 def bytesDownloadedDataOnly @bytesDownloadedDataOnly end |
#bytesUploaded ⇒ Object
Returns the value of attribute bytesUploaded.
86 87 88 |
# File 'lib/quartz_torrent/peerclient.rb', line 86 def bytesUploaded @bytesUploaded end |
#bytesUploadedDataOnly ⇒ Object
Returns the value of attribute bytesUploadedDataOnly.
84 85 86 |
# File 'lib/quartz_torrent/peerclient.rb', line 84 def bytesUploadedDataOnly @bytesUploadedDataOnly end |
#checkMetadataPieceManagerTimer ⇒ Object
Timer handle for timer that checks metadata piece manager results
103 104 105 |
# File 'lib/quartz_torrent/peerclient.rb', line 103 def checkMetadataPieceManagerTimer @checkMetadataPieceManagerTimer end |
#checkPieceManagerTimer ⇒ Object
Timer handle for timer that checks piece manager results
105 106 107 |
# File 'lib/quartz_torrent/peerclient.rb', line 105 def checkPieceManagerTimer @checkPieceManagerTimer end |
#downloadCompletedTime ⇒ Object
Time at which we completely downloaded all bytes of the torrent.
122 123 124 |
# File 'lib/quartz_torrent/peerclient.rb', line 122 def downloadCompletedTime @downloadCompletedTime end |
#downRateLimit ⇒ Object
The RateLimit for downloading this torrent.
113 114 115 |
# File 'lib/quartz_torrent/peerclient.rb', line 113 def downRateLimit @downRateLimit end |
#info ⇒ Object
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)
68 69 70 |
# File 'lib/quartz_torrent/peerclient.rb', line 68 def info @info end |
#infoHash ⇒ Object
The infoHash of the torrent
70 71 72 |
# File 'lib/quartz_torrent/peerclient.rb', line 70 def infoHash @infoHash end |
#isEndgame ⇒ Object
Returns the value of attribute isEndgame.
95 96 97 |
# File 'lib/quartz_torrent/peerclient.rb', line 95 def isEndgame @isEndgame end |
#magnet ⇒ Object
The MagnetURI object, if this torrent was created from a magnet link. Nil for torrents not created from magnets.
74 75 76 |
# File 'lib/quartz_torrent/peerclient.rb', line 74 def magnet @magnet end |
#managePeersTimer ⇒ Object
Timer handle for timer that manages peers.
101 102 103 |
# File 'lib/quartz_torrent/peerclient.rb', line 101 def managePeersTimer @managePeersTimer end |
#metainfoPieceState ⇒ Object
Returns the value of attribute metainfoPieceState.
96 97 98 |
# File 'lib/quartz_torrent/peerclient.rb', line 96 def end |
#metainfoRequestTimer ⇒ Object
The timer handle for the timer that requests metainfo pieces. This is used to cancel the timer when the metadata is completely downloaded.
99 100 101 |
# File 'lib/quartz_torrent/peerclient.rb', line 99 def end |
#paused ⇒ Object
Is the torrent paused
109 110 111 |
# File 'lib/quartz_torrent/peerclient.rb', line 109 def paused @paused end |
#peerChangeListener ⇒ Object
Returns the value of attribute peerChangeListener.
82 83 84 |
# File 'lib/quartz_torrent/peerclient.rb', line 82 def peerChangeListener @peerChangeListener end |
#peerManager ⇒ Object
Returns the value of attribute peerManager.
75 76 77 |
# File 'lib/quartz_torrent/peerclient.rb', line 75 def peerManager @peerManager end |
#peers ⇒ Object
Returns the value of attribute peers.
72 73 74 |
# File 'lib/quartz_torrent/peerclient.rb', line 72 def peers @peers end |
#pieceManager ⇒ Object
Returns the value of attribute pieceManager.
77 78 79 |
# File 'lib/quartz_torrent/peerclient.rb', line 77 def pieceManager @pieceManager end |
#pieceManagerMetainfoRequestMetadata ⇒ Object
Metadata associated with outstanding requests to the PieceManager responsible for the pieces of the torrent metainfo.
81 82 83 |
# File 'lib/quartz_torrent/peerclient.rb', line 81 def pieceManagerMetainfoRequestMetadata @pieceManagerMetainfoRequestMetadata end |
#pieceManagerRequestMetadata ⇒ Object
Metadata associated with outstanding requests to the PieceManager responsible for the pieces of the torrent data.
79 80 81 |
# File 'lib/quartz_torrent/peerclient.rb', line 79 def pieceManagerRequestMetadata @pieceManagerRequestMetadata end |
#queued ⇒ Object
Is the torrent queued
111 112 113 |
# File 'lib/quartz_torrent/peerclient.rb', line 111 def queued @queued end |
#ratio ⇒ Object
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.
118 119 120 |
# File 'lib/quartz_torrent/peerclient.rb', line 118 def ratio @ratio end |
#requestBlocksTimer ⇒ Object
Timer handle for timer that requests blocks
107 108 109 |
# File 'lib/quartz_torrent/peerclient.rb', line 107 def requestBlocksTimer @requestBlocksTimer end |
#state ⇒ Object
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
: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.
94 95 96 |
# File 'lib/quartz_torrent/peerclient.rb', line 94 def state @state end |
#trackerClient ⇒ Object
Returns the value of attribute trackerClient.
71 72 73 |
# File 'lib/quartz_torrent/peerclient.rb', line 71 def trackerClient @trackerClient end |
#uploadDuration ⇒ Object
Maximum amount of time in seconds that the torrent can be in the uploading state before it’s paused.
120 121 122 |
# File 'lib/quartz_torrent/peerclient.rb', line 120 def uploadDuration @uploadDuration end |
#upRateLimit ⇒ Object
The RateLimit for uploading to peers for this torrent.
115 116 117 |
# File 'lib/quartz_torrent/peerclient.rb', line 115 def upRateLimit @upRateLimit end |