*
* MANUAL SETUP INSTRUCTIONS
*
- * 1) in /etc/gnunet.conf, set
+ * 1) in gnunet.conf, set
* @verbatim
[datastore]
DATABASE = "mysql"
#define UPDATE_ENTRY "UPDATE gn090 SET prio=prio+?,expire=IF(expire>=?,expire,?) WHERE uid=?"
struct GNUNET_MYSQL_StatementHandle *update_entry;
-#define DEC_REPL "UPDATE gn090 SET repl=GREATEST (0, repl - 1) WHERE uid=?"
+#define DEC_REPL "UPDATE gn090 SET repl=GREATEST (1, repl) - 1 WHERE uid=?"
struct GNUNET_MYSQL_StatementHandle *dec_repl;
#define SELECT_SIZE "SELECT SUM(BIT_LENGTH(value) DIV 8) FROM gn090"
* @return GNUNET_OK on success
*/
static int
-mysql_plugin_put (void *cls, const GNUNET_HashCode * key, uint32_t size,
+mysql_plugin_put (void *cls, const struct GNUNET_HashCode * key, uint32_t size,
const void *data, enum GNUNET_BLOCK_Type type,
uint32_t priority, uint32_t anonymity, uint32_t replication,
struct GNUNET_TIME_Absolute expiration, char **msg)
unsigned int irepl = replication;
unsigned int ipriority = priority;
unsigned int ianonymity = anonymity;
- unsigned long long lexpiration = expiration.abs_value;
+ unsigned long long lexpiration = expiration.abs_value_us;
unsigned long long lrvalue =
(unsigned long long) GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
UINT64_MAX);
unsigned long hashSize;
unsigned long hashSize2;
unsigned long lsize;
- GNUNET_HashCode vhash;
+ struct GNUNET_HashCode vhash;
if (size > MAX_DATUM_SIZE)
{
GNUNET_break (0);
return GNUNET_SYSERR;
}
- hashSize = sizeof (GNUNET_HashCode);
- hashSize2 = sizeof (GNUNET_HashCode);
+ hashSize = sizeof (struct GNUNET_HashCode);
+ hashSize2 = sizeof (struct GNUNET_HashCode);
lsize = size;
GNUNET_CRYPTO_hash (data, size, &vhash);
if (GNUNET_OK !=
{
struct Plugin *plugin = cls;
unsigned long long vkey = uid;
- unsigned long long lexpire = expire.abs_value;
+ unsigned long long lexpire = expire.abs_value_us;
int ret;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Updating value %llu adding %d to priority and maxing exp at %llu\n",
- vkey, delta, lexpire);
+ "Updating value %llu adding %d to priority and maxing exp at %s\n",
+ vkey, delta,
+ GNUNET_STRINGS_absolute_time_to_string (expire));
ret =
GNUNET_MYSQL_statement_run_prepared (plugin->mc, plugin->update_entry, NULL,
MYSQL_TYPE_LONG, &delta, GNUNET_NO,
unsigned long size;
unsigned long long uid;
char value[GNUNET_DATASTORE_MAX_VALUE_SIZE];
- GNUNET_HashCode key;
+ struct GNUNET_HashCode key;
struct GNUNET_TIME_Absolute expiration;
MYSQL_BIND rbind[7];
- hashSize = sizeof (GNUNET_HashCode);
+ hashSize = sizeof (struct GNUNET_HashCode);
memset (rbind, 0, sizeof (rbind));
rbind[0].buffer_type = MYSQL_TYPE_LONG;
rbind[0].buffer = &type;
return;
}
GNUNET_assert (size <= sizeof (value));
- if ((rbind[4].buffer_length != sizeof (GNUNET_HashCode)) ||
- (hashSize != sizeof (GNUNET_HashCode)))
+ if ((rbind[4].buffer_length != sizeof (struct GNUNET_HashCode)) ||
+ (hashSize != sizeof (struct GNUNET_HashCode)))
{
GNUNET_break (0);
proc (proc_cls, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0);
return;
}
+ expiration.abs_value_us = exp;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Found %u-byte value under key `%s' with prio %u, anon %u, expire %llu selecting from gn090 table\n",
- (unsigned int) size, GNUNET_h2s (&key), priority, anonymity, exp);
+ "Found %u-byte value under key `%s' with prio %u, anon %u, expire %s selecting from gn090 table\n",
+ (unsigned int) size, GNUNET_h2s (&key),
+ priority, anonymity,
+ GNUNET_STRINGS_absolute_time_to_string (expiration));
GNUNET_assert (size < MAX_DATUM_SIZE);
- expiration.abs_value = exp;
ret =
proc (proc_cls, &key, size, value, type, priority, anonymity, expiration,
uid);
* @param proc_cls closure for proc
*/
static void
-mysql_plugin_get_key (void *cls, uint64_t offset, const GNUNET_HashCode * key,
- const GNUNET_HashCode * vhash,
+mysql_plugin_get_key (void *cls, uint64_t offset, const struct GNUNET_HashCode * key,
+ const struct GNUNET_HashCode * vhash,
enum GNUNET_BLOCK_Type type, PluginDatumProcessor proc,
void *proc_cls)
{
GNUNET_assert (key != NULL);
GNUNET_assert (NULL != proc);
- hashSize = sizeof (GNUNET_HashCode);
- hashSize2 = sizeof (GNUNET_HashCode);
+ hashSize = sizeof (struct GNUNET_HashCode);
+ hashSize2 = sizeof (struct GNUNET_HashCode);
memset (cbind, 0, sizeof (cbind));
total = -1;
cbind[0].buffer_type = MYSQL_TYPE_LONGLONG;
* GNUNET_NO to delete the item and continue (if supported)
*/
static int
-repl_proc (void *cls, const GNUNET_HashCode * key, uint32_t size,
+repl_proc (void *cls, const struct GNUNET_HashCode * key, uint32_t size,
const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority,
uint32_t anonymity, struct GNUNET_TIME_Absolute expiration,
uint64_t uid)
const char *query = "SELECT hash FROM gn090";
int ret;
MYSQL_STMT *statement;
- GNUNET_HashCode key;
+ struct GNUNET_HashCode key;
MYSQL_BIND cbind[1];
unsigned long length;
-
+
statement = GNUNET_MYSQL_statement_get_stmt (plugin->mc,
plugin->get_all_keys);
if (statement == NULL)
}
while (0 == (ret = mysql_stmt_fetch (statement)))
{
- if (sizeof (GNUNET_HashCode) == length)
- proc (proc_cls, &key, 1);
+ if (sizeof (struct GNUNET_HashCode) == length)
+ proc (proc_cls, &key, 1);
}
if (ret != MYSQL_NO_DATA)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("`%s' failed at %s:%d with error: %s\n"),
"mysql_stmt_fetch", __FILE__, __LINE__,
- mysql_stmt_error (statement));
+ mysql_stmt_error (statement));
GNUNET_MYSQL_statements_invalidate (plugin->mc);
return;
}
* GNUNET_NO to delete the item and continue (if supported)
*/
static int
-expi_proc (void *cls, const GNUNET_HashCode * key, uint32_t size,
+expi_proc (void *cls, const struct GNUNET_HashCode * key, uint32_t size,
const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority,
uint32_t anonymity, struct GNUNET_TIME_Absolute expiration,
uint64_t uid)
rc.plugin = plugin;
rc.proc = proc;
rc.proc_cls = proc_cls;
- nt = (long long) GNUNET_TIME_absolute_get ().abs_value;
+ nt = (long long) GNUNET_TIME_absolute_get ().abs_value_us;
execute_select (plugin, plugin->select_expiration, expi_proc, &rc,
MYSQL_TYPE_LONGLONG, &nt, GNUNET_YES, -1);