towards having download
authorChristian Grothoff <christian@grothoff.org>
Sat, 5 Sep 2009 21:01:12 +0000 (21:01 +0000)
committerChristian Grothoff <christian@grothoff.org>
Sat, 5 Sep 2009 21:01:12 +0000 (21:01 +0000)
src/fs/fs_download.c
src/fs/fs_tree.c
src/fs/fs_tree.h

index 323be8805703f3749a61b91a94e9fa3a396dc1bb..904244dbb15594aca2badf92a3362306539c0508 100644 (file)
@@ -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,
index f5205f082e3c5c18b6461eb5e49f8d6875fca974..d151eb086aa68e710e72e359df489f502c1fff4c 100644 (file)
@@ -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 *
index 47d383fb52dbd58ec760d21a59ebfa43e22c2e56..4186a4e21ef2fb1ba1167a05fafb25931b9816e5 100644 (file)
 
 #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.