class PiecePicker;
class CongestionController;
class PeerSelector;
+ typedef void (*ProgressCallback) (int transfer, bin64_t bin);
/** A class representing single file transfer. */
tint init_time_;
+ #define SWFT_MAX_TRANSFER_CB 8
+ ProgressCallback callbacks[SWFT_MAX_TRANSFER_CB];
+ uint8_t cb_agg[SWFT_MAX_TRANSFER_CB];
+ int cb_installed;
+
public:
void OnDataIn (bin64_t pos);
void OnPexIn (const Address& addr);
friend uint64_t SeqComplete (int fdes);
friend int Open (const char* filename, const Sha1Hash& hash) ;
friend void Close (int fd) ;
+ friend void AddProgressCallback (int transfer,ProgressCallback cb,uint8_t agg);
+ friend void RemoveProgressCallback (int transfer,ProgressCallback cb);
+ friend void ExternallyRetrieved (int transfer,bin64_t piece);
};
* @param expires (not used currently) when to consider request expired
* @return the bin number to request */
virtual bin64_t Pick (binmap_t& offered, uint64_t max_width, tint expires) = 0;
+ virtual void LimitRange (bin64_t range) = 0;
virtual ~PiecePicker() {}
};
return i<channels.size()?channels[i]:NULL;
}
static void CloseTransfer (FileTransfer* trans);
- static SOCKET default_socket() { return sockets[0].sock; }
protected:
/** Channel id: index in the channel array. */
static PeerSelector* peer_selector;
- #define SWFT_MAX_SOCK_OPEN 128
- static socket_callbacks_t sockets[SWFT_MAX_SOCK_OPEN];
- static int socket_count;
static tint last_tick;
static tbheap send_queue;
friend void AddPeer (Address address, const Sha1Hash& root);
friend void SetTracker(const Address& tracker);
friend int Open (const char*, const Sha1Hash&) ; // FIXME
- friend bool Listen3rdPartySocket (socket_callbacks_t);
};
int Listen (Address addr);
/** Run send/receive loop for the specified amount of time. */
void Loop (tint till);
- bool Listen3rdPartySocket (socket_callbacks_t);
+ bool Listen3rdPartySocket (sckrwecb_t);
/** Stop listening to a port. */
void Shutdown (int sock_des=-1);
/** Returns the number of bytes that are complete sequentially, starting from the
beginning, till the first not-yet-retrieved packet. */
uint64_t SeqComplete (int fdes);
+ /***/
+ int Find (Sha1Hash hash);
+ void AddProgressCallback (int transfer,ProgressCallback cb,uint8_t agg);
+ void RemoveProgressCallback (int transfer,ProgressCallback cb);
+ void ExternallyRetrieved (int transfer,bin64_t piece);
//uint32_t Width (const tbinvec& v);