};
-/**
- * Message to the datastore service requesting an update
- * to the priority or expiration for some content.
- */
-struct UpdateMessage
-{
- /**
- * Type is GNUNET_MESSAGE_TYPE_DATASTORE_UPDATE.
- */
- struct GNUNET_MessageHeader header;
-
- /**
- * Desired priority increase.
- */
- int32_t priority GNUNET_PACKED;
-
- /**
- * Desired new expiration time.
- */
- struct GNUNET_TIME_AbsoluteNBO expiration;
-
- /**
- * Unique ID for the content.
- */
- uint64_t uid;
-
-};
-
-
/**
* Message transmitting content from or to the datastore
* service.
}
-/**
- * Update a value in the datastore.
- *
- * @param h handle to the datastore
- * @param uid identifier for the value
- * @param priority how much to increase the priority of the value
- * @param expiration new expiration value should be MAX of existing and this argument
- * @param queue_priority ranking of this request in the priority queue
- * @param max_queue_size at what queue size should this request be dropped
- * (if other requests of higher priority are in the queue)
- * @param cont continuation to call when done
- * @param cont_cls closure for @a cont
- * @return NULL if the entry was not queued, otherwise a handle that can be used to
- * cancel; note that even if NULL is returned, the callback will be invoked
- * (or rather, will already have been invoked)
- */
-struct GNUNET_DATASTORE_QueueEntry *
-GNUNET_DATASTORE_update (struct GNUNET_DATASTORE_Handle *h,
- uint64_t uid,
- uint32_t priority,
- struct GNUNET_TIME_Absolute expiration,
- unsigned int queue_priority,
- unsigned int max_queue_size,
- GNUNET_DATASTORE_ContinuationWithStatus cont,
- void *cont_cls)
-{
- struct GNUNET_DATASTORE_QueueEntry *qe;
- struct GNUNET_MQ_Envelope *env;
- struct UpdateMessage *um;
- union QueueContext qc;
-
- if (NULL == cont)
- cont = &drop_status_cont;
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Asked to update entry %llu raising priority by %u and expiration to %s\n",
- uid,
- (unsigned int) priority,
- GNUNET_STRINGS_absolute_time_to_string (expiration));
- env = GNUNET_MQ_msg (um,
- GNUNET_MESSAGE_TYPE_DATASTORE_UPDATE);
- um->priority = htonl (priority);
- um->expiration = GNUNET_TIME_absolute_hton (expiration);
- um->uid = GNUNET_htonll (uid);
-
- qc.sc.cont = cont;
- qc.sc.cont_cls = cont_cls;
- qe = make_queue_entry (h,
- env,
- queue_priority,
- max_queue_size,
- GNUNET_MESSAGE_TYPE_DATASTORE_STATUS,
- &qc);
- if (NULL == qe)
- {
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Could not create queue entry for UPDATE\n");
- return NULL;
- }
- GNUNET_STATISTICS_update (h->stats,
- gettext_noop ("# UPDATE requests executed"), 1,
- GNUNET_NO);
- process_queue (h);
- return qe;
-}
-
-
/**
* Explicitly remove some content from the database.
* The @a cont continuation will be called with `status`
}
-/**
- * Function called with the result of an update operation.
- *
- * @param cls closure
- * @param status #GNUNET_OK or #GNUNET_SYSERR
- * @param msg error message on error
- */
-static void
-update_continuation (void *cls,
- int status,
- const char *msg)
-{
- struct GNUNET_SERVICE_Client *client = cls;
-
- transmit_status (client,
- status,
- msg);
-}
-
-
-/**
- * Handle UPDATE-message.
- *
- * @param cls client identification of the client
- * @param message the actual message
- */
-static void
-handle_update (void *cls,
- const struct UpdateMessage *msg)
-{
- struct GNUNET_SERVICE_Client *client = cls;
-
- GNUNET_STATISTICS_update (stats,
- gettext_noop ("# UPDATE requests received"),
- 1,
- GNUNET_NO);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Processing UPDATE request for %llu\n",
- (unsigned long long) GNUNET_ntohll (msg->uid));
- plugin->api->update (plugin->api->cls,
- GNUNET_ntohll (msg->uid),
- (int32_t) ntohl (msg->priority),
- GNUNET_TIME_absolute_ntoh (msg->expiration),
- &update_continuation,
- client);
- GNUNET_SERVICE_client_continue (client);
-}
-
-
/**
* Handle GET_REPLICATION-message.
*
GNUNET_MESSAGE_TYPE_DATASTORE_PUT,
struct DataMessage,
NULL),
- GNUNET_MQ_hd_fixed_size (update,
- GNUNET_MESSAGE_TYPE_DATASTORE_UPDATE,
- struct UpdateMessage,
- NULL),
GNUNET_MQ_hd_fixed_size (get,
GNUNET_MESSAGE_TYPE_DATASTORE_GET,
struct GetMessage,
RP_PUT_MULTIPLE_NEXT = 8,
RP_GET_MULTIPLE = 9,
RP_GET_MULTIPLE_NEXT = 10,
- RP_UPDATE = 11,
- RP_UPDATE_VALIDATE = 12,
/**
* Execution failed with some kind of error.
break;
case RP_GET_MULTIPLE_NEXT:
GNUNET_assert (uid != crc->first_uid);
- crc->phase = RP_UPDATE;
+ crc->phase = RP_DONE;
break;
default:
GNUNET_break (0);
}
-static void
-check_update (void *cls,
- const struct GNUNET_HashCode *key,
- size_t size,
- const void *data,
- enum GNUNET_BLOCK_Type type,
- uint32_t priority,
- uint32_t anonymity,
- struct GNUNET_TIME_Absolute expiration,
- uint64_t uid)
-{
- struct CpsRunContext *crc = cls;
-
- GNUNET_assert (key != NULL);
- if ((anonymity == get_anonymity (42)) && (size == get_size (42)) &&
- (priority == get_priority (42) + 100))
- crc->phase = RP_DONE;
- else
- {
- GNUNET_assert (size == get_size (43));
- crc->offset++;
- }
- GNUNET_SCHEDULER_add_now (&run_continuation, crc);
-}
-
-
/**
* Main state machine. Executes the next step of the test
* depending on the current state.
1, 1,
&check_multiple, crc));
break;
- case RP_UPDATE:
- GNUNET_assert (crc->uid > 0);
- crc->phase = RP_UPDATE_VALIDATE;
- GNUNET_DATASTORE_update (datastore,
- crc->uid, 100,
- get_expiration (42), 1,
- 1,
- &check_success, crc);
- break;
- case RP_UPDATE_VALIDATE:
- GNUNET_assert (NULL !=
- GNUNET_DATASTORE_get_key (datastore,
- crc->offset,
- &crc->key,
- get_type (42),
- 1, 1,
- &check_update, crc));
- break;
case RP_DONE:
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Finished, disconnecting\n");
*/
#define GNUNET_MESSAGE_TYPE_DATASTORE_PUT 95
-/**
- * Message sent by datastore client to update data.
- */
-#define GNUNET_MESSAGE_TYPE_DATASTORE_UPDATE 96
-
/**
* Message sent by datastore client to get data.
*/