aboutsummaryrefslogtreecommitdiff
path: root/src/fs/fs_tree.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-08-15 21:54:06 +0000
committerChristian Grothoff <christian@grothoff.org>2011-08-15 21:54:06 +0000
commit5746309cb4be2073d550ad7a6885e918631dbc38 (patch)
tree89455bc4aadf977816b38df13f990372cd81d71a /src/fs/fs_tree.c
parent6fd3e715cae09fa6e657c96f1c6f9711ee51f42f (diff)
downloadgnunet-5746309cb4be2073d550ad7a6885e918631dbc38.tar.gz
gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.zip
indentation
Diffstat (limited to 'src/fs/fs_tree.c')
-rw-r--r--src/fs/fs_tree.c46
1 files changed, 21 insertions, 25 deletions
diff --git a/src/fs/fs_tree.c b/src/fs/fs_tree.c
index 5584ad868..0a0db7a10 100644
--- a/src/fs/fs_tree.c
+++ b/src/fs/fs_tree.c
@@ -221,8 +221,8 @@ GNUNET_FS_tree_compute_iblock_size (unsigned int depth, uint64_t end_offset)
221 * @return number of bytes stored in this node 221 * @return number of bytes stored in this node
222 */ 222 */
223size_t 223size_t
224GNUNET_FS_tree_calculate_block_size (uint64_t fsize, 224GNUNET_FS_tree_calculate_block_size (uint64_t fsize, uint64_t offset,
225 uint64_t offset, unsigned int depth) 225 unsigned int depth)
226{ 226{
227 size_t ret; 227 size_t ret;
228 uint64_t rsize; 228 uint64_t rsize;
@@ -268,10 +268,8 @@ GNUNET_FS_tree_calculate_block_size (uint64_t fsize,
268 * @param cont function to call when done 268 * @param cont function to call when done
269 */ 269 */
270struct GNUNET_FS_TreeEncoder * 270struct GNUNET_FS_TreeEncoder *
271GNUNET_FS_tree_encoder_create (struct GNUNET_FS_Handle *h, 271GNUNET_FS_tree_encoder_create (struct GNUNET_FS_Handle *h, uint64_t size,
272 uint64_t size, 272 void *cls, GNUNET_FS_DataReader reader,
273 void *cls,
274 GNUNET_FS_DataReader reader,
275 GNUNET_FS_TreeBlockProcessor proc, 273 GNUNET_FS_TreeBlockProcessor proc,
276 GNUNET_FS_TreeProgressCallback progress, 274 GNUNET_FS_TreeProgressCallback progress,
277 GNUNET_SCHEDULER_Task cont) 275 GNUNET_SCHEDULER_Task cont)
@@ -287,8 +285,9 @@ GNUNET_FS_tree_encoder_create (struct GNUNET_FS_Handle *h,
287 te->progress = progress; 285 te->progress = progress;
288 te->cont = cont; 286 te->cont = cont;
289 te->chk_tree_depth = GNUNET_FS_compute_depth (size); 287 te->chk_tree_depth = GNUNET_FS_compute_depth (size);
290 te->chk_tree = GNUNET_malloc (te->chk_tree_depth * 288 te->chk_tree =
291 CHK_PER_INODE * sizeof (struct ContentHashKey)); 289 GNUNET_malloc (te->chk_tree_depth * CHK_PER_INODE *
290 sizeof (struct ContentHashKey));
292 return te; 291 return te;
293} 292}
294 293
@@ -343,8 +342,7 @@ GNUNET_FS_tree_encoder_next (struct GNUNET_FS_TreeEncoder *te)
343 { 342 {
344 off = CHK_PER_INODE * (te->chk_tree_depth - 1); 343 off = CHK_PER_INODE * (te->chk_tree_depth - 1);
345#if DEBUG_TREE 344#if DEBUG_TREE
346 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 345 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "TE done, reading CHK `%s' from %u\n",
347 "TE done, reading CHK `%s' from %u\n",
348 GNUNET_h2s (&te->chk_tree[off].query), off); 346 GNUNET_h2s (&te->chk_tree[off].query), off);
349#endif 347#endif
350 te->uri = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri)); 348 te->uri = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri));
@@ -362,8 +360,7 @@ GNUNET_FS_tree_encoder_next (struct GNUNET_FS_TreeEncoder *te)
362 if (pt_size != 360 if (pt_size !=
363 te->reader (te->cls, te->publish_offset, pt_size, iob, &te->emsg)) 361 te->reader (te->cls, te->publish_offset, pt_size, iob, &te->emsg))
364 { 362 {
365 GNUNET_SCHEDULER_add_continuation (te->cont, 363 GNUNET_SCHEDULER_add_continuation (te->cont, te->cls,
366 te->cls,
367 GNUNET_SCHEDULER_REASON_TIMEOUT); 364 GNUNET_SCHEDULER_REASON_TIMEOUT);
368 te->in_next = GNUNET_NO; 365 te->in_next = GNUNET_NO;
369 return; 366 return;
@@ -372,16 +369,17 @@ GNUNET_FS_tree_encoder_next (struct GNUNET_FS_TreeEncoder *te)
372 } 369 }
373 else 370 else
374 { 371 {
375 pt_size = GNUNET_FS_tree_compute_iblock_size (te->current_depth, 372 pt_size =
376 te->publish_offset); 373 GNUNET_FS_tree_compute_iblock_size (te->current_depth,
374 te->publish_offset);
377 pt_block = &te->chk_tree[(te->current_depth - 1) * CHK_PER_INODE]; 375 pt_block = &te->chk_tree[(te->current_depth - 1) * CHK_PER_INODE];
378 } 376 }
379 off = compute_chk_offset (te->current_depth, te->publish_offset); 377 off = compute_chk_offset (te->current_depth, te->publish_offset);
380#if DEBUG_TREE 378#if DEBUG_TREE
381 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 379 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
382 "TE is at offset %llu and depth %u with block size %u and target-CHK-offset %u\n", 380 "TE is at offset %llu and depth %u with block size %u and target-CHK-offset %u\n",
383 (unsigned long long) te->publish_offset, 381 (unsigned long long) te->publish_offset, te->current_depth,
384 te->current_depth, (unsigned int) pt_size, (unsigned int) off); 382 (unsigned int) pt_size, (unsigned int) off);
385#endif 383#endif
386 mychk = &te->chk_tree[te->current_depth * CHK_PER_INODE + off]; 384 mychk = &te->chk_tree[te->current_depth * CHK_PER_INODE + off];
387 GNUNET_CRYPTO_hash (pt_block, pt_size, &mychk->key); 385 GNUNET_CRYPTO_hash (pt_block, pt_size, &mychk->key);
@@ -395,16 +393,14 @@ GNUNET_FS_tree_encoder_next (struct GNUNET_FS_TreeEncoder *te)
395 te->current_depth * CHK_PER_INODE + off); 393 te->current_depth * CHK_PER_INODE + off);
396#endif 394#endif
397 if (NULL != te->proc) 395 if (NULL != te->proc)
398 te->proc (te->cls, 396 te->proc (te->cls, mychk, te->publish_offset, te->current_depth,
399 mychk, 397 (0 ==
400 te->publish_offset, 398 te->
401 te->current_depth, 399 current_depth) ? GNUNET_BLOCK_TYPE_FS_DBLOCK :
402 (0 == te->current_depth) 400 GNUNET_BLOCK_TYPE_FS_IBLOCK, enc, pt_size);
403 ? GNUNET_BLOCK_TYPE_FS_DBLOCK
404 : GNUNET_BLOCK_TYPE_FS_IBLOCK, enc, pt_size);
405 if (NULL != te->progress) 401 if (NULL != te->progress)
406 te->progress (te->cls, 402 te->progress (te->cls, te->publish_offset, pt_block, pt_size,
407 te->publish_offset, pt_block, pt_size, te->current_depth); 403 te->current_depth);
408 if (0 == te->current_depth) 404 if (0 == te->current_depth)
409 { 405 {
410 te->publish_offset += pt_size; 406 te->publish_offset += pt_size;