Class: QuartzTorrent::TorrentData

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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
   = {}
   = {}
  @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

Instance Attribute Details

#alarmsObject (readonly)

Alarms object for this torrent



124
125
126
# File 'lib/quartz_torrent/peerclient.rb', line 124

def alarms
  @alarms
end

#blockStateObject

Returns the value of attribute blockState.



76
77
78
# File 'lib/quartz_torrent/peerclient.rb', line 76

def blockState
  @blockState
end

#bytesDownloadedObject

Returns the value of attribute bytesDownloaded.



85
86
87
# File 'lib/quartz_torrent/peerclient.rb', line 85

def bytesDownloaded
  @bytesDownloaded
end

#bytesDownloadedDataOnlyObject

Returns the value of attribute bytesDownloadedDataOnly.



83
84
85
# File 'lib/quartz_torrent/peerclient.rb', line 83

def bytesDownloadedDataOnly
  @bytesDownloadedDataOnly
end

#bytesUploadedObject

Returns the value of attribute bytesUploaded.



86
87
88
# File 'lib/quartz_torrent/peerclient.rb', line 86

def bytesUploaded
  @bytesUploaded
end

#bytesUploadedDataOnlyObject

Returns the value of attribute bytesUploadedDataOnly.



84
85
86
# File 'lib/quartz_torrent/peerclient.rb', line 84

def bytesUploadedDataOnly
  @bytesUploadedDataOnly
end

#checkMetadataPieceManagerTimerObject

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

#checkPieceManagerTimerObject

Timer handle for timer that checks piece manager results



105
106
107
# File 'lib/quartz_torrent/peerclient.rb', line 105

def checkPieceManagerTimer
  @checkPieceManagerTimer
end

#downloadCompletedTimeObject

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

#downRateLimitObject

The RateLimit for downloading this torrent.



113
114
115
# File 'lib/quartz_torrent/peerclient.rb', line 113

def downRateLimit
  @downRateLimit
end

#infoObject

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

#infoHashObject

The infoHash of the torrent



70
71
72
# File 'lib/quartz_torrent/peerclient.rb', line 70

def infoHash
  @infoHash
end

#isEndgameObject

Returns the value of attribute isEndgame.



95
96
97
# File 'lib/quartz_torrent/peerclient.rb', line 95

def isEndgame
  @isEndgame
end

#magnetObject

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

#managePeersTimerObject

Timer handle for timer that manages peers.



101
102
103
# File 'lib/quartz_torrent/peerclient.rb', line 101

def managePeersTimer
  @managePeersTimer
end

#metainfoPieceStateObject

Returns the value of attribute metainfoPieceState.



96
97
98
# File 'lib/quartz_torrent/peerclient.rb', line 96

def metainfoPieceState
  @metainfoPieceState
end

#metainfoRequestTimerObject

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 metainfoRequestTimer
  @metainfoRequestTimer
end

#pausedObject

Is the torrent paused



109
110
111
# File 'lib/quartz_torrent/peerclient.rb', line 109

def paused
  @paused
end

#peerChangeListenerObject

Returns the value of attribute peerChangeListener.



82
83
84
# File 'lib/quartz_torrent/peerclient.rb', line 82

def peerChangeListener
  @peerChangeListener
end

#peerManagerObject

Returns the value of attribute peerManager.



75
76
77
# File 'lib/quartz_torrent/peerclient.rb', line 75

def peerManager
  @peerManager
end

#peersObject

Returns the value of attribute peers.



72
73
74
# File 'lib/quartz_torrent/peerclient.rb', line 72

def peers
  @peers
end

#pieceManagerObject

Returns the value of attribute pieceManager.



77
78
79
# File 'lib/quartz_torrent/peerclient.rb', line 77

def pieceManager
  @pieceManager
end

#pieceManagerMetainfoRequestMetadataObject

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 
  
end

#pieceManagerRequestMetadataObject

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 
  
end

#queuedObject

Is the torrent queued



111
112
113
# File 'lib/quartz_torrent/peerclient.rb', line 111

def queued
  @queued
end

#ratioObject

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

#requestBlocksTimerObject

Timer handle for timer that requests blocks



107
108
109
# File 'lib/quartz_torrent/peerclient.rb', line 107

def requestBlocksTimer
  @requestBlocksTimer
end

#stateObject

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.


94
95
96
# File 'lib/quartz_torrent/peerclient.rb', line 94

def state
  @state
end

#trackerClientObject

Returns the value of attribute trackerClient.



71
72
73
# File 'lib/quartz_torrent/peerclient.rb', line 71

def trackerClient
  @trackerClient
end

#uploadDurationObject

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

#upRateLimitObject

The RateLimit for uploading to peers for this torrent.



115
116
117
# File 'lib/quartz_torrent/peerclient.rb', line 115

def upRateLimit
  @upRateLimit
end