From 426fc06938549f4f3bc3f10e65efc2ec7722a8bb Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 19 Nov 2009 08:35:11 +0000 Subject: [PATCH] forgot to add these two files git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1839 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/ft/ftchunkmap.cc | 34 ++++++++++++++++++++++++++++++ libretroshare/src/ft/ftchunkmap.h | 13 ++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 libretroshare/src/ft/ftchunkmap.cc create mode 100644 libretroshare/src/ft/ftchunkmap.h diff --git a/libretroshare/src/ft/ftchunkmap.cc b/libretroshare/src/ft/ftchunkmap.cc new file mode 100644 index 000000000..cc8dda5c2 --- /dev/null +++ b/libretroshare/src/ft/ftchunkmap.cc @@ -0,0 +1,34 @@ +#include +#include "ftchunkmap.h" + +ChunkMap::ChunkMap(uint64_t s) +{ + file_size = s ; + + chunk_size = 1024*1024 ; // 1MB chunks + uint64_t n = s/chunk_size ; + if(s% (uint64_t)chunk_size != 0) + ++n ; + + chunks.resize(n,CHUNK_OUTSTANDING) ; +} + +void ChunkMap::received(uint64_t offset) +{ + uint64_t n = offset/chunk_size ; + + for(uint64_t i=0;i + +class ChunkMap: public FileChunksInfo +{ + public: + ChunkMap(uint64_t size) ; + + virtual void received(uint64_t offset) ; + virtual void requested(uint64_t offset, uint32_t chunk_size) ; +}; +