-/**
- * Closure for 'do_get' and 'get_iterator'.
- */
-struct GetClosure
-{
- /**
- * Key we are doing the 'get' for.
- */
- GNUNET_HashCode key;
-
- /**
- * Datastore entry type we are doing the 'get' for.
- */
- uint32_t type;
-
- /**
- * Function to call for each entry.
- */
- GNUNET_DATASTORE_Iterator iter;
-
- /**
- * Closure for iter.
- */
- void *iter_cls;
-
- /**
- * Timeout for this operation.
- */
- struct GNUNET_TIME_Absolute timeout;
-};
-
-
-/**
- * Wrapper for the datastore get operation. Makes sure to trigger the
- * next datastore operation in the queue once the operation is
- * complete.
- *
- * @param cls our 'struct GetClosure*'
- * @param key key for the content
- * @param size number of bytes in data
- * @param data content stored
- * @param type type of the content
- * @param priority priority of the content
- * @param anonymity anonymity-level for the content
- * @param expiration expiration time for the content
- * @param uid unique identifier for the datum;
- * maybe 0 if no unique identifier is available
- */
-static void
-get_iterator (void *cls,
- const GNUNET_HashCode * key,
- uint32_t size,
- const void *data,
- uint32_t type,
- uint32_t priority,
- uint32_t anonymity,
- struct GNUNET_TIME_Absolute
- expiration,
- uint64_t uid)
-{
- struct GetClosure *gc = cls;
-
- if (gc->iter == NULL)
- {
- /* stop the iteration */
- if (key != NULL)
- GNUNET_DATASTORE_get_next (dsh, GNUNET_NO);
- }
- else
- {
- gc->iter (gc->iter_cls,
- key, size, data, type,
- priority, anonymity, expiration, uid);
- }
- if (key == NULL)
- {
- next_ds_request ();
- GNUNET_free (gc);
- }
-}
-
-
-/**
- * We're at the head of the reqeust queue, execute the
- * get operation (or signal error).
- *
- * @param cls the 'struct GetClosure'
- * @param ok GNUNET_OK if we can run the GET, otherwise
- * we need to time out
- */
-static void
-do_get (void *cls,
- int ok)
-{
- struct GetClosure *gc = cls;
-
- if (ok != GNUNET_OK)
- {
- if (gc->iter != NULL)
- gc->iter (gc->iter_cls,
- NULL, 0, NULL, 0, 0, 0,
- GNUNET_TIME_UNIT_ZERO_ABS, 0);
- GNUNET_free (gc);
- next_ds_request ();
- return;
- }
- GNUNET_DATASTORE_get (dsh, &gc->key, gc->type,
- &get_iterator,
- gc,
- GNUNET_TIME_absolute_get_remaining(gc->timeout));
-}
-
-