summaryrefslogtreecommitdiff
path: root/src/include/gnunet_peerinfo_service.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-04-17 16:53:42 +0000
committerChristian Grothoff <christian@grothoff.org>2010-04-17 16:53:42 +0000
commit5a028c05614f71e6279a98e97aa32660b4c3d412 (patch)
tree4d19ea04ab70bf70f36104eb06ceaa01dc1a88f7 /src/include/gnunet_peerinfo_service.h
parent25e132881a18faed1e9438b882367df0dc4e090f (diff)
downloadgnunet-5a028c05614f71e6279a98e97aa32660b4c3d412.tar.gz
gnunet-5a028c05614f71e6279a98e97aa32660b4c3d412.zip
peerinfo API redesign
Diffstat (limited to 'src/include/gnunet_peerinfo_service.h')
-rw-r--r--src/include/gnunet_peerinfo_service.h86
1 files changed, 85 insertions, 1 deletions
diff --git a/src/include/gnunet_peerinfo_service.h b/src/include/gnunet_peerinfo_service.h
index 6deed04d9..e84b2ca4e 100644
--- a/src/include/gnunet_peerinfo_service.h
+++ b/src/include/gnunet_peerinfo_service.h
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet 2 This file is part of GNUnet
3 (C) 2009 Christian Grothoff (and other contributing authors) 3 (C) 2009, 2010 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -43,6 +43,57 @@ extern "C"
43 43
44 44
45/** 45/**
46 * Handle to the peerinfo service.
47 */
48struct GNUNET_PEERINFO_Handle;
49
50
51/**
52 * Connect to the peerinfo service.
53 *
54 * @param cfg configuration to use
55 * @param sched scheduler to use
56 * @return NULL on error (configuration related, actual connection
57 * etablishment may happen asynchronously).
58 */
59struct GNUNET_PEERINFO_Handle *
60GNUNET_PEERINFO_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
61 struct GNUNET_SCHEDULER_Handle *sched);
62
63
64/**
65 * Disconnect from the peerinfo service. Note that all iterators must
66 * have completed or have been cancelled by the time this function is
67 * called (otherwise, calling this function is a serious error).
68 * Furthermore, if 'GNUNET_PEERINFO_add_peer' operations are still
69 * pending, they will be cancelled silently on disconnect.
70 *
71 * @param h handle to disconnect
72 */
73void
74GNUNET_PEERINFO_disconnect (struct GNUNET_PEERINFO_Handle *h);
75
76
77/**
78 * Add a host to the persistent list. This method operates in
79 * semi-reliable mode: if the transmission is not completed by
80 * the time 'GNUNET_PEERINFO_disconnect' is called, it will be
81 * aborted. Furthermore, if a second HELLO is added for the
82 * same peer before the first one was transmitted, PEERINFO may
83 * merge the two HELLOs prior to transmission to the service.
84 *
85 * @param h handle to the peerinfo service
86 * @param peer identity of the peer
87 * @param hello the verified (!) HELLO message
88 */
89void
90GNUNET_PEERINFO_add_peer_new (struct GNUNET_PEERINFO_Handle *h,
91 const struct GNUNET_PeerIdentity *peer,
92 const struct GNUNET_HELLO_Message *hello);
93
94
95
96/**
46 * Add a host to the persistent list. 97 * Add a host to the persistent list.
47 * 98 *
48 * @param cfg configuration to use 99 * @param cfg configuration to use
@@ -109,6 +160,39 @@ GNUNET_PEERINFO_iterate (const struct GNUNET_CONFIGURATION_Handle *cfg,
109 void *callback_cls); 160 void *callback_cls);
110 161
111 162
163
164/**
165 * Call a method for each known matching host and change its trust
166 * value. The callback method will be invoked once for each matching
167 * host and then finally once with a NULL pointer. After that final
168 * invocation, the iterator context must no longer be used.
169 *
170 * Note that the last call can be triggered by timeout or by simply
171 * being done; however, the trust argument will be set to zero if we
172 * are done, 1 if we timed out and 2 for fatal error.
173 *
174 * Instead of calling this function with 'peer == NULL' and 'trust ==
175 * 0', it is often better to use 'GNUNET_PEERINFO_notify'.
176 *
177 * @param h handle to the peerinfo service
178 * @param peer restrict iteration to this peer only (can be NULL)
179 * @param trust_delta how much to change the trust in all matching peers
180 * @param timeout how long to wait until timing out
181 * @param callback the method to call for each peer
182 * @param callback_cls closure for callback
183 * @return NULL on error (in this case, 'callback' is never called!),
184 * otherwise an iterator context
185 */
186struct GNUNET_PEERINFO_IteratorContext *
187GNUNET_PEERINFO_iterate_new (struct GNUNET_PEERINFO_Handle *h,
188 const struct GNUNET_PeerIdentity *peer,
189 int trust_delta,
190 struct GNUNET_TIME_Relative timeout,
191 GNUNET_PEERINFO_Processor callback,
192 void *callback_cls);
193
194
195
112/** 196/**
113 * Cancel an iteration over peer information. 197 * Cancel an iteration over peer information.
114 * 198 *