Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/ft/ftserver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1335,6 +1335,15 @@ bool ftServer::sendData(const RsPeerId& peerId, const RsFileHash& hash, uint64_t
offset += chunk;
tosend -= chunk;
}
std::map<RsFileHash,uint64_t>::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);
Expand Down Expand Up @@ -2385,3 +2394,24 @@ std::error_condition ftServer::parseFilesLink(
if(tft) collection = *tft;
return ec;
}

uint64_t ftServer::getCumulativeUpload(RsFileHash hash)
{
std::map<RsFileHash,uint64_t>::iterator it = cumulative_uploaded.find(hash) ;
if(it != cumulative_uploaded.end())
return it->second;
return 0;
}

uint64_t ftServer::getCumulativeUploadAll()
{
uint64_t all = 0;
for(std::map<RsFileHash,uint64_t>::iterator it(cumulative_uploaded.begin()); it!=cumulative_uploaded.end(); ++it)
all += it->second;
return all;
}

uint64_t ftServer::getCumulativeUploadNum()
{
return cumulative_uploaded.size();
}
6 changes: 6 additions & 0 deletions src/ft/ftserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -422,6 +426,8 @@ class ftServer :
std::map<RsPeerId,RsFileHash> mEncryptedPeerIds ; // This map holds the hash to be used with each peer id
std::map<RsPeerId,std::map<RsFileHash,rstime_t> > mUploadLimitMap ;

std::map<RsFileHash,uint64_t> cumulative_uploaded;

/** Store search callbacks with timeout*/
RS_DEPRECATED
std::map<
Expand Down
4 changes: 4 additions & 0 deletions src/retroshare/rsfiles.h
Original file line number Diff line number Diff line change
Expand Up @@ -1113,5 +1113,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;
};