+/**
+ * Watch statistics from the peer (be notified whenever they change).
+ *
+ * @param handle identification of the statistics service
+ * @param subsystem limit to the specified subsystem, never NULL
+ * @param name name of the statistic value, never NULL
+ * @param proc function to call on each value
+ * @param proc_cls closure for @a proc
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
+ */
+int
+GNUNET_STATISTICS_watch (struct GNUNET_STATISTICS_Handle *handle,
+ const char *subsystem,
+ const char *name,
+ GNUNET_STATISTICS_Iterator proc,
+ void *proc_cls)
+{
+ struct GNUNET_STATISTICS_WatchEntry *w;
+
+ if (NULL == handle)
+ return GNUNET_SYSERR;
+ w = GNUNET_new (struct GNUNET_STATISTICS_WatchEntry);
+ w->subsystem = GNUNET_strdup (subsystem);
+ w->name = GNUNET_strdup (name);
+ w->proc = proc;
+ w->proc_cls = proc_cls;
+ GNUNET_array_append (handle->watches,
+ handle->watches_size,
+ w);
+ schedule_watch_request (handle,
+ w);
+ return GNUNET_OK;
+}
+
+
+/**
+ * Stop watching statistics from the peer.
+ *
+ * @param handle identification of the statistics service
+ * @param subsystem limit to the specified subsystem, never NULL
+ * @param name name of the statistic value, never NULL
+ * @param proc function to call on each value
+ * @param proc_cls closure for @a proc
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR on error (no such watch)
+ */
+int
+GNUNET_STATISTICS_watch_cancel (struct GNUNET_STATISTICS_Handle *handle,
+ const char *subsystem,
+ const char *name,
+ GNUNET_STATISTICS_Iterator proc,
+ void *proc_cls)
+{
+ struct GNUNET_STATISTICS_WatchEntry *w;
+
+ if (NULL == handle)
+ return GNUNET_SYSERR;
+ for (unsigned int i=0;i<handle->watches_size;i++)
+ {
+ w = handle->watches[i];
+ if (NULL == w)
+ continue;
+ if ( (w->proc == proc) &&
+ (w->proc_cls == proc_cls) &&
+ (0 == strcmp (w->name,
+ name)) &&
+ (0 == strcmp (w->subsystem,
+ subsystem)) )
+ {
+ GNUNET_free (w->name);
+ GNUNET_free (w->subsystem);
+ GNUNET_free (w);
+ handle->watches[i] = NULL;
+ return GNUNET_OK;
+ }
+ }
+ return GNUNET_SYSERR;
+}
+
+
+/**
+ * Queue a request to change a statistic.
+ *
+ * @param h statistics handle
+ * @param name name of the value
+ * @param make_persistent should the value be kept across restarts?
+ * @param value new value or change
+ * @param type type of the action (#ACTION_SET or #ACTION_UPDATE)
+ */