aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/include/gnunet_peerinfo_service.h13
-rw-r--r--src/peerinfo/peerinfo_api.c126
2 files changed, 136 insertions, 3 deletions
diff --git a/src/include/gnunet_peerinfo_service.h b/src/include/gnunet_peerinfo_service.h
index e84b2ca4e..553624b82 100644
--- a/src/include/gnunet_peerinfo_service.h
+++ b/src/include/gnunet_peerinfo_service.h
@@ -160,6 +160,8 @@ GNUNET_PEERINFO_iterate (const struct GNUNET_CONFIGURATION_Handle *cfg,
160 void *callback_cls); 160 void *callback_cls);
161 161
162 162
163struct GNUNET_PEERINFO_NewIteratorContext;
164
163 165
164/** 166/**
165 * Call a method for each known matching host and change its trust 167 * Call a method for each known matching host and change its trust
@@ -183,7 +185,7 @@ GNUNET_PEERINFO_iterate (const struct GNUNET_CONFIGURATION_Handle *cfg,
183 * @return NULL on error (in this case, 'callback' is never called!), 185 * @return NULL on error (in this case, 'callback' is never called!),
184 * otherwise an iterator context 186 * otherwise an iterator context
185 */ 187 */
186struct GNUNET_PEERINFO_IteratorContext * 188struct GNUNET_PEERINFO_NewIteratorContext *
187GNUNET_PEERINFO_iterate_new (struct GNUNET_PEERINFO_Handle *h, 189GNUNET_PEERINFO_iterate_new (struct GNUNET_PEERINFO_Handle *h,
188 const struct GNUNET_PeerIdentity *peer, 190 const struct GNUNET_PeerIdentity *peer,
189 int trust_delta, 191 int trust_delta,
@@ -199,6 +201,15 @@ GNUNET_PEERINFO_iterate_new (struct GNUNET_PEERINFO_Handle *h,
199 * @param ic context of the iterator to cancel 201 * @param ic context of the iterator to cancel
200 */ 202 */
201void 203void
204GNUNET_PEERINFO_iterate_cancel_new (struct GNUNET_PEERINFO_NewIteratorContext *ic);
205
206
207/**
208 * Cancel an iteration over peer information.
209 *
210 * @param ic context of the iterator to cancel
211 */
212void
202GNUNET_PEERINFO_iterate_cancel (struct GNUNET_PEERINFO_IteratorContext *ic); 213GNUNET_PEERINFO_iterate_cancel (struct GNUNET_PEERINFO_IteratorContext *ic);
203 214
204 215
diff --git a/src/peerinfo/peerinfo_api.c b/src/peerinfo/peerinfo_api.c
index 841f14074..89422bcb6 100644
--- a/src/peerinfo/peerinfo_api.c
+++ b/src/peerinfo/peerinfo_api.c
@@ -30,6 +30,130 @@
30#include "gnunet_time_lib.h" 30#include "gnunet_time_lib.h"
31#include "peerinfo.h" 31#include "peerinfo.h"
32 32
33
34
35/**
36 * Handle to the peerinfo service.
37 */
38struct GNUNET_PEERINFO_Handle
39{
40};
41
42
43/**
44 * Connect to the peerinfo service.
45 *
46 * @param cfg configuration to use
47 * @param sched scheduler to use
48 * @return NULL on error (configuration related, actual connection
49 * etablishment may happen asynchronously).
50 */
51struct GNUNET_PEERINFO_Handle *
52GNUNET_PEERINFO_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
53 struct GNUNET_SCHEDULER_Handle *sched)
54{
55 return NULL;
56}
57
58
59/**
60 * Disconnect from the peerinfo service. Note that all iterators must
61 * have completed or have been cancelled by the time this function is
62 * called (otherwise, calling this function is a serious error).
63 * Furthermore, if 'GNUNET_PEERINFO_add_peer' operations are still
64 * pending, they will be cancelled silently on disconnect.
65 *
66 * @param h handle to disconnect
67 */
68void
69GNUNET_PEERINFO_disconnect (struct GNUNET_PEERINFO_Handle *h)
70{
71}
72
73
74
75
76
77
78/**
79 * Add a host to the persistent list. This method operates in
80 * semi-reliable mode: if the transmission is not completed by
81 * the time 'GNUNET_PEERINFO_disconnect' is called, it will be
82 * aborted. Furthermore, if a second HELLO is added for the
83 * same peer before the first one was transmitted, PEERINFO may
84 * merge the two HELLOs prior to transmission to the service.
85 *
86 * @param h handle to the peerinfo service
87 * @param peer identity of the peer
88 * @param hello the verified (!) HELLO message
89 */
90void
91GNUNET_PEERINFO_add_peer_new (struct GNUNET_PEERINFO_Handle *h,
92 const struct GNUNET_PeerIdentity *peer,
93 const struct GNUNET_HELLO_Message *hello)
94{
95}
96
97
98struct GNUNET_PEERINFO_NewIteratorContext
99{
100};
101
102
103/**
104 * Call a method for each known matching host and change its trust
105 * value. The callback method will be invoked once for each matching
106 * host and then finally once with a NULL pointer. After that final
107 * invocation, the iterator context must no longer be used.
108 *
109 * Note that the last call can be triggered by timeout or by simply
110 * being done; however, the trust argument will be set to zero if we
111 * are done, 1 if we timed out and 2 for fatal error.
112 *
113 * Instead of calling this function with 'peer == NULL' and 'trust ==
114 * 0', it is often better to use 'GNUNET_PEERINFO_notify'.
115 *
116 * @param h handle to the peerinfo service
117 * @param peer restrict iteration to this peer only (can be NULL)
118 * @param trust_delta how much to change the trust in all matching peers
119 * @param timeout how long to wait until timing out
120 * @param callback the method to call for each peer
121 * @param callback_cls closure for callback
122 * @return NULL on error (in this case, 'callback' is never called!),
123 * otherwise an iterator context
124 */
125struct GNUNET_PEERINFO_NewIteratorContext *
126GNUNET_PEERINFO_iterate_new (struct GNUNET_PEERINFO_Handle *h,
127 const struct GNUNET_PeerIdentity *peer,
128 int trust_delta,
129 struct GNUNET_TIME_Relative timeout,
130 GNUNET_PEERINFO_Processor callback,
131 void *callback_cls)
132{
133 return NULL;
134}
135
136
137
138/**
139 * Cancel an iteration over peer information.
140 *
141 * @param ic context of the iterator to cancel
142 */
143void
144GNUNET_PEERINFO_iterate_cancel_new (struct GNUNET_PEERINFO_NewIteratorContext *ic)
145{
146}
147
148
149
150
151
152/* ***************************** OLD API ****************************** */
153
154
155
156
33#define ADD_PEER_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) 157#define ADD_PEER_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
34 158
35 159
@@ -324,6 +448,4 @@ GNUNET_PEERINFO_iterate_cancel (struct GNUNET_PEERINFO_IteratorContext *ic)
324} 448}
325 449
326 450
327
328
329/* end of peerinfo_api.c */ 451/* end of peerinfo_api.c */