/**
* A value that we are storing.
- */
+ */
struct Value
{
* only used if anonymity is zero.
*/
unsigned int zero_anon_offset;
-
+
/**
* Number of bytes in 'data'.
*/
- uint32_t size;
+ uint32_t size;
/**
* Priority of the value.
* Anonymity level for the value.
*/
uint32_t anonymity;
-
+
/**
* Replication level for the value.
*/
* @return GNUNET_OK on success
*/
static int
-heap_plugin_put (void *cls,
- const struct GNUNET_HashCode * key,
+heap_plugin_put (void *cls,
+ const struct GNUNET_HashCode * key,
uint32_t size,
- const void *data,
+ const void *data,
enum GNUNET_BLOCK_Type type,
uint32_t priority, uint32_t anonymity,
uint32_t replication,
* The plugin.
*/
struct Plugin *plugin;
-
+
/**
* Requested value hash.
*/
* Function to call with the result.
*/
PluginDatumProcessor proc;
-
+
/**
* Closure for 'proc'.
*/
* @param value the value to check against the query
* @return GNUNET_YES if the value matches
*/
-static int
+static int
match (const struct GetContext *gc,
struct Value *value)
{
if (0 != gc->offset--)
return GNUNET_OK;
if (GNUNET_NO ==
- gc->proc (gc->proc_cls,
+ gc->proc (gc->proc_cls,
key,
value->size,
&value[1],
&gc);
if (0 == gc.offset)
{
- proc (proc_cls,
+ proc (proc_cls,
NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0);
return;
}
{
GNUNET_CONTAINER_multihashmap_get_multiple (plugin->keyvalue,
key,
- &count_iterator,
+ &count_iterator,
&gc);
if (0 == gc.offset)
{
- proc (proc_cls,
+ proc (proc_cls,
NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0);
return;
}
* @param proc_cls closure for proc
*/
static void
-heap_plugin_get_replication (void *cls,
+heap_plugin_get_replication (void *cls,
PluginDatumProcessor proc,
void *proc_cls)
{
value = GNUNET_CONTAINER_heap_remove_root (plugin->by_replication);
if (NULL == value)
{
- proc (proc_cls,
+ proc (proc_cls,
NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0);
return;
}
value->replication--;
value->replication_heap = GNUNET_CONTAINER_heap_insert (plugin->by_replication,
value,
- value->replication);
+ value->replication);
}
else
{
/* need a better way to pick a random item, replication level is always 0 */
value->replication_heap = GNUNET_CONTAINER_heap_insert (plugin->by_replication,
value,
- value->replication);
+ value->replication);
value = GNUNET_CONTAINER_heap_walk_get_next (plugin->by_replication);
}
if (GNUNET_NO ==
- proc (proc_cls,
+ proc (proc_cls,
&value->key,
value->size,
&value[1],
value = GNUNET_CONTAINER_heap_peek (plugin->by_expiration);
if (NULL == value)
{
- proc (proc_cls,
+ proc (proc_cls,
NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0);
return;
}
if (GNUNET_NO ==
- proc (proc_cls,
+ proc (proc_cls,
&value->key,
value->size,
&value[1],
* @return GNUNET_OK on success
*/
static int
-heap_plugin_update (void *cls,
- uint64_t uid,
+heap_plugin_update (void *cls,
+ uint64_t uid,
int delta,
struct GNUNET_TIME_Absolute expire, char **msg)
{
}
if (0 == count)
{
- proc (proc_cls,
+ proc (proc_cls,
NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0);
return;
- }
+ }
offset = offset % count;
for (zabt = plugin->zero_head; NULL != zabt; zabt = zabt->next)
{
GNUNET_assert (NULL != zabt);
value = zabt->array[offset];
if (GNUNET_NO ==
- proc (proc_cls,
+ proc (proc_cls,
&value->key,
value->size,
&value[1],
void *val)
{
struct GetAllContext *gac = cls;
-
- gac->proc (gac->proc_cls,
+
+ gac->proc (gac->proc_cls,
key,
1);
return GNUNET_OK;