- ic->callback (ic->callback_cls, NULL, NULL, 2);
- reconnect (ic->h);
- trigger_transmit (ic->h);
- GNUNET_free (ic);
- return;
- }
- GNUNET_CLIENT_receive (ic->h->client,
- &peerinfo_handler,
- ic,
- GNUNET_TIME_absolute_get_remaining (ic->timeout));
-}
-
-
-/**
- * Call a method for each known matching host and change its trust
- * value. The callback method will be invoked once for each matching
- * host and then finally once with a NULL pointer. After that final
- * invocation, the iterator context must no longer be used.
- *
- * Note that the last call can be triggered by timeout or by simply
- * being done; however, the trust argument will be set to zero if we
- * are done, 1 if we timed out and 2 for fatal error.
- *
- * Instead of calling this function with 'peer == NULL' and 'trust ==
- * 0', it is often better to use 'GNUNET_PEERINFO_notify'.
- *
- * @param h handle to the peerinfo service
- * @param peer restrict iteration to this peer only (can be NULL)
- * @param trust_delta how much to change the trust in all matching peers
- * @param timeout how long to wait until timing out
- * @param callback the method to call for each peer
- * @param callback_cls closure for callback
- * @return NULL on error (in this case, 'callback' is never called!),
- * otherwise an iterator context
- */
-struct GNUNET_PEERINFO_NewIteratorContext *
-GNUNET_PEERINFO_iterate_new (struct GNUNET_PEERINFO_Handle *h,
- const struct GNUNET_PeerIdentity *peer,
- int trust_delta,
- struct GNUNET_TIME_Relative timeout,
- GNUNET_PEERINFO_Processor callback,
- void *callback_cls)
-{
- struct ListAllPeersMessage *lapm;
- struct ListPeerMessage *lpm;
- struct GNUNET_PEERINFO_NewIteratorContext *ic;
- struct TransmissionQueueEntry *tqe;
-
-#if DEBUG_PEERINFO
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Requesting list of peers from peerinfo database\n");
-#endif
- if (peer == NULL)
- {
- tqe = GNUNET_malloc (sizeof (struct TransmissionQueueEntry) +
- sizeof (struct ListAllPeersMessage));
- tqe->size = sizeof (struct ListAllPeersMessage);
- lapm = (struct ListAllPeersMessage *) &tqe[1];
- lapm->header.size = htons (sizeof (struct ListAllPeersMessage));
- lapm->header.type = htons (GNUNET_MESSAGE_TYPE_PEERINFO_GET_ALL);
- lapm->trust_change = htonl (trust_delta);
- }
- else
- {
- tqe = GNUNET_malloc (sizeof (struct TransmissionQueueEntry) +
- sizeof (struct ListPeerMessage));
- tqe->size = sizeof (struct ListPeerMessage);
- lpm = (struct ListPeerMessage *) &tqe[1];
- lpm->header.size = htons (sizeof (struct ListPeerMessage));
- lpm->header.type = htons (GNUNET_MESSAGE_TYPE_PEERINFO_GET);
- lpm->trust_change = htonl (trust_delta);
- memcpy (&lpm->peer, peer, sizeof (struct GNUNET_PeerIdentity));