From 0dfe519c70ef2c40c8f63499c521c0885af37cc2 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 5 Sep 2009 21:01:12 +0000 Subject: towards having download --- src/fs/fs_download.c | 3 ++- src/fs/fs_tree.c | 6 +++--- src/fs/fs_tree.h | 10 ++++++++++ 3 files changed, 15 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/fs/fs_download.c b/src/fs/fs_download.c index 323be8805..904244dbb 100644 --- a/src/fs/fs_download.c +++ b/src/fs/fs_download.c @@ -33,6 +33,7 @@ #include "gnunet_constants.h" #include "gnunet_fs_service.h" #include "fs.h" +#include "fs_tree.h" #define DEBUG_DOWNLOAD GNUNET_YES @@ -388,7 +389,7 @@ GNUNET_FS_file_download_start (struct GNUNET_FS_Handle *h, dc->anonymity = anonymity; dc->options = options; dc->active = GNUNET_CONTAINER_multihashmap_create (1 + (length / DBLOCK_SIZE)); - // FIXME: calculate tree depth + dc->treedepth = GNUNET_FS_compute_depth (GNUNET_ntohll(dc->uri->data.chk.file_length)); // FIXME: make persistent schedule_block_download (dc, &dc->uri->data.chk.chk, diff --git a/src/fs/fs_tree.c b/src/fs/fs_tree.c index f5205f082..d151eb086 100644 --- a/src/fs/fs_tree.c +++ b/src/fs/fs_tree.c @@ -121,8 +121,8 @@ struct GNUNET_FS_TreeEncoder * @param flen file length for which to compute the depth * @return depth of the tree */ -static unsigned int -compute_depth (uint64_t flen) +unsigned int +GNUNET_FS_compute_depth (uint64_t flen) { unsigned int treeDepth; uint64_t fl; @@ -179,7 +179,7 @@ GNUNET_FS_tree_encoder_create (struct GNUNET_FS_Handle *h, te->proc = proc; te->progress = progress; te->cont = cont; - te->chk_tree_depth = compute_depth (size); + te->chk_tree_depth = GNUNET_FS_compute_depth (size); te->current_depth = te->chk_tree_depth; te->chk_tree = GNUNET_malloc (te->chk_tree_depth * CHK_PER_INODE * diff --git a/src/fs/fs_tree.h b/src/fs/fs_tree.h index 47d383fb5..4186a4e21 100644 --- a/src/fs/fs_tree.h +++ b/src/fs/fs_tree.h @@ -34,6 +34,16 @@ #include "fs.h" +/** + * Compute the depth of the CHK tree. + * + * @param flen file length for which to compute the depth + * @return depth of the tree + */ +unsigned int +GNUNET_FS_compute_depth (uint64_t flen); + + /** * Context for an ECRS-based file encoder that computes * the Merkle-ish-CHK tree. -- cgit v1.2.3