ntohl(dm->anonymity),
GNUNET_TIME_absolute_ntoh(dm->expiration),
GNUNET_ntohll(dm->uid));
- GNUNET_CLIENT_receive (h->client,
- &with_result_response_handler,
- h,
- GNUNET_TIME_absolute_get_remaining (h->timeout));
}
}
+
+/**
+ * Function called to trigger obtaining the next result
+ * from the datastore.
+ *
+ * @param h handle to the datastore
+ * @param more GNUNET_YES to get moxre results, GNUNET_NO to abort
+ * iteration (with a final call to "iter" with key/data == NULL).
+ */
+void
+GNUNET_DATASTORE_get_next (struct GNUNET_DATASTORE_Handle *h,
+ int more)
+{
+ GNUNET_DATASTORE_Iterator cont;
+
+ if (GNUNET_YES == more)
+ {
+ GNUNET_CLIENT_receive (h->client,
+ &with_result_response_handler,
+ h,
+ GNUNET_TIME_absolute_get_remaining (h->timeout));
+ return;
+ }
+ cont = h->response_proc;
+ h->response_proc = NULL;
+ GNUNET_CLIENT_disconnect (h->client);
+ h->client = GNUNET_CLIENT_connect (h->sched, "datastore", h->cfg);
+ cont (h->response_proc_cls,
+ NULL, 0, NULL, 0, 0, 0,
+ GNUNET_TIME_UNIT_ZERO_ABS, 0);
+}
+
+
/**
* Helper function that will initiate the
* transmission of a message to the datastore
}
stored_ops++;
if (stored_bytes < MAX_SIZE)
- return;
+ {
+ GNUNET_DATASTORE_get_next (datastore, GNUNET_YES);
+ return;
+ }
crc->key = *key;
crc->esize = size;
memcpy (crc->data, data, size);
+ GNUNET_DATASTORE_get_next (datastore, GNUNET_YES);
}
GNUNET_assert (priority == get_priority (i));
GNUNET_assert (anonymity == get_anonymity(i));
GNUNET_assert (expiration.value == get_expiration(i).value);
+ GNUNET_DATASTORE_get_next (datastore, GNUNET_YES);
}
crc->key = *key;
crc->data = GNUNET_malloc (size);
memcpy (crc->data, data, size);
+ GNUNET_DATASTORE_get_next (datastore, GNUNET_YES);
}
crc->phase++;
if (priority == get_priority (42))
crc->uid = uid;
+ GNUNET_DATASTORE_get_next (datastore, GNUNET_YES);
}
}
else
GNUNET_assert (size == get_size (43));
+ GNUNET_DATASTORE_get_next (datastore, GNUNET_YES);
}
GNUNET_assert (priority == get_priority (i));
GNUNET_assert (anonymity == get_anonymity(i));
GNUNET_assert (expiration.value == get_expiration(i).value);
+ GNUNET_DATASTORE_get_next (datastore, GNUNET_YES);
}
/**
* Iterate over the results for a particular key
- * in the datastore.
+ * in the datastore. The iterator will only be called
+ * once initially; if the first call did contain a
+ * result, further results can be obtained by calling
+ * "GNUNET_DATASTORE_get_next" with the given argument.
*
* @param h handle to the datastore
* @param key maybe NULL (to match all entries)
GNUNET_DATASTORE_get (struct GNUNET_DATASTORE_Handle *h,
const GNUNET_HashCode * key,
uint32_t type,
- GNUNET_DATASTORE_Iterator iter, void *iter_cls,
+ GNUNET_DATASTORE_Iterator iter,
+ void *iter_cls,
struct GNUNET_TIME_Relative timeout);
+/**
+ * Function called to trigger obtaining the next result
+ * from the datastore.
+ *
+ * @param h handle to the datastore
+ * @param more GNUNET_YES to get moxre results, GNUNET_NO to abort
+ * iteration (with a final call to "iter" with key/data == NULL).
+ */
+void
+GNUNET_DATASTORE_get_next (struct GNUNET_DATASTORE_Handle *h,
+ int more);
+
+
/**
* Get a random value from the datastore.
*