*/
uint32_t anonymity GNUNET_PACKED;
+ /**
+ * Desired replication level. 0 from service to API.
+ */
+ uint32_t replication GNUNET_PACKED;
+
+ /**
+ * For alignment.
+ */
+ uint32_t reserved GNUNET_PACKED;
+
/**
* Unique ID for the content (can be used for UPDATE);
* can be zero for remove (which indicates that
#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Asked to put %u bytes of data under key `%s'\n",
+ "Asked to put %u bytes of data under key `%s' for %llu ms\n",
size,
- GNUNET_h2s (key));
+ GNUNET_h2s (key),
+ GNUNET_TIME_absolute_get_remaining (expiration).rel_value);
#endif
msize = sizeof(struct DataMessage) + size;
GNUNET_assert (msize < GNUNET_SERVER_MAX_MESSAGE_SIZE);
dm->type = htonl(type);
dm->priority = htonl(priority);
dm->anonymity = htonl(anonymity);
+ dm->replication = htonl (replication);
+ dm->reserved = htonl (0);
dm->uid = GNUNET_htonll(0);
dm->expiration = GNUNET_TIME_absolute_hton(expiration);
dm->key = *key;
dm->type = htonl(type);
dm->priority = htonl(priority);
dm->anonymity = htonl(anonymity);
+ dm->replication = htonl (0);
+ dm->reserved = htonl (0);
dm->expiration = GNUNET_TIME_absolute_hton(expiration);
dm->uid = GNUNET_htonll(uid);
dm->key = *key;
memcpy (&dm[1], data, size);
#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Transmitting `%s' message for `%s' of type %u\n",
+ "Transmitting `%s' message for `%s' of type %u with expiration %llu (now: %llu)\n",
"DATA",
GNUNET_h2s (key),
- type);
+ type,
+ (unsigned long long) expiration.abs_value,
+ (unsigned long long) GNUNET_TIME_absolute_get ().abs_value);
#endif
GNUNET_STATISTICS_update (stats,
gettext_noop ("# results found"),
ntohl(dm->type),
ntohl(dm->priority),
ntohl(dm->anonymity),
- 0 /* FIXME: replication */,
+ ntohl(dm->replication),
GNUNET_TIME_absolute_ntoh(dm->expiration),
&msg);
if (GNUNET_OK == ret)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Result already present in datastore\n");
#endif
+ /* FIXME: change API to allow increasing 'replication' counter */
+ if ( (ntohl (dm->priority) > 0) ||
+ (GNUNET_TIME_absolute_ntoh(dm->expiration).abs_value >
+ expiration.abs_value) )
+ plugin->api->update (plugin->api->cls,
+ uid,
+ (int32_t) ntohl(dm->priority),
+ GNUNET_TIME_absolute_ntoh(dm->expiration),
+ NULL);
transmit_status (pc->client, GNUNET_NO, NULL);
GNUNET_SERVER_client_drop (pc->client);
GNUNET_free (pc);
/**
* Enable or disable logging debug messages.
*/
-#define DEBUG_SQLITE GNUNET_NO
+#define DEBUG_SQLITE GNUNET_YES
/**
* We allocate items on the stack at times. To prevent a stack
#if DEBUG_SQLITE
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
"sqlite",
- "Storing in database block with type %u/key `%s'/priority %u/expiration %llu (%lld).\n",
+ "Storing in database block with type %u/key `%s'/priority %u/expiration in %llu ms (%lld).\n",
type,
GNUNET_h2s(key),
priority,
break;
}
expiration.abs_value = sqlite3_column_int64 (stmt, 3);
+#if DEBUG_SQLITE
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
+ "sqlite",
+ "Found reply in database with expiration %llu\n",
+ (unsigned long long) expiration.abs_value);
+#endif
ret = proc (proc_cls,
sqlite3_column_blob (stmt, 4) /* key */,
size,
#if DEBUG_SQLITE
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
"sqlite",
- "sqlite plugin is finished doneing\n");
+ "sqlite plugin is finished\n");
#endif
return NULL;
}