- changed Sha1CheckSum from hand-made class to instance of t_GenericIdType<> (should be backward compatible)

- updated ft/, p3msgservice and p3chatservice accordingly
- added a new class for Sha1Sum in t_GeneridIdType<>, and an additional template argument to make ids of identical size 
	incompatible.



git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7082 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2014-02-01 19:10:45 +00:00
parent 10bf083ca3
commit 235280399f
19 changed files with 67 additions and 441 deletions

View file

@ -696,61 +696,5 @@ bool ftFileCreator::verifyChunk(uint32_t chunk_number,const Sha1CheckSum& sum)
return true ;
}
bool ftFileCreator::crossCheckChunkMap(const CRC32Map& ref,uint32_t& bad_chunks,uint32_t& incomplete_chunks)
{
{
RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/
CompressedChunkMap map ;
// Start with a full map.
ChunkMap::buildPlainMap(mSize,map) ;
uint32_t nb_chunks = ref.size() ;
static const uint32_t chunk_size = ChunkMap::CHUNKMAP_FIXED_CHUNK_SIZE ;
std::cerr << "ftFileCreator::crossCheckChunkMap(): comparing chunks..." << std::endl;
if(!locked_initializeFileAttrs() )
return false ;
unsigned char *buff = new unsigned char[chunk_size] ;
incomplete_chunks = 0 ;
bad_chunks = 0 ;
uint32_t len = 0 ;
for(uint32_t i=0;i<nb_chunks;++i)
{
printf(" Chunk %05d/%05d:",i,nb_chunks) ;
if(fseeko64(fd,(uint64_t)i * (uint64_t)chunk_size,SEEK_SET)==0 && (len = fread(buff,1,chunk_size,fd)) > 0)
{
uint32_t crc = RsDirUtil::rs_CRC32(buff,len) ;
printf(" crc: %08x, ref: %08x : ",crc,ref[i]) ;
if(crc != ref[i])
{
printf(" CRC ERROR!!\n") ;
++bad_chunks ;
map.reset(i) ;
}
else
printf(" matched\n") ;
}
else
{
printf(" cannot fseek!\n") ;
++bad_chunks ;
map.reset(i) ;
}
}
delete[] buff ;
chunkMap.setAvailabilityMap(map) ;
}
closeFile() ;
return true ;
}