merge of branch v0.6-idclean 7180

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7187 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
chrisparker126 2014-03-17 20:56:06 +00:00
parent 7815efb16f
commit 0f29d28b1b
397 changed files with 6503 additions and 5702 deletions

View file

@ -56,7 +56,7 @@ class HashThread ;
class peerInfo
{
public:
peerInfo(std::string peerId_in):peerId(peerId_in),state(PQIPEER_NOT_ONLINE),desiredRate(0),actualRate(0),
peerInfo(const RsPeerId& peerId_in):peerId(peerId_in),state(PQIPEER_NOT_ONLINE),desiredRate(0),actualRate(0),
lastTS(0),
recvTS(0), lastTransfers(0), nResets(0),
rtt(0), rttActive(false), rttStart(0), rttOffset(0),
@ -64,7 +64,7 @@ public:
{
return;
}
peerInfo(std::string peerId_in,uint32_t state_in,uint32_t maxRate_in):
peerInfo(const RsPeerId& peerId_in,uint32_t state_in,uint32_t maxRate_in):
peerId(peerId_in),state(state_in),desiredRate(maxRate_in),actualRate(0),
lastTS(0),
recvTS(0), lastTransfers(0), nResets(0),
@ -73,7 +73,7 @@ public:
{
return;
}
std::string peerId;
RsPeerId peerId;
uint32_t state;
double desiredRate;
double actualRate;
@ -111,9 +111,9 @@ public:
};
ftFileStatus():hash(""),stat(PQIFILE_INIT) {}
ftFileStatus(std::string hash_in):hash(hash_in),stat(PQIFILE_INIT) {}
ftFileStatus(const RsFileHash& hash_in):hash(hash_in),stat(PQIFILE_INIT) {}
std::string hash;
RsFileHash hash;
Status stat;
};
@ -124,13 +124,13 @@ public:
~ftTransferModule();
//interface to download controller
bool setFileSources(const std::list<std::string>& peerIds);
bool addFileSource(const std::string& peerId);
bool removeFileSource(const std::string& peerId);
bool setPeerState(const std::string& peerId,uint32_t state,uint32_t maxRate); //state = ONLINE/OFFLINE
bool getFileSources(std::list<std::string> &peerIds);
bool getPeerState(const std::string& peerId,uint32_t &state,uint32_t &tfRate);
uint32_t getDataRate(const std::string& peerId);
bool setFileSources(const std::list<RsPeerId>& peerIds);
bool addFileSource(const RsPeerId& peerId);
bool removeFileSource(const RsPeerId& peerId);
bool setPeerState(const RsPeerId& peerId,uint32_t state,uint32_t maxRate); //state = ONLINE/OFFLINE
bool getFileSources(std::list<RsPeerId> &peerIds);
bool getPeerState(const RsPeerId& peerId,uint32_t &state,uint32_t &tfRate);
uint32_t getDataRate(const RsPeerId& peerId);
bool cancelTransfer();
bool cancelFileTransferUpward();
bool completeFileTransfer();
@ -138,17 +138,17 @@ public:
void forceCheck() ;
//interface to multiplex module
bool recvFileData(const std::string& peerId, uint64_t offset, uint32_t chunk_size, void *data);
void locked_requestData(const std::string& peerId, uint64_t offset, uint32_t chunk_size);
bool recvFileData(const RsPeerId& peerId, uint64_t offset, uint32_t chunk_size, void *data);
void locked_requestData(const RsPeerId& peerId, uint64_t offset, uint32_t chunk_size);
//interface to file creator
bool locked_getChunk(const std::string& peer_id,uint32_t size_hint,uint64_t &offset, uint32_t &chunk_size);
bool locked_getChunk(const RsPeerId& peer_id,uint32_t size_hint,uint64_t &offset, uint32_t &chunk_size);
bool locked_storeData(uint64_t offset, uint32_t chunk_size, void *data);
int tick();
std::string hash() { return mHash; }
uint64_t size() { return mSize; }
const RsFileHash& hash() const { return mHash; }
uint64_t size() const { return mSize; }
//internal used functions
bool queryInactive();
@ -175,13 +175,13 @@ private:
ftDataMultiplex *mMultiplexor;
ftController *mFtController;
std::string mHash;
RsFileHash mHash;
uint64_t mSize;
RsMutex tfMtx; /* below is mutex protected */
std::list<std::string> mOnlinePeers;
std::map<std::string,peerInfo> mFileSources;
std::list<RsPeerId> mOnlinePeers;
std::map<RsPeerId,peerInfo> mFileSources;
uint16_t mFlag; //2:file canceled, 1:transfer complete, 0: not complete, 3: checking hash, 4: checking chunks
double desiredRate;