aboutsummaryrefslogtreecommitdiff
path: root/src/datastore/plugin_datastore_heap.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/datastore/plugin_datastore_heap.c')
-rw-r--r--src/datastore/plugin_datastore_heap.c56
1 files changed, 28 insertions, 28 deletions
diff --git a/src/datastore/plugin_datastore_heap.c b/src/datastore/plugin_datastore_heap.c
index 79dcb9043..1f756a95c 100644
--- a/src/datastore/plugin_datastore_heap.c
+++ b/src/datastore/plugin_datastore_heap.c
@@ -33,7 +33,7 @@
33 33
34/** 34/**
35 * A value that we are storing. 35 * A value that we are storing.
36 */ 36 */
37struct Value 37struct Value
38{ 38{
39 39
@@ -67,11 +67,11 @@ struct Value
67 * only used if anonymity is zero. 67 * only used if anonymity is zero.
68 */ 68 */
69 unsigned int zero_anon_offset; 69 unsigned int zero_anon_offset;
70 70
71 /** 71 /**
72 * Number of bytes in 'data'. 72 * Number of bytes in 'data'.
73 */ 73 */
74 uint32_t size; 74 uint32_t size;
75 75
76 /** 76 /**
77 * Priority of the value. 77 * Priority of the value.
@@ -82,7 +82,7 @@ struct Value
82 * Anonymity level for the value. 82 * Anonymity level for the value.
83 */ 83 */
84 uint32_t anonymity; 84 uint32_t anonymity;
85 85
86 /** 86 /**
87 * Replication level for the value. 87 * Replication level for the value.
88 */ 88 */
@@ -209,10 +209,10 @@ heap_plugin_estimate_size (void *cls)
209 * @return GNUNET_OK on success 209 * @return GNUNET_OK on success
210 */ 210 */
211static int 211static int
212heap_plugin_put (void *cls, 212heap_plugin_put (void *cls,
213 const struct GNUNET_HashCode * key, 213 const struct GNUNET_HashCode * key,
214 uint32_t size, 214 uint32_t size,
215 const void *data, 215 const void *data,
216 enum GNUNET_BLOCK_Type type, 216 enum GNUNET_BLOCK_Type type,
217 uint32_t priority, uint32_t anonymity, 217 uint32_t priority, uint32_t anonymity,
218 uint32_t replication, 218 uint32_t replication,
@@ -328,7 +328,7 @@ struct GetContext
328 * The plugin. 328 * The plugin.
329 */ 329 */
330 struct Plugin *plugin; 330 struct Plugin *plugin;
331 331
332 /** 332 /**
333 * Requested value hash. 333 * Requested value hash.
334 */ 334 */
@@ -343,7 +343,7 @@ struct GetContext
343 * Function to call with the result. 343 * Function to call with the result.
344 */ 344 */
345 PluginDatumProcessor proc; 345 PluginDatumProcessor proc;
346 346
347 /** 347 /**
348 * Closure for 'proc'. 348 * Closure for 'proc'.
349 */ 349 */
@@ -358,7 +358,7 @@ struct GetContext
358 * @param value the value to check against the query 358 * @param value the value to check against the query
359 * @return GNUNET_YES if the value matches 359 * @return GNUNET_YES if the value matches
360 */ 360 */
361static int 361static int
362match (const struct GetContext *gc, 362match (const struct GetContext *gc,
363 struct Value *value) 363 struct Value *value)
364{ 364{
@@ -421,7 +421,7 @@ get_iterator (void *cls,
421 if (0 != gc->offset--) 421 if (0 != gc->offset--)
422 return GNUNET_OK; 422 return GNUNET_OK;
423 if (GNUNET_NO == 423 if (GNUNET_NO ==
424 gc->proc (gc->proc_cls, 424 gc->proc (gc->proc_cls,
425 key, 425 key,
426 value->size, 426 value->size,
427 &value[1], 427 &value[1],
@@ -476,7 +476,7 @@ heap_plugin_get_key (void *cls, uint64_t offset,
476 &gc); 476 &gc);
477 if (0 == gc.offset) 477 if (0 == gc.offset)
478 { 478 {
479 proc (proc_cls, 479 proc (proc_cls,
480 NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); 480 NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0);
481 return; 481 return;
482 } 482 }
@@ -489,11 +489,11 @@ heap_plugin_get_key (void *cls, uint64_t offset,
489 { 489 {
490 GNUNET_CONTAINER_multihashmap_get_multiple (plugin->keyvalue, 490 GNUNET_CONTAINER_multihashmap_get_multiple (plugin->keyvalue,
491 key, 491 key,
492 &count_iterator, 492 &count_iterator,
493 &gc); 493 &gc);
494 if (0 == gc.offset) 494 if (0 == gc.offset)
495 { 495 {
496 proc (proc_cls, 496 proc (proc_cls,
497 NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); 497 NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0);
498 return; 498 return;
499 } 499 }
@@ -518,7 +518,7 @@ heap_plugin_get_key (void *cls, uint64_t offset,
518 * @param proc_cls closure for proc 518 * @param proc_cls closure for proc
519 */ 519 */
520static void 520static void
521heap_plugin_get_replication (void *cls, 521heap_plugin_get_replication (void *cls,
522 PluginDatumProcessor proc, 522 PluginDatumProcessor proc,
523 void *proc_cls) 523 void *proc_cls)
524{ 524{
@@ -528,7 +528,7 @@ heap_plugin_get_replication (void *cls,
528 value = GNUNET_CONTAINER_heap_remove_root (plugin->by_replication); 528 value = GNUNET_CONTAINER_heap_remove_root (plugin->by_replication);
529 if (NULL == value) 529 if (NULL == value)
530 { 530 {
531 proc (proc_cls, 531 proc (proc_cls,
532 NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); 532 NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0);
533 return; 533 return;
534 } 534 }
@@ -537,18 +537,18 @@ heap_plugin_get_replication (void *cls,
537 value->replication--; 537 value->replication--;
538 value->replication_heap = GNUNET_CONTAINER_heap_insert (plugin->by_replication, 538 value->replication_heap = GNUNET_CONTAINER_heap_insert (plugin->by_replication,
539 value, 539 value,
540 value->replication); 540 value->replication);
541 } 541 }
542 else 542 else
543 { 543 {
544 /* need a better way to pick a random item, replication level is always 0 */ 544 /* need a better way to pick a random item, replication level is always 0 */
545 value->replication_heap = GNUNET_CONTAINER_heap_insert (plugin->by_replication, 545 value->replication_heap = GNUNET_CONTAINER_heap_insert (plugin->by_replication,
546 value, 546 value,
547 value->replication); 547 value->replication);
548 value = GNUNET_CONTAINER_heap_walk_get_next (plugin->by_replication); 548 value = GNUNET_CONTAINER_heap_walk_get_next (plugin->by_replication);
549 } 549 }
550 if (GNUNET_NO == 550 if (GNUNET_NO ==
551 proc (proc_cls, 551 proc (proc_cls,
552 &value->key, 552 &value->key,
553 value->size, 553 value->size,
554 &value[1], 554 &value[1],
@@ -579,12 +579,12 @@ heap_plugin_get_expiration (void *cls, PluginDatumProcessor proc,
579 value = GNUNET_CONTAINER_heap_peek (plugin->by_expiration); 579 value = GNUNET_CONTAINER_heap_peek (plugin->by_expiration);
580 if (NULL == value) 580 if (NULL == value)
581 { 581 {
582 proc (proc_cls, 582 proc (proc_cls,
583 NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); 583 NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0);
584 return; 584 return;
585 } 585 }
586 if (GNUNET_NO == 586 if (GNUNET_NO ==
587 proc (proc_cls, 587 proc (proc_cls,
588 &value->key, 588 &value->key,
589 value->size, 589 value->size,
590 &value[1], 590 &value[1],
@@ -618,8 +618,8 @@ heap_plugin_get_expiration (void *cls, PluginDatumProcessor proc,
618 * @return GNUNET_OK on success 618 * @return GNUNET_OK on success
619 */ 619 */
620static int 620static int
621heap_plugin_update (void *cls, 621heap_plugin_update (void *cls,
622 uint64_t uid, 622 uint64_t uid,
623 int delta, 623 int delta,
624 struct GNUNET_TIME_Absolute expire, char **msg) 624 struct GNUNET_TIME_Absolute expire, char **msg)
625{ 625{
@@ -675,10 +675,10 @@ heap_plugin_get_zero_anonymity (void *cls, uint64_t offset,
675 } 675 }
676 if (0 == count) 676 if (0 == count)
677 { 677 {
678 proc (proc_cls, 678 proc (proc_cls,
679 NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); 679 NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0);
680 return; 680 return;
681 } 681 }
682 offset = offset % count; 682 offset = offset % count;
683 for (zabt = plugin->zero_head; NULL != zabt; zabt = zabt->next) 683 for (zabt = plugin->zero_head; NULL != zabt; zabt = zabt->next)
684 { 684 {
@@ -695,7 +695,7 @@ heap_plugin_get_zero_anonymity (void *cls, uint64_t offset,
695 GNUNET_assert (NULL != zabt); 695 GNUNET_assert (NULL != zabt);
696 value = zabt->array[offset]; 696 value = zabt->array[offset];
697 if (GNUNET_NO == 697 if (GNUNET_NO ==
698 proc (proc_cls, 698 proc (proc_cls,
699 &value->key, 699 &value->key,
700 value->size, 700 value->size,
701 &value[1], 701 &value[1],
@@ -749,8 +749,8 @@ return_value (void *cls,
749 void *val) 749 void *val)
750{ 750{
751 struct GetAllContext *gac = cls; 751 struct GetAllContext *gac = cls;
752 752
753 gac->proc (gac->proc_cls, 753 gac->proc (gac->proc_cls,
754 key, 754 key,
755 1); 755 1);
756 return GNUNET_OK; 756 return GNUNET_OK;