fixing 1584
[oweals/gnunet.git] / src / fs / fs_tree.h
index 4186a4e21ef2fb1ba1167a05fafb25931b9816e5..2cc627899e51fb1366bd4a0204f724f16c789304 100644 (file)
@@ -4,7 +4,7 @@
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
-     by the Free Software Foundation; either version 2, or (at your
+     by the Free Software Foundation; either version 3, or (at your
      option) any later version.
 
      GNUnet is distributed in the hope that it will be useful, but
@@ -67,7 +67,7 @@ struct GNUNET_FS_TreeEncoder;
 typedef void (*GNUNET_FS_TreeBlockProcessor)(void *cls,
                                             const GNUNET_HashCode *query,
                                             uint64_t offset,
-                                            unsigned int type,
+                                            enum GNUNET_BLOCK_Type type,
                                             const void *block,
                                             uint16_t block_size);
                                             
@@ -144,6 +144,36 @@ void GNUNET_FS_tree_encoder_finish (struct GNUNET_FS_TreeEncoder * te,
                                    char **emsg);
 
 
+/**
+ * Compute the size of the current IBlock.
+ *
+ * @param height height of the IBlock in the tree (aka overall
+ *               number of tree levels minus depth); 0 == DBlock
+ * @param offset current offset in the overall file
+ * @return size of the corresponding IBlock
+ */
+uint16_t 
+GNUNET_FS_tree_compute_iblock_size (unsigned int height,
+                                   uint64_t offset);
+
+
+/**
+ * Compute how many bytes of data should be stored in
+ * the specified node.
+ *
+ * @param fsize overall file size
+ * @param totaldepth depth of the entire tree
+ * @param offset offset of the node
+ * @param depth depth of the node
+ * @return number of bytes stored in this node
+ */
+size_t
+GNUNET_FS_tree_calculate_block_size (uint64_t fsize,
+                                    unsigned int totaldepth,
+                                    uint64_t offset,
+                                    unsigned int depth);
+
+
 #if 0
 /* the functions below will be needed for persistence
    but are not yet implemented -- FIXME... */