47
void tr_torrentRecheckCompleteness( tr_torrent * );
49
int tr_trackerInfoInit( struct tr_tracker_info * info,
53
void tr_trackerInfoClear( struct tr_tracker_info * info );
50
55
void tr_peerIdNew ( char* buf, int buflen );
52
void tr_torrentResetTransferStats( tr_torrent_t * );
54
int tr_torrentAddCompact( tr_torrent_t * tor, int from,
55
uint8_t * buf, int count );
56
int tr_torrentAttachPeer( tr_torrent_t * tor, struct tr_peer_s * );
58
void tr_torrentSetHasPiece( tr_torrent_t * tor, int pieceIndex, int has );
60
void tr_torrentReaderLock ( const tr_torrent_t * );
61
void tr_torrentReaderUnlock ( const tr_torrent_t * );
62
void tr_torrentWriterLock ( tr_torrent_t * );
63
void tr_torrentWriterUnlock ( tr_torrent_t * );
57
void tr_torrentResetTransferStats( tr_torrent * );
59
void tr_torrentSetHasPiece( tr_torrent * tor, int pieceIndex, int has );
61
void tr_torrentLock ( const tr_torrent * );
62
void tr_torrentUnlock ( const tr_torrent * );
64
int tr_torrentIsSeed ( const tr_torrent * );
66
void tr_torrentChangeMyPort ( tr_torrent * );
68
int tr_torrentExists( tr_handle *, const uint8_t * );
69
tr_torrent* tr_torrentFindFromHash( tr_handle *, const uint8_t * );
70
tr_torrent* tr_torrentFindFromObfuscatedHash( tr_handle *, const uint8_t* );
72
void tr_torrentGetRates( const tr_torrent *, float * toClient, float * toPeer );
65
74
/* get the index of this piece's first block */
66
75
#define tr_torPieceFirstBlock(tor,piece) ( (piece) * (tor)->blockCountInPiece )
81
90
( ((block)==((tor)->blockCount-1)) ? (tor)->lastBlockSize : (tor)->blockSize )
83
92
#define tr_block(a,b) _tr_block(tor,a,b)
84
int _tr_block( const tr_torrent_t * tor, int index, int begin );
93
int _tr_block( const tr_torrent * tor, int index, int begin );
95
uint64_t tr_pieceOffset( const tr_torrent * tor, int index, int begin, int length );
89
TR_RUN_CHECKING = (1<<0), /* checking files' checksums */
90
TR_RUN_RUNNING = (1<<1), /* seeding or leeching */
91
TR_RUN_STOPPING = (1<<2), /* stopping */
92
TR_RUN_STOPPING_NET_WAIT = (1<<3), /* waiting on network -- we're
93
telling tracker we've stopped */
94
TR_RUN_STOPPED = (1<<4) /* stopped */
103
tr_handle_t * handle;
106
tr_speedlimit_t uploadLimitMode;
107
tr_speedlimit_t downloadLimitMode;
108
struct tr_ratecontrol_s * upload;
109
struct tr_ratecontrol_s * download;
110
struct tr_ratecontrol_s * swarmspeed;
113
char errorString[128];
116
char peer_id[TR_ID_LEN+1];
121
/* An escaped string used to include the hash in HTTP queries */
122
char escapedHashString[3*SHA_DIGEST_LENGTH+1];
112
tr_speedlimit uploadLimitMode;
113
tr_speedlimit downloadLimitMode;
114
struct tr_ratecontrol * upload;
115
struct tr_ratecontrol * download;
116
struct tr_ratecontrol * swarmspeed;
119
char errorString[128];
121
uint8_t obfuscatedHash[SHA_DIGEST_LENGTH];
124
123
/* Where to download */
127
126
/* How many bytes we ask for per request */
134
int blockCountInPiece;
135
int blockCountInLastPiece;
133
int blockCountInPiece;
134
int blockCountInLastPiece;
137
struct tr_completion_s * completion;
139
volatile char dieFlag;
140
struct tr_bitfield_s * uncheckedPieces;
141
run_status_t runStatus;
142
cp_status_t cpStatus;
143
struct tr_thread_s * thread;
144
struct tr_rwlock_s * lock;
146
struct tr_tracker_s * tracker;
151
char fastResumeDirty;
154
struct tr_peer_s * peers[TR_MAX_PEER_COUNT];
156
uint64_t downloadedCur;
157
uint64_t downloadedPrev;
158
uint64_t uploadedCur;
159
uint64_t uploadedPrev;
160
uint64_t activityDate;
136
struct tr_completion * completion;
138
struct tr_bitfield * uncheckedPieces;
139
cp_status_t cpStatus;
141
struct tr_tracker * tracker;
142
struct tr_publisher_tag * trackerSubscription;
144
uint64_t downloadedCur;
145
uint64_t downloadedPrev;
146
uint64_t uploadedCur;
147
uint64_t uploadedPrev;
149
uint64_t corruptPrev;
153
uint64_t activityDate;
155
tr_torrent_status_func * status_func;
156
void * status_func_user_data;
158
unsigned int pexDisabled : 1;
159
unsigned int statCur : 1;
160
unsigned int isRunning : 1;
162
tr_recheck_state recheckState;
173
tr_torrent_t * torrentList;
179
char useDownloadLimit;
180
struct tr_ratecontrol_s * upload;
181
struct tr_ratecontrol_s * download;
183
struct tr_shared_s * shared;
185
char key[TR_KEY_LEN+1];
187
tr_handle_status_t stats[2];
189
#define TR_AZ_ID_LEN 20
190
uint8_t azId[TR_AZ_ID_LEN];
171
tr_encryption_mode encryptionMode;
173
struct tr_event_handle * events;
176
tr_torrent * torrentList;
182
char useDownloadLimit;
183
struct tr_ratecontrol * upload;
184
struct tr_ratecontrol * download;
186
struct tr_peerMgr * peerMgr;
187
struct tr_shared * shared;
189
struct tr_lock * lock;
191
tr_handle_status stats[2];
196
#define TR_AZ_ID_LEN 20
197
uint8_t azId[TR_AZ_ID_LEN];
200
void tr_globalLock ( struct tr_handle * );
201
void tr_globalUnlock ( struct tr_handle * );
202
int tr_globalIsLocked ( const struct tr_handle * );