mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-21 07:20:28 -04:00
Integration of ft into a working system.
* Made ftTransferModule compile. * bugfixes to make ftserver1test work. * New P3Pipe / P3Hub ... * Added Test Notes. * First functions added to ftcontroller * added isOnline to p3ConnectMgr. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@698 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
c4a3792500
commit
eb8dacc798
15 changed files with 647 additions and 143 deletions
|
@ -43,7 +43,7 @@ ftTransferModule::ftTransferModule(ftFileCreator *fc, ftDataMultiplex *dm)
|
|||
|
||||
// Dummy for Testing (should be handled independantly for
|
||||
// each peer.
|
||||
mChunkSize = 10000;
|
||||
//mChunkSize = 10000;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,7 @@ uint32_t ftTransferModule::getDataRate(std::string peerId)
|
|||
if (mit == mOnlinePeers.end())
|
||||
return 0;
|
||||
else
|
||||
return (mit->second).actualRate;
|
||||
return (uint32_t) (mit->second).actualRate;
|
||||
}
|
||||
|
||||
|
||||
|
@ -135,15 +135,15 @@ void ftTransferModule::requestData(std::string peerId, uint64_t offset, uint32_t
|
|||
}
|
||||
|
||||
bool ftTransferModule::getChunk(uint64_t &offset, uint32_t &chunk_size)
|
||||
{
|
||||
return mFileCreator->getMissingChunk(offset, chunk_size);
|
||||
}
|
||||
|
||||
bool ftTransferModule::storeData(uint64_t offset, uint32_t chunk_size,void *data)
|
||||
{
|
||||
mFileCreator -> addFileData(offset, chunk_size, data);
|
||||
return mFileCreator->getMissingChunk(offset, chunk_size);
|
||||
}
|
||||
|
||||
|
||||
bool ftTransferModule::storeData(uint64_t offset, uint32_t chunk_size,void *data)
|
||||
{
|
||||
return mFileCreator -> addFileData(offset, chunk_size, data);
|
||||
}
|
||||
|
||||
void ftTransferModule::queryInactive()
|
||||
{
|
||||
#ifdef FT_DEBUG
|
||||
|
@ -152,9 +152,11 @@ void ftTransferModule::queryInactive()
|
|||
out<<std:endl;
|
||||
#endif
|
||||
|
||||
int ts = time(NULL);
|
||||
int offset,size,delta;
|
||||
|
||||
int ts = time(NULL);
|
||||
uint64_t offset;
|
||||
uint32_t size;
|
||||
int delta;
|
||||
|
||||
std::map<std::string,peerInfo>::iterator mit;
|
||||
for(mit = mOnlinePeers.begin(); mit != mOnlinePeers.end(); mit++)
|
||||
{
|
||||
|
@ -180,26 +182,26 @@ void ftTransferModule::queryInactive()
|
|||
//file request has been sent to peer side, but no response received yet
|
||||
case PQIPEER_DOWNLOADING:
|
||||
if (ts - ((mit->second).lastTS) > PQIPEER_DOWNLOAD_CHECK)
|
||||
requestData(mit->first, (mit->second).offset,(mit->second).size); //give a push
|
||||
requestData(mit->first, (mit->second).offset,(mit->second).chunkSize); //give a push
|
||||
|
||||
actualRate += (mit->second).actualRate;
|
||||
break;
|
||||
|
||||
//file response has been received or peer side is just ready for download
|
||||
case PQIPEER_IDLE:
|
||||
(mit->second).actualRate = (mit->second).size/(ts-(mit-second).lastTS);
|
||||
if ((mit->second).actualRate < (mit->second).desireRate)
|
||||
(mit->second).actualRate = (mit->second).chunkSize/(ts-(mit->second).lastTS);
|
||||
if ((mit->second).actualRate < (mit->second).desiredRate)
|
||||
{
|
||||
size = (mit->second).size *2 ;
|
||||
size = (mit->second).chunkSize * 2 ;
|
||||
}
|
||||
else
|
||||
{
|
||||
size = (mit->second).size * 0.9 ;
|
||||
size = (uint32_t ) ((mit->second).chunkSize * 0.9) ;
|
||||
}
|
||||
if (getChunk(offset,size))
|
||||
{
|
||||
(mit->second).offset = offset;
|
||||
(mit->second).size = size;
|
||||
(mit->second).chunkSize = size;
|
||||
(mit->second).lastTS = ts;
|
||||
(mit->second).state = PQIPEER_DOWNLOADING;
|
||||
requestData(mit->first,offset,size);
|
||||
|
@ -242,10 +244,11 @@ bool ftTransferModule::resumeTransfer()
|
|||
return 1;
|
||||
}
|
||||
|
||||
bool ftTransferModule::completeFileTransfer()
|
||||
{
|
||||
}
|
||||
|
||||
bool ftTransferModule::completeFileTransfer()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
int ftTransferModule::tick()
|
||||
{
|
||||
queryInactive();
|
||||
|
@ -265,12 +268,12 @@ void ftTransferModule::adjustSpeed()
|
|||
if (((mit->second).state == PQIPEER_DOWNLOADING)
|
||||
|| ((mit->second).state == PQIPEER_IDLE))
|
||||
{
|
||||
if (actualRate < desiredRate) && ((mit->second).actualRate >= (mit->second).desiredRate)
|
||||
if ((actualRate < desiredRate) && ((mit->second).actualRate >= (mit->second).desiredRate))
|
||||
{
|
||||
(mit->second).desiredRate *= 1.1;
|
||||
}
|
||||
|
||||
if (actualRate > desiredRate) && ((mit->second).actualRate < (mit->second).desiredRate)
|
||||
if ((actualRate > desiredRate) && ((mit->second).actualRate < (mit->second).desiredRate))
|
||||
{
|
||||
(mit->second).desiredRate *= 0.9;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue