mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-20 03:48:16 -04:00
changed std::string into RsFileHash for all file hashes
git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.6-IdCleaning@7137 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
533216c9e3
commit
acf34cd7ad
84 changed files with 698 additions and 718 deletions
|
@ -63,14 +63,14 @@ class ftRequest
|
|||
{
|
||||
public:
|
||||
|
||||
ftRequest(uint32_t type, const SSLIdType& peerId, const std::string& hash, uint64_t size, uint64_t offset, uint32_t chunk, void *data);
|
||||
ftRequest(uint32_t type, const RsPeerId& peerId, const RsFileHash& hash, uint64_t size, uint64_t offset, uint32_t chunk, void *data);
|
||||
|
||||
ftRequest()
|
||||
:mType(0), mSize(0), mOffset(0), mChunk(0), mData(NULL) { return; }
|
||||
|
||||
uint32_t mType;
|
||||
SSLIdType mPeerId;
|
||||
std::string mHash;
|
||||
RsPeerId mPeerId;
|
||||
RsFileHash mHash;
|
||||
uint64_t mSize;
|
||||
uint64_t mOffset;
|
||||
uint32_t mChunk;
|
||||
|
@ -93,17 +93,17 @@ class ftDataMultiplex: public ftDataRecv, public RsQueueThread
|
|||
|
||||
public:
|
||||
|
||||
ftDataMultiplex(const SSLIdType& ownId, ftDataSend *server, ftSearch *search);
|
||||
ftDataMultiplex(const RsPeerId& ownId, ftDataSend *server, ftSearch *search);
|
||||
|
||||
/* ftController Interface */
|
||||
bool addTransferModule(ftTransferModule *mod, ftFileCreator *f);
|
||||
bool removeTransferModule(std::string hash);
|
||||
bool removeTransferModule(const RsFileHash& hash);
|
||||
|
||||
/* data interface */
|
||||
/* get Details of File Transfers */
|
||||
bool FileUploads(std::list<std::string> &hashs);
|
||||
bool FileDownloads(std::list<std::string> &hashs);
|
||||
bool FileDetails(const std::string &hash, FileSearchFlags hintsflag, FileInfo &info);
|
||||
bool FileUploads(std::list<RsFileHash> &hashs);
|
||||
bool FileDownloads(std::list<RsFileHash> &hashs);
|
||||
bool FileDetails(const RsFileHash &hash, FileSearchFlags hintsflag, FileInfo &info);
|
||||
|
||||
void deleteUnusedServers() ;
|
||||
void handlePendingCrcRequests() ;
|
||||
|
@ -112,39 +112,39 @@ class ftDataMultiplex: public ftDataRecv, public RsQueueThread
|
|||
/*************** SEND INTERFACE (calls ftDataSend) *******************/
|
||||
|
||||
/* Client Send */
|
||||
bool sendDataRequest(const SSLIdType& peerId, const std::string& hash, uint64_t size, uint64_t offset, uint32_t chunksize);
|
||||
bool sendDataRequest(const RsPeerId& peerId, const RsFileHash& hash, uint64_t size, uint64_t offset, uint32_t chunksize);
|
||||
|
||||
/* Server Send */
|
||||
bool sendData(const SSLIdType& peerId, const std::string& hash, uint64_t size, uint64_t offset, uint32_t chunksize, void *data);
|
||||
bool sendData(const RsPeerId& peerId, const RsFileHash& hash, uint64_t size, uint64_t offset, uint32_t chunksize, void *data);
|
||||
|
||||
/* Server/client Send */
|
||||
bool sendChunkMapRequest(const SSLIdType& peerId, const std::string& hash,bool is_client) ;
|
||||
bool sendChunkMapRequest(const RsPeerId& peerId, const RsFileHash& hash,bool is_client) ;
|
||||
|
||||
|
||||
/* called from a separate thread */
|
||||
bool sendSingleChunkCRCRequests(const std::string& hash, const std::vector<uint32_t>& to_ask) ;
|
||||
bool sendSingleChunkCRCRequests(const RsFileHash& hash, const std::vector<uint32_t>& to_ask) ;
|
||||
|
||||
bool dispatchReceivedChunkCheckSum() ;
|
||||
|
||||
/*************** RECV INTERFACE (provides ftDataRecv) ****************/
|
||||
|
||||
/* Client Recv */
|
||||
virtual bool recvData(const SSLIdType& peerId, const std::string& hash, uint64_t size, uint64_t offset, uint32_t chunksize, void *data);
|
||||
virtual bool recvData(const RsPeerId& peerId, const RsFileHash& hash, uint64_t size, uint64_t offset, uint32_t chunksize, void *data);
|
||||
/* Server Recv */
|
||||
virtual bool recvDataRequest(const SSLIdType& peerId, const std::string& hash, uint64_t size, uint64_t offset, uint32_t chunksize);
|
||||
virtual bool recvDataRequest(const RsPeerId& peerId, const RsFileHash& hash, uint64_t size, uint64_t offset, uint32_t chunksize);
|
||||
|
||||
/// Receive a request for a chunk map
|
||||
virtual bool recvChunkMapRequest(const SSLIdType& peer_id,const std::string& hash,bool is_client) ;
|
||||
virtual bool recvChunkMapRequest(const RsPeerId& peer_id,const RsFileHash& hash,bool is_client) ;
|
||||
/// Receive a chunk map
|
||||
virtual bool recvChunkMap(const SSLIdType& peer_id,const std::string& hash,const CompressedChunkMap& cmap,bool is_client) ;
|
||||
virtual bool recvChunkMap(const RsPeerId& peer_id,const RsFileHash& hash,const CompressedChunkMap& cmap,bool is_client) ;
|
||||
|
||||
virtual bool recvSingleChunkCRCRequest(const SSLIdType& peer_id,const std::string& hash,uint32_t chunk_id) ;
|
||||
virtual bool recvSingleChunkCRC(const SSLIdType& peer_id,const std::string& hash,uint32_t chunk_id,const Sha1CheckSum& sum) ;
|
||||
virtual bool recvSingleChunkCRCRequest(const RsPeerId& peer_id,const RsFileHash& hash,uint32_t chunk_id) ;
|
||||
virtual bool recvSingleChunkCRC(const RsPeerId& peer_id,const RsFileHash& hash,uint32_t chunk_id,const Sha1CheckSum& sum) ;
|
||||
|
||||
// Returns the chunk map from the file uploading client. Also initiates a chunk map request if this
|
||||
// map is too old. This supposes that the caller will ask again in a few seconds.
|
||||
//
|
||||
bool getClientChunkMap(const std::string& upload_hash,const SSLIdType& peer_id,CompressedChunkMap& map) ;
|
||||
bool getClientChunkMap(const RsFileHash& upload_hash,const RsPeerId& peer_id,CompressedChunkMap& map) ;
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -155,26 +155,25 @@ class ftDataMultiplex: public ftDataRecv, public RsQueueThread
|
|||
private:
|
||||
|
||||
/* Handling Job Queues */
|
||||
bool handleRecvData(const SSLIdType& peerId, const std::string& hash, uint64_t size, uint64_t offset, uint32_t chunksize, void *data);
|
||||
bool handleRecvDataRequest(const SSLIdType& peerId, const std::string& hash, uint64_t size, uint64_t offset, uint32_t chunksize);
|
||||
bool handleSearchRequest(const SSLIdType& peerId, const std::string& hash);
|
||||
bool handleRecvClientChunkMapRequest(const SSLIdType& peerId, const std::string& hash) ;
|
||||
bool handleRecvServerChunkMapRequest(const SSLIdType& peerId, const std::string& hash) ;
|
||||
bool handleRecvChunkCrcRequest(const SSLIdType& peerId, const std::string& hash,uint32_t chunk_id) ;
|
||||
bool handleRecvData(const RsPeerId& peerId, const RsFileHash& hash, uint64_t size, uint64_t offset, uint32_t chunksize, void *data);
|
||||
bool handleRecvDataRequest(const RsPeerId& peerId, const RsFileHash& hash, uint64_t size, uint64_t offset, uint32_t chunksize);
|
||||
bool handleSearchRequest(const RsPeerId& peerId, const RsFileHash& hash);
|
||||
bool handleRecvClientChunkMapRequest(const RsPeerId& peerId, const RsFileHash& hash) ;
|
||||
bool handleRecvServerChunkMapRequest(const RsPeerId& peerId, const RsFileHash& hash) ;
|
||||
bool handleRecvChunkCrcRequest(const RsPeerId& peerId, const RsFileHash& hash,uint32_t chunk_id) ;
|
||||
|
||||
/* We end up doing the actual server job here */
|
||||
bool locked_handleServerRequest(ftFileProvider *provider, const SSLIdType& peerId, const std::string& hash, uint64_t size, uint64_t offset, uint32_t chunksize);
|
||||
bool locked_handleServerRequest(ftFileProvider *provider, const RsPeerId& peerId, const RsFileHash& hash, uint64_t size, uint64_t offset, uint32_t chunksize);
|
||||
|
||||
RsMutex dataMtx;
|
||||
|
||||
std::map<std::string, ftClient> mClients;
|
||||
std::map<std::string, ftFileProvider *> mServers;
|
||||
std::map<RsFileHash, ftClient> mClients;
|
||||
std::map<RsFileHash, ftFileProvider *> mServers;
|
||||
|
||||
std::list<ftRequest> mRequestQueue;
|
||||
std::list<ftRequest> mSearchQueue;
|
||||
// std::map<std::string, time_t> mUnknownHashs;
|
||||
|
||||
std::map<std::string,Sha1CacheEntry> _cached_sha1maps ; // one cache entry per file hash. Handled dynamically.
|
||||
std::map<RsFileHash,Sha1CacheEntry> _cached_sha1maps ; // one cache entry per file hash. Handled dynamically.
|
||||
|
||||
ftDataSend *mDataSend;
|
||||
ftSearch *mSearch;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue