mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-31 18:36:24 -05:00
added proper dynamic suppression of sources from chunkmap, and updated the gui
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2498 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
1c2683f613
commit
5f7486f160
@ -402,6 +402,16 @@ void ChunkMap::getChunksInfo(FileChunksInfo& info) const
|
|||||||
info.compressed_peer_availability_maps[it->first] = it->second.cmap ;
|
info.compressed_peer_availability_maps[it->first] = it->second.cmap ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChunkMap::removeFileSource(const std::string& peer_id)
|
||||||
|
{
|
||||||
|
std::map<std::string,SourceChunksInfo>::iterator it(_peers_chunks_availability.find(peer_id)) ;
|
||||||
|
|
||||||
|
if(it == _peers_chunks_availability.end())
|
||||||
|
return ;
|
||||||
|
|
||||||
|
_peers_chunks_availability.erase(it) ;
|
||||||
|
}
|
||||||
|
|
||||||
void ChunkMap::getAvailabilityMap(CompressedChunkMap& compressed_map) const
|
void ChunkMap::getAvailabilityMap(CompressedChunkMap& compressed_map) const
|
||||||
{
|
{
|
||||||
compressed_map = CompressedChunkMap(_map) ;
|
compressed_map = CompressedChunkMap(_map) ;
|
||||||
|
@ -135,6 +135,9 @@ class ChunkMap
|
|||||||
virtual void getAvailabilityMap(CompressedChunkMap& cmap) const ;
|
virtual void getAvailabilityMap(CompressedChunkMap& cmap) const ;
|
||||||
void setAvailabilityMap(const CompressedChunkMap& cmap) ;
|
void setAvailabilityMap(const CompressedChunkMap& cmap) ;
|
||||||
|
|
||||||
|
/// Removes the source availability map. The map
|
||||||
|
void removeFileSource(const std::string& peer_id) ;
|
||||||
|
|
||||||
/// This function fills in a plain map for a file of the given size. This
|
/// This function fills in a plain map for a file of the given size. This
|
||||||
/// is used to ensure that the chunk size will be consistent with the rest
|
/// is used to ensure that the chunk size will be consistent with the rest
|
||||||
/// of the code.
|
/// of the code.
|
||||||
|
@ -181,6 +181,7 @@ void ftController::removeFileSource(const std::string& hash,const std::string& p
|
|||||||
if(it->first == hash)
|
if(it->first == hash)
|
||||||
{
|
{
|
||||||
it->second->mTransfer->removeFileSource(peer_id);
|
it->second->mTransfer->removeFileSource(peer_id);
|
||||||
|
it->second->mCreator->removeFileSource(peer_id);
|
||||||
|
|
||||||
// setPeerState(it->second.mTransfer, peer_id, rate, mConnMgr->isOnline(peer_id));
|
// setPeerState(it->second.mTransfer, peer_id, rate, mConnMgr->isOnline(peer_id));
|
||||||
|
|
||||||
|
@ -177,6 +177,15 @@ void ftFileCreator::removeInactiveChunks()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ftFileCreator::removeFileSource(const std::string& peer_id)
|
||||||
|
{
|
||||||
|
RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/
|
||||||
|
#ifdef FILE_DEBUG
|
||||||
|
std::cerr << "ftFileCreator:: removign file source " << peer_id << " from chunkmap." << std::endl ;
|
||||||
|
#endif
|
||||||
|
chunkMap.removeFileSource(peer_id) ;
|
||||||
|
}
|
||||||
|
|
||||||
int ftFileCreator::initializeFileAttrs()
|
int ftFileCreator::initializeFileAttrs()
|
||||||
{
|
{
|
||||||
#ifdef FILE_DEBUG
|
#ifdef FILE_DEBUG
|
||||||
|
@ -73,6 +73,9 @@ class ftFileCreator: public ftFileProvider
|
|||||||
//
|
//
|
||||||
void removeInactiveChunks() ;
|
void removeInactiveChunks() ;
|
||||||
|
|
||||||
|
// removes the designated file source from the chunkmap.
|
||||||
|
void removeFileSource(const std::string& peer_id) ;
|
||||||
|
|
||||||
// Returns the time stamp of the last data receive.
|
// Returns the time stamp of the last data receive.
|
||||||
time_t lastRecvTimeStamp() ;
|
time_t lastRecvTimeStamp() ;
|
||||||
|
|
||||||
|
@ -217,28 +217,28 @@ void ftFileProvider::getClientMap(const std::string& peer_id,CompressedChunkMap&
|
|||||||
|
|
||||||
int ftFileProvider::initializeFileAttrs()
|
int ftFileProvider::initializeFileAttrs()
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_FT_FILE_PROVIDER
|
#ifdef DEBUG_FT_FILE_PROVIDER
|
||||||
std::cerr << "ftFileProvider::initializeFileAttrs() Filename: " << file_name << std::endl;
|
std::cerr << "ftFileProvider::initializeFileAttrs() Filename: " << file_name << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/
|
||||||
if (fd)
|
if (fd)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* check if the file exists
|
* check if the file exists
|
||||||
*/
|
*/
|
||||||
|
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_FT_FILE_PROVIDER
|
#ifdef DEBUG_FT_FILE_PROVIDER
|
||||||
std::cerr << "ftFileProvider::initializeFileAttrs() trying (r+b) " << std::endl;
|
std::cerr << "ftFileProvider::initializeFileAttrs() trying (r+b) " << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* attempt to open file
|
* attempt to open file
|
||||||
*/
|
*/
|
||||||
|
|
||||||
fd = fopen64(file_name.c_str(), "rb");
|
fd = fopen64(file_name.c_str(), "rb");
|
||||||
if (!fd)
|
if (!fd)
|
||||||
{
|
{
|
||||||
@ -251,28 +251,28 @@ int ftFileProvider::initializeFileAttrs()
|
|||||||
{
|
{
|
||||||
std::cerr << "ftFileProvider::initializeFileAttrs() Failed to open (rb): ";
|
std::cerr << "ftFileProvider::initializeFileAttrs() Failed to open (rb): ";
|
||||||
std::cerr << file_name << std::endl;
|
std::cerr << file_name << std::endl;
|
||||||
|
|
||||||
/* try opening read only */
|
/* try opening read only */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* if it opened, find it's length
|
* if it opened, find it's length
|
||||||
* move to the end
|
* move to the end
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (0 != fseeko64(fd, 0L, SEEK_END))
|
|
||||||
{
|
|
||||||
std::cerr << "ftFileProvider::initializeFileAttrs() Seek Failed" << std::endl;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t recvdsize = ftello64(fd);
|
// if (0 != fseeko64(fd, 0L, SEEK_END))
|
||||||
|
// {
|
||||||
|
// std::cerr << "ftFileProvider::initializeFileAttrs() Seek Failed" << std::endl;
|
||||||
|
// return 0;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// uint64_t recvdsize = ftello64(fd);
|
||||||
|
//
|
||||||
|
//#ifdef DEBUG_FT_FILE_PROVIDER
|
||||||
|
// std::cerr << "ftFileProvider::initializeFileAttrs() File Expected Size: " << mSize << " RecvdSize: " << recvdsize << std::endl;
|
||||||
|
//#endif
|
||||||
|
|
||||||
#ifdef DEBUG_FT_FILE_PROVIDER
|
|
||||||
std::cerr << "ftFileProvider::initializeFileAttrs() File Expected Size: " << mSize << " RecvdSize: " << recvdsize << std::endl;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -247,9 +247,9 @@ void p3turtle::autoWash()
|
|||||||
|
|
||||||
if(it == _incoming_file_hashes.end())
|
if(it == _incoming_file_hashes.end())
|
||||||
{
|
{
|
||||||
#ifdef P3TURTLE_DEBUG
|
#ifdef P3TURTLE_DEBUG
|
||||||
std::cerr << "p3turtle: asked to stop monitoring file hash " << _hashes_to_remove[i] << ", but this hash is actually not handled by the turtle router." << std::endl ;
|
std::cerr << "p3turtle: asked to stop monitoring file hash " << _hashes_to_remove[i] << ", but this hash is actually not handled by the turtle router." << std::endl ;
|
||||||
#endif
|
#endif
|
||||||
continue ;
|
continue ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,7 +187,7 @@ void FileTransferInfoWidget::draw(const FileInfo& nfo,const FileChunksInfo& info
|
|||||||
y += block_sep ;
|
y += block_sep ;
|
||||||
y += text_height ;
|
y += text_height ;
|
||||||
painter->setPen(QColor::fromRgb(0,0,0)) ;
|
painter->setPen(QColor::fromRgb(0,0,0)) ;
|
||||||
painter->drawText(0,y,tr("Availability map (")+QString::number(info.compressed_peer_availability_maps.size())+ tr(" sources")+")") ;
|
painter->drawText(0,y,tr("Availability map (")+QString::number(info.compressed_peer_availability_maps.size())+ tr(" active sources")+")") ;
|
||||||
y += block_sep ;
|
y += block_sep ;
|
||||||
|
|
||||||
// Note (for non geeks): the !! operator transforms anything positive into 1 and 0 into 0.
|
// Note (for non geeks): the !! operator transforms anything positive into 1 and 0 into 0.
|
||||||
|
Loading…
Reference in New Issue
Block a user