diff --git a/src/ft/ftserver.cc b/src/ft/ftserver.cc index 74cc00847..ef6e4ef9e 100644 --- a/src/ft/ftserver.cc +++ b/src/ft/ftserver.cc @@ -1317,6 +1317,15 @@ bool ftServer::sendData(const RsPeerId& peerId, const RsFileHash& hash, uint64_t offset += chunk; tosend -= chunk; } + std::map::iterator it = cumulative_uploaded.find(hash) ; + if(it != cumulative_uploaded.end()) + { + it->second += chunksize; + } + else + { + cumulative_uploaded.insert(std::make_pair(hash,(uint64_t)chunksize)) ; + } /* clean up data */ free(data); @@ -2370,3 +2379,26 @@ std::error_condition ftServer::parseFilesLink( if(tft) collection = *tft; return ec; } + +uint64_t ftServer::getCumulativeUpload(RsFileHash hash) +{ + RS_STACK_MUTEX(srvMutex); + std::map::iterator it = cumulative_uploaded.find(hash) ; + if(it != cumulative_uploaded.end()) + return it->second; + return 0; +} + +uint64_t ftServer::getCumulativeUploadAll() +{ + RS_STACK_MUTEX(srvMutex); + uint64_t all = 0; + for(std::map::iterator it(cumulative_uploaded.begin()); it!=cumulative_uploaded.end(); ++it) + all += it->second; + return all; +} + +uint64_t ftServer::getCumulativeUploadNum() +{ + return cumulative_uploaded.size(); +} diff --git a/src/ft/ftserver.h b/src/ft/ftserver.h index 02bae7477..8efdfe9d5 100644 --- a/src/ft/ftserver.h +++ b/src/ft/ftserver.h @@ -364,6 +364,10 @@ class ftServer : bool encryptItem(RsTurtleGenericTunnelItem *clear_item,const RsFileHash& hash,RsTurtleGenericDataItem *& encrypted_item); bool decryptItem(const RsTurtleGenericDataItem *encrypted_item, const RsFileHash& hash, RsTurtleGenericTunnelItem *&decrypted_item); + virtual uint64_t getCumulativeUpload(RsFileHash hash); + virtual uint64_t getCumulativeUploadAll(); + virtual uint64_t getCumulativeUploadNum(); + /*************** Internal Transfer Fns *************************/ virtual int tick(); @@ -422,6 +426,8 @@ class ftServer : std::map mEncryptedPeerIds ; // This map holds the hash to be used with each peer id std::map > mUploadLimitMap ; + std::map cumulative_uploaded; + /** Store search callbacks with timeout*/ RS_DEPRECATED std::map< diff --git a/src/retroshare/rsfiles.h b/src/retroshare/rsfiles.h index 3c7ec8052..a56f38b9d 100644 --- a/src/retroshare/rsfiles.h +++ b/src/retroshare/rsfiles.h @@ -180,14 +180,14 @@ const TransferRequestFlags RS_FILE_REQ_NO_SEARCH ( 0x02000000 ); // di // | RS_FILE_HINTS_NETWORK_WIDE_GROUPS | RS_FILE_HINTS_BROWSABLE_GROUPS ; enum class RsSharedDirectoriesEventCode: uint8_t { - UNKNOWN = 0x00, - STARTING_DIRECTORY_SWEEP = 0x01, // (void) - HASHING_FILE = 0x02, // mMessage: full path and hashing speed of the file being hashed - DIRECTORY_SWEEP_ENDED = 0x03, // (void) - SAVING_FILE_INDEX = 0x04, // (void) - EXTRA_LIST_FILE_ADDED = 0x05, // (void) - EXTRA_LIST_FILE_REMOVED = 0x06, // (void) - SHARED_DIRS_LIST_CHANGED = 0x07, // (void) + UNKNOWN = 0x00, + STARTING_DIRECTORY_SWEEP = 0x01, // (void) + HASHING_FILE = 0x02, // mMessage: full path and hashing speed of the file being hashed + DIRECTORY_SWEEP_ENDED = 0x03, // (void) + SAVING_FILE_INDEX = 0x04, // (void) + EXTRA_LIST_FILE_ADDED = 0x05, // (void) + EXTRA_LIST_FILE_REMOVED = 0x06, // (void) + SHARED_DIRS_LIST_CHANGED = 0x07, // (void) }; enum class RsFileTransferEventCode: uint8_t { @@ -1217,5 +1217,9 @@ class RsFiles virtual bool ignoreDuplicates() = 0; virtual void setIgnoreDuplicates(bool ignore) = 0; + virtual uint64_t getCumulativeUpload(RsFileHash hash) = 0; + virtual uint64_t getCumulativeUploadAll() = 0; + virtual uint64_t getCumulativeUploadNum() = 0; + virtual ~RsFiles() = default; };