mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-13 11:32:48 -04:00
More Improvements to FileTransfer:
* Added TlvShallowClear() to serialisers * Added RsQueueThread for periodic queue processes. * Completed ftDataMultiplex which replaces ftServer/ClientModules. * Added Server Queue / Thread to ftDataMultiplex. * Added ftdataplextest to exercise ftDataMultiplex. * Generalised ftFileSearch to handle an array of ftSearch classes. * Tweaked rsfiles.h #defines to match new ftFileSearch scheme. * Added Generic ftData Interfaces for Testing. * added ftDataSend/Recv Interfaces to ftServer + ftDataMultiplex respectively. * Completed much of ftServer (External Interface), but not yet done. * Extra debugging and small changes to ftExtraList * Integrated new ftTransferModule with minor interface changes. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@660 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
d584516859
commit
5c6e558942
22 changed files with 1355 additions and 326 deletions
|
@ -34,11 +34,16 @@
|
|||
* It must be able to cope with varying data rates and dropped peers without flooding the system with too many requests.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <map>
|
||||
#include <list>
|
||||
#include <ftFileCreator.h>
|
||||
|
||||
|
||||
#include <map>
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
||||
#include "ft/ftfilecreator.h"
|
||||
#include "ft/ftdatamultiplex.h"
|
||||
|
||||
#include "util/rsthreads.h"
|
||||
|
||||
const int PQIPEER_INIT = 0x0000;
|
||||
const int PQIPEER_NOT_ONLINE = 0x0001;
|
||||
const int PQIPEER_DOWNLOADING = 0x0002;
|
||||
|
@ -47,13 +52,15 @@ const int PQIPEER_SUSPEND = 0x0010;
|
|||
|
||||
class Request
|
||||
{
|
||||
public:
|
||||
uint64_t offset;
|
||||
uint32_t chunkSize;
|
||||
};
|
||||
|
||||
class peerInfo
|
||||
{
|
||||
std:string peerId;
|
||||
public:
|
||||
std::string peerId;
|
||||
uint32_t state;
|
||||
uint32_t desiredRate;
|
||||
Request lastRequest;
|
||||
|
@ -66,50 +73,55 @@ class peerInfo
|
|||
time_t lastTS;
|
||||
};
|
||||
|
||||
class ftTransferModule
|
||||
{
|
||||
public:
|
||||
ftTransferModule(ftFileCreator *fc,ftClientModule *cm);
|
||||
~ftTransferModule();
|
||||
|
||||
//interface to download controller
|
||||
bool setFileSources(std::list<std::string> peerIds);
|
||||
bool setPeerState(std::string peerId,uint32_t state,uint32_t maxRate); //state = ONLINE/OFFLINE
|
||||
uint32_t getDataRate(std::string peerId);
|
||||
bool stopTransfer();
|
||||
bool resumeTransfer();
|
||||
bool completeFileTransfer();
|
||||
|
||||
//interface to client module
|
||||
bool recvFileData(uint64_t offset, uint32_t chunk_size, void *data); //called by ftClientModule when data arrives
|
||||
void requestData(uint64_t offset, uint32_t chunk_size);
|
||||
|
||||
//interface to file creator , just wrapper functions that call the ftFileCreator
|
||||
bool getChunk(uint64_t &offset, uint32_t &chunk_size);
|
||||
bool storeData(uint64_t offset, uint32_t chunk_size, void *data);
|
||||
|
||||
//internal used functions
|
||||
void queryInactive();
|
||||
|
||||
int tick();
|
||||
|
||||
/* add by DrBob for interfaces */
|
||||
std::string hash() { return mHash; }
|
||||
uint64_t size() { return mSize; }
|
||||
|
||||
public:
|
||||
ftFileCreator *mFileCreator;
|
||||
ftClientModule *mClientModule;
|
||||
|
||||
private:
|
||||
std::string mHash;
|
||||
uint64_t mSize;
|
||||
std::list<std::string> mFileSources;
|
||||
std::map<std::string,peerInfo> mOnlinePeers;
|
||||
|
||||
uint64_t mOffset;
|
||||
uint32_t mChunkSize;
|
||||
bool mFlag; //1:transfer complete, 0: not complete
|
||||
};
|
||||
|
||||
#endif //FT_TRANSFER_MODULE_HEADER
|
||||
class ftTransferModule
|
||||
{
|
||||
public:
|
||||
ftTransferModule(ftFileCreator *fc, ftDataMultiplex *dm);
|
||||
~ftTransferModule();
|
||||
|
||||
//interface to download controller
|
||||
bool setFileSources(std::list<std::string> peerIds);
|
||||
bool setPeerState(std::string peerId,uint32_t state,uint32_t maxRate); //state = ONLINE/OFFLINE
|
||||
uint32_t getDataRate(std::string peerId);
|
||||
bool stopTransfer();
|
||||
bool resumeTransfer();
|
||||
bool completeFileTransfer();
|
||||
|
||||
//interface to multiplex module
|
||||
bool recvFileData(std::string peerId, uint64_t offset,
|
||||
uint32_t chunk_size, void *data);
|
||||
void requestData(std::string peerId, uint64_t offset, uint32_t chunk_size);
|
||||
|
||||
//interface to file creator
|
||||
bool getChunk(uint64_t &offset, uint32_t &chunk_size);
|
||||
bool storeData(uint64_t offset, uint32_t chunk_size, void *data);
|
||||
|
||||
int tick();
|
||||
|
||||
std::string hash() { return mHash; }
|
||||
uint64_t size() { return mSize; }
|
||||
|
||||
//internal used functions
|
||||
void queryInactive();
|
||||
void adjustSpeed();
|
||||
|
||||
private:
|
||||
|
||||
/* These have independent Mutexes / are const locally (no Mutex protection)*/
|
||||
ftFileCreator *mFileCreator;
|
||||
ftDataMultiplex *mMultiplexor;
|
||||
|
||||
std::string mHash;
|
||||
uint64_t mSize;
|
||||
|
||||
RsMutex tfMtx; /* below is mutex protected */
|
||||
|
||||
std::list<std::string> mFileSources;
|
||||
std::map<std::string,peerInfo> mOnlinePeers;
|
||||
|
||||
uint64_t mOffset;
|
||||
uint32_t mChunkSize;
|
||||
bool mFlag; //1:transfer complete, 0: not complete
|
||||
};
|
||||
|
||||
#endif //FT_TRANSFER_MODULE_HEADER
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue