ntohl(dm->type),
ntohl(dm->priority),
ntohl(dm->anonymity),
+ 0 /* FIXME: replication */,
GNUNET_TIME_absolute_ntoh(dm->expiration),
&msg);
if (GNUNET_OK == ret)
&key,
size,
value,
- i,
+ i /* type */,
prio,
- i,
+ i /* anonymity */,
+ 0 /* replication */,
GNUNET_TIME_relative_to_absolute
(GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS,
60 * 60 * 60 * 1000 +
* @param type type of the content
* @param priority priority of the content
* @param anonymity anonymity-level for the content
+ * @param replication replication-level for the content
* @param expiration expiration time for the content
* @param msg set to error message
* @return GNUNET_OK on success
enum GNUNET_BLOCK_Type type,
uint32_t priority,
uint32_t anonymity,
+ uint32_t replication,
struct GNUNET_TIME_Absolute expiration,
char **msg)
{
}
+/**
+ * Get a random item for replication. Returns a single, not expired, random item
+ * from those with the highest replication counters. The item's
+ * replication counter is decremented by one IF it was positive before.
+ * Call 'iter' with all values ZERO or NULL if the datastore is empty.
+ *
+ * @param cls closure
+ * @param iter function to call the value (once only).
+ * @param iter_cls closure for iter
+ */
+static void
+mysql_plugin_replication_get (void *cls,
+ PluginIterator iter, void *iter_cls)
+{
+ /* FIXME: not implemented! */
+ iter (iter_cls, NULL, NULL, 0, NULL, 0, 0, 0,
+ GNUNET_TIME_UNIT_ZERO_ABS, 0);
+}
+
+
/**
* Update the priority for a particular key in the datastore. If
* the expiration time in value is different than the time found in
api->put = &mysql_plugin_put;
api->next_request = &mysql_plugin_next_request;
api->get = &mysql_plugin_get;
+ api->replication_get = &mysql_plugin_replication_get;
api->update = &mysql_plugin_update;
api->iter_low_priority = &mysql_plugin_iter_low_priority;
api->iter_zero_anonymity = &mysql_plugin_iter_zero_anonymity;
* @param type type of the content
* @param priority priority of the content
* @param anonymity anonymity-level for the content
+ * @param replication replication-level for the content
* @param expiration expiration time for the content
* @param msg set to error message
* @return GNUNET_OK on success
enum GNUNET_BLOCK_Type type,
uint32_t priority,
uint32_t anonymity,
+ uint32_t replication,
struct GNUNET_TIME_Absolute expiration,
char **msg)
{
}
+/**
+ * Get a random item for replication. Returns a single, not expired, random item
+ * from those with the highest replication counters. The item's
+ * replication counter is decremented by one IF it was positive before.
+ * Call 'iter' with all values ZERO or NULL if the datastore is empty.
+ *
+ * @param cls closure
+ * @param iter function to call the value (once only).
+ * @param iter_cls closure for iter
+ */
+static void
+postgres_plugin_replication_get (void *cls,
+ PluginIterator iter, void *iter_cls)
+{
+ /* FIXME: not implemented! */
+ iter (iter_cls, NULL, NULL, 0, NULL, 0, 0, 0,
+ GNUNET_TIME_UNIT_ZERO_ABS, 0);
+}
+
+
/**
* Select a subset of the items in the datastore and call
* the given iterator for each of them.
api->put = &postgres_plugin_put;
api->next_request = &postgres_plugin_next_request;
api->get = &postgres_plugin_get;
+ api->replication_get = &postgres_plugin_replication_get;
api->update = &postgres_plugin_update;
api->iter_low_priority = &postgres_plugin_iter_low_priority;
api->iter_zero_anonymity = &postgres_plugin_iter_zero_anonymity;
* @param type type of the content
* @param priority priority of the content
* @param anonymity anonymity-level for the content
+ * @param replication replication-level for the content
* @param expiration expiration time for the content
* @param msg set to an error message
* @return GNUNET_OK on success
enum GNUNET_BLOCK_Type type,
uint32_t priority,
uint32_t anonymity,
+ uint32_t replication,
struct GNUNET_TIME_Absolute expiration,
char ** msg)
{
}
+/**
+ * Get a random item for replication. Returns a single, not expired, random item
+ * from those with the highest replication counters. The item's
+ * replication counter is decremented by one IF it was positive before.
+ * Call 'iter' with all values ZERO or NULL if the datastore is empty.
+ *
+ * @param cls closure
+ * @param iter function to call the value (once only).
+ * @param iter_cls closure for iter
+ */
+static void
+sqlite_plugin_replication_get (void *cls,
+ PluginIterator iter, void *iter_cls)
+{
+ /* FIXME: not implemented! */
+ iter (iter_cls, NULL, NULL, 0, NULL, 0, 0, 0,
+ GNUNET_TIME_UNIT_ZERO_ABS, 0);
+}
+
+
/**
* Drop database.
*
api->put = &sqlite_plugin_put;
api->next_request = &sqlite_next_request;
api->get = &sqlite_plugin_get;
+ api->replication_get = &sqlite_plugin_replication_get;
api->update = &sqlite_plugin_update;
api->iter_low_priority = &sqlite_plugin_iter_low_priority;
api->iter_zero_anonymity = &sqlite_plugin_iter_zero_anonymity;
* @param type type of the content
* @param priority priority of the content
* @param anonymity anonymity-level for the content
+ * @param replication replication-level for the content
* @param expiration expiration time for the content
* @param msg set to error message
* @return GNUNET_OK on success
enum GNUNET_BLOCK_Type type,
uint32_t priority,
uint32_t anonymity,
+ uint32_t replication,
struct GNUNET_TIME_Absolute expiration,
char **msg)
{
}
+
+/**
+ * Get a random item for replication. Returns a single, not expired, random item
+ * from those with the highest replication counters. The item's
+ * replication counter is decremented by one IF it was positive before.
+ * Call 'iter' with all values ZERO or NULL if the datastore is empty.
+ *
+ * @param cls closure
+ * @param iter function to call the value (once only).
+ * @param iter_cls closure for iter
+ */
+static void
+template_plugin_replication_get (void *cls,
+ PluginIterator iter, void *iter_cls)
+{
+ GNUNET_break (0);
+}
+
+
/**
* Update the priority for a particular key in the datastore. If
* the expiration time in value is different than the time found in
api->put = &template_plugin_put;
api->next_request = &template_plugin_next_request;
api->get = &template_plugin_get;
+ api->replication_get = &template_plugin_replication_get;
api->update = &template_plugin_update;
api->iter_low_priority = &template_plugin_iter_low_priority;
api->iter_zero_anonymity = &template_plugin_iter_zero_anonymity;
/*
This file is part of GNUnet
- (C) 2009 Christian Grothoff (and other contributing authors)
+ (C) 2009, 2011 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
/**
* Store an item in the datastore. If the item is already present,
- * the priorities are summed up and the higher expiration time and
- * lower anonymity level is used.
+ * the priorities and replication levels are summed up and the higher
+ * expiration time and lower anonymity level is used.
*
* @param cls closure
* @param key key for the item
* @param type type of the content
* @param priority priority of the content
* @param anonymity anonymity-level for the content
+ * @param replication replication-level for the content
* @param expiration expiration time for the content
* @param msg set to an error message (on failure)
* @return GNUNET_OK on success, GNUNET_NO if the content
enum GNUNET_BLOCK_Type type,
uint32_t priority,
uint32_t anonymity,
+ uint32_t replication,
struct GNUNET_TIME_Absolute expiration,
char **msg);
PluginIterator iter, void *iter_cls);
+
+/**
+ * Get a random item for replication. Returns a single,
+ * not expired, random item
+ * from those with the highest replication counters. The item's
+ * replication counter is decremented by one IF it was positive before.
+ * Call 'iter' with all values ZERO or NULL if the datastore is empty.
+ *
+ * @param cls closure
+ * @param iter function to call the value (once only).
+ * @param iter_cls closure for iter
+ */
+typedef void (*PluginReplicationGet) (void *cls,
+ PluginIterator iter, void *iter_cls);
+
+
/**
* Update the priority for a particular key in the datastore. If
* the expiration time in value is different than the time found in
*/
PluginGet get;
+ /**
+ * Function to get a random item with high replication score from
+ * the database, lowering the item's replication score.
+ */
+ PluginReplicationGet replication_get;
+
/**
* Update the priority for a particular key in the datastore. If
* the expiration time in value is different than the time found in