mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-17 18:40:49 -04:00
Added deferred check of chunks during file transfer. Chunk sha1 sums are requested to the sources and checked for downloaded data.
Validated chunks are shared to other peers. Force check is now very simple since it just turns all chunks into "needs checking" mode and sums are asked to sources. Sources maintain a temporary cache of chunks. Since sums are requested sparsely, this should not affect the sources in terms of performance. We can still imagine precomputing and saving sha1 of chunks while hashing them. For backward compatibility reasons, the following has been setup *temporarily* in this version: - unvalidated chunks are still considered as already obtained, and are shared and saved - force check has been disabled - final file check is maintained - in case of file fail, the old checking mode will be used. All changes for next version are kept in the define 'USE_NEW_CHUNK_CHECKING_CODE' that will be made the default in a few weeks. At start, I expect most chunk to stya yellow during download, until most sources are able to provide chunk hashs. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5019 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
7ab5b54266
commit
889a2b2433
31 changed files with 1540 additions and 35 deletions
|
@ -178,8 +178,22 @@ class ChunkMap
|
|||
/// returns true is the file is complete
|
||||
bool isComplete() const { return _file_is_complete ; }
|
||||
|
||||
/// returns info about currently downloaded chunks
|
||||
void getChunksInfo(FileChunksInfo& info) const ;
|
||||
|
||||
/// input the result of the chunk hash checking
|
||||
void setChunkCheckingResult(uint32_t chunk_number, bool succeed) ;
|
||||
|
||||
/// returns the current list of chunks to ask for a CRC, and a proposed source for each
|
||||
void getChunksToCheck(std::vector<std::pair<unsigned int, std::list<std::string> > >& chunks_to_ask) ;
|
||||
|
||||
/// sets all chunks to checking state
|
||||
void forceCheck() ;
|
||||
|
||||
/// Goes through all structures and computes the actual file completion. The true completion
|
||||
/// gets lost when force checking the file.
|
||||
void updateTotalDownloaded() ;
|
||||
|
||||
protected:
|
||||
/// handles what size the last chunk has.
|
||||
uint32_t sizeOfChunk(uint32_t chunk_number) const ;
|
||||
|
@ -199,6 +213,7 @@ class ChunkMap
|
|||
uint64_t _total_downloaded ; //! completion for the file
|
||||
bool _file_is_complete ; //! set to true when the file is complete.
|
||||
bool _assume_availability ; //! true if all sources always have the complete file.
|
||||
std::vector<uint32_t> _chunks_checking_queue ; //! Queue of downloaded chunks to be checked.
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue