1
1
/******************************************************************************
2
* $Id: internal.h 4037 2007-12-02 01:27:14Z charles $
2
* $Id: internal.h 4404 2008-01-01 17:20:20Z charles $
4
* Copyright (c) 2005-2007 Transmission authors and contributors
4
* Copyright (c) 2005-2008 Transmission authors and contributors
6
6
* Permission is hereby granted, free of charge, to any person obtaining a
7
7
* copy of this software and associated documentation files (the "Software"),
56
52
void tr_peerIdNew ( char* buf, int buflen );
58
void tr_torrentResetTransferStats( tr_torrent * );
60
void tr_torrentSetHasPiece( tr_torrent * tor, int pieceIndex, int has );
62
void tr_torrentLock ( const tr_torrent * );
63
void tr_torrentUnlock ( const tr_torrent * );
65
int tr_torrentIsSeed ( const tr_torrent * );
67
void tr_torrentChangeMyPort ( tr_torrent * );
69
int tr_torrentExists( tr_handle *, const uint8_t * );
70
tr_torrent* tr_torrentFindFromHash( tr_handle *, const uint8_t * );
71
tr_torrent* tr_torrentFindFromObfuscatedHash( tr_handle *, const uint8_t* );
73
void tr_torrentGetRates( const tr_torrent *, float * toClient, float * toPeer );
75
/* get the index of this piece's first block */
76
#define tr_torPieceFirstBlock(tor,piece) ( (piece) * (tor)->blockCountInPiece )
78
/* what piece index is this block in? */
79
#define tr_torBlockPiece(tor,block) ( (block) / (tor)->blockCountInPiece )
81
/* how many blocks are in this piece? */
82
#define tr_torPieceCountBlocks(tor,piece) \
83
( ((piece)==((tor)->info.pieceCount-1)) ? (tor)->blockCountInLastPiece : (tor)->blockCountInPiece )
85
/* how many bytes are in this piece? */
86
#define tr_torPieceCountBytes(tor,piece) \
87
( ((piece)==((tor)->info.pieceCount-1)) ? (tor)->lastPieceSize : (tor)->info.pieceSize )
89
/* how many bytes are in this block? */
90
#define tr_torBlockCountBytes(tor,block) \
91
( ((block)==((tor)->blockCount-1)) ? (tor)->lastBlockSize : (tor)->blockSize )
93
#define tr_block(a,b) _tr_block(tor,a,b)
94
int _tr_block( const tr_torrent * tor, int index, int begin );
96
uint64_t tr_pieceOffset( const tr_torrent * tor, int index, int begin, int length );
113
tr_speedlimit uploadLimitMode;
114
tr_speedlimit downloadLimitMode;
115
struct tr_ratecontrol * upload;
116
struct tr_ratecontrol * download;
117
struct tr_ratecontrol * swarmspeed;
120
char errorString[128];
122
uint8_t obfuscatedHash[SHA_DIGEST_LENGTH];
124
/* Where to download */
127
/* How many bytes we ask for per request */
134
int blockCountInPiece;
135
int blockCountInLastPiece;
137
struct tr_completion * completion;
139
struct tr_bitfield * uncheckedPieces;
140
cp_status_t cpStatus;
142
struct tr_tracker * tracker;
143
struct tr_publisher_tag * trackerSubscription;
145
uint64_t downloadedCur;
146
uint64_t downloadedPrev;
147
uint64_t uploadedCur;
148
uint64_t uploadedPrev;
150
uint64_t corruptPrev;
154
uint64_t activityDate;
156
tr_torrent_status_func * status_func;
157
void * status_func_user_data;
159
unsigned int pexDisabled : 1;
160
unsigned int statCur : 1;
161
unsigned int isRunning : 1;
163
tr_recheck_state recheckState;
172
56
tr_encryption_mode encryptionMode;