diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-03-17 15:41:07 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-03-17 15:41:07 +0000 |
commit | b571e5a4ed7fb2ef6f203c540e82675cf38bfcf8 (patch) | |
tree | 94b14969db712bc389397318f8d24f165810b856 /src/include/gnunet_dht_service.h | |
parent | 57c43f6e066cd8697b864ca3e6967a09cd322c2b (diff) | |
download | gnunet-b571e5a4ed7fb2ef6f203c540e82675cf38bfcf8.tar.gz gnunet-b571e5a4ed7fb2ef6f203c540e82675cf38bfcf8.zip |
crazy work
Diffstat (limited to 'src/include/gnunet_dht_service.h')
-rw-r--r-- | src/include/gnunet_dht_service.h | 135 |
1 files changed, 90 insertions, 45 deletions
diff --git a/src/include/gnunet_dht_service.h b/src/include/gnunet_dht_service.h index dfb880b4a..cf09fd649 100644 --- a/src/include/gnunet_dht_service.h +++ b/src/include/gnunet_dht_service.h | |||
@@ -49,11 +49,14 @@ struct GNUNET_DHT_Handle; | |||
49 | * | 49 | * |
50 | * @param cfg configuration to use | 50 | * @param cfg configuration to use |
51 | * @param sched scheduler to use | 51 | * @param sched scheduler to use |
52 | * @param ht_len size of the internal hash table to use for | ||
53 | * processing multiple GET/FIND requests in parallel | ||
52 | * @return NULL on error | 54 | * @return NULL on error |
53 | */ | 55 | */ |
54 | struct GNUNET_DHT_Handle * | 56 | struct GNUNET_DHT_Handle * |
55 | GNUNET_DHT_connect (struct GNUNET_SCHEDULER_Handle *sched, | 57 | GNUNET_DHT_connect (struct GNUNET_SCHEDULER_Handle *sched, |
56 | const struct GNUNET_CONFIGURATION_Handle *cfg); | 58 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
59 | unsigned int ht_len); | ||
57 | 60 | ||
58 | 61 | ||
59 | /** | 62 | /** |
@@ -66,6 +69,36 @@ GNUNET_DHT_disconnect (struct GNUNET_DHT_Handle *h); | |||
66 | 69 | ||
67 | 70 | ||
68 | /** | 71 | /** |
72 | * Perform a PUT operation on the DHT identified by 'table' storing | ||
73 | * a binding of 'key' to 'value'. The peer does not have to be part | ||
74 | * of the table (if so, we will attempt to locate a peer that is!) | ||
75 | * | ||
76 | * @param h handle to DHT service | ||
77 | * @param key the key to store under | ||
78 | * @param type type of the value | ||
79 | * @param size number of bytes in data; must be less than 64k | ||
80 | * @param data the data to store | ||
81 | * @param exp desired expiration time for the value | ||
82 | * @param timeout when to abort with an error if we fail to get | ||
83 | * a confirmation for the PUT from the local DHT service | ||
84 | * @param cont continuation to call when done; | ||
85 | * reason will be TIMEOUT on error, | ||
86 | * reason will be PREREQ_DONE on success | ||
87 | * @param cont_cls closure for cont | ||
88 | */ | ||
89 | void | ||
90 | GNUNET_DHT_put (struct GNUNET_DHT_Handle *h, | ||
91 | const GNUNET_HashCode * key, | ||
92 | uint32_t type, | ||
93 | uint32_t size, | ||
94 | const char *data, | ||
95 | struct GNUNET_TIME_Absolute exp, | ||
96 | struct GNUNET_TIME_Relative timeout, | ||
97 | GNUNET_SCHEDULER_Task cont, | ||
98 | void *cont_cls); | ||
99 | |||
100 | |||
101 | /** | ||
69 | * Handle to control a GET operation. | 102 | * Handle to control a GET operation. |
70 | */ | 103 | */ |
71 | struct GNUNET_DHT_GetHandle; | 104 | struct GNUNET_DHT_GetHandle; |
@@ -99,7 +132,7 @@ typedef void (*GNUNET_DHT_Iterator)(void *cls, | |||
99 | * @param key the key to look up | 132 | * @param key the key to look up |
100 | * @param iter function to call on each result | 133 | * @param iter function to call on each result |
101 | * @param iter_cls closure for iter | 134 | * @param iter_cls closure for iter |
102 | * @return handle to stop the async get | 135 | * @return handle to stop the async get, NULL on error |
103 | */ | 136 | */ |
104 | struct GNUNET_DHT_GetHandle * | 137 | struct GNUNET_DHT_GetHandle * |
105 | GNUNET_DHT_get_start (struct GNUNET_DHT_Handle *h, | 138 | GNUNET_DHT_get_start (struct GNUNET_DHT_Handle *h, |
@@ -108,69 +141,81 @@ GNUNET_DHT_get_start (struct GNUNET_DHT_Handle *h, | |||
108 | GNUNET_DHT_Iterator iter, | 141 | GNUNET_DHT_Iterator iter, |
109 | void *iter_cls); | 142 | void *iter_cls); |
110 | 143 | ||
144 | /** | ||
145 | * Stop async DHT-get. Frees associated resources. | ||
146 | * | ||
147 | * @param get_handle GET operation to stop. | ||
148 | */ | ||
149 | void | ||
150 | GNUNET_DHT_get_stop (struct GNUNET_DHT_GetHandle *get_handle); | ||
151 | |||
111 | 152 | ||
112 | /** | 153 | /** |
113 | * Iterator called on each result obtained from a FIND_PEER | 154 | * Iterator called on each result obtained from a FIND_PEER |
114 | * operation | 155 | * operation |
115 | * | 156 | * |
116 | * @param cls closure | 157 | * @param cls closure |
117 | * @param key the key that was searched | 158 | * @param peer a peer that was located |
118 | * @param data the HELLO of the peer that was returned | 159 | * @param reply response generated by the peer (for example, a HELLO); or NULL |
119 | */ | 160 | */ |
120 | typedef void (*GNUNET_DHT_PeerIterator)(void *cls, | 161 | typedef void (*GNUNET_DHT_ReplyProcessor)(void *cls, |
121 | const GNUNET_HashCode * key, | 162 | const struct GNUNET_PeerIdentity *peer, |
122 | const void *data); | 163 | const struct GNUNET_MessageHeader *reply); |
123 | 164 | ||
124 | /** | ||
125 | * Perform an asynchronous FIND_PEER operation on the DHT. | ||
126 | * | ||
127 | * @param h handle to the DHT service | ||
128 | * @param key the key to look up | ||
129 | * @param iter function to call on each result | ||
130 | * @param iter_cls closure for iter | ||
131 | * | ||
132 | * @return handle to stop the request | ||
133 | */ | ||
134 | struct GNUNET_DHT_GetHandle * | ||
135 | GNUNET_DHT_find_peer_start (struct GNUNET_DHT_Handle *h, | ||
136 | const GNUNET_HashCode * key, | ||
137 | GNUNET_DHT_PeerIterator iter, | ||
138 | void *iter_cls); | ||
139 | 165 | ||
140 | /** | 166 | /** |
141 | * Stop async DHT-get. Frees associated resources. | 167 | * Options for routing. |
142 | * | ||
143 | * @param record GET operation to stop. | ||
144 | */ | 168 | */ |
145 | void | 169 | enum GNUNET_DHT_RouteOption |
146 | GNUNET_DHT_get_stop (struct GNUNET_DHT_Handle *handle, struct GNUNET_DHT_GetHandle *get_handle); | 170 | { |
171 | /** | ||
172 | * Default. Do nothing special. | ||
173 | */ | ||
174 | GNUNET_DHT_RO_NONE = 0, | ||
175 | |||
176 | /** | ||
177 | * Each peer along the way should look at 'enc' (otherwise | ||
178 | * only the k-peers closest to the key should look at it). | ||
179 | */ | ||
180 | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE = 1 | ||
181 | }; | ||
147 | 182 | ||
148 | 183 | ||
149 | /** | 184 | /** |
150 | * Perform a PUT operation on the DHT identified by 'table' storing | 185 | * Perform an asynchronous FIND_PEER operation on the DHT. |
151 | * a binding of 'key' to 'value'. The peer does not have to be part | ||
152 | * of the table (if so, we will attempt to locate a peer that is!) | ||
153 | * | 186 | * |
154 | * @param h handle to DHT service | 187 | * @param h handle to the DHT service |
155 | * @param key the key to store under | 188 | * @param key the key to look up |
156 | * @param type type of the value | 189 | * @param desired_replication_level how many peers should ultimately receive |
157 | * @param size number of bytes in data; must be less than 64k | 190 | * this message (advisory only, target may be too high for the |
158 | * @param data the data to store | 191 | * given DHT or not hit exactly). |
159 | * @param exp desired expiration time for the value | 192 | * @param options options for routing |
193 | * @param enc send the encapsulated message to a peer close to the key | ||
194 | * @param iter function to call on each result, NULL if no replies are expected | ||
195 | * @param iter_cls closure for iter | ||
196 | * @param timeout when to abort with an error if we fail to get | ||
197 | * a confirmation for the PUT from the local DHT service | ||
160 | * @param cont continuation to call when done; | 198 | * @param cont continuation to call when done; |
161 | * reason will be TIMEOUT on error, | 199 | * reason will be TIMEOUT on error, |
162 | * reason will be PREREQ_DONE on success | 200 | * reason will be PREREQ_DONE on success |
163 | * @param cont_cls closure for cont | 201 | * @param cont_cls closure for cont |
164 | * | 202 | * @return handle to stop the request |
165 | */ | 203 | */ |
166 | int GNUNET_DHT_put (struct GNUNET_DHT_Handle *h, | 204 | struct GNUNET_DHT_FindPeerHandle * |
167 | const GNUNET_HashCode * key, | 205 | GNUNET_DHT_route_start (struct GNUNET_DHT_Handle *h, |
168 | uint32_t type, | 206 | const GNUNET_HashCode *key, |
169 | uint32_t size, | 207 | unsigned int desired_replication_level, |
170 | const char *data, | 208 | enum GNUNET_DHT_RouteOption options, |
171 | struct GNUNET_TIME_Relative exp, | 209 | const struct GNUNET_MessageHeader *enc, |
172 | GNUNET_SCHEDULER_Task cont, | 210 | struct GNUNET_TIME_Relative timeout, |
173 | void *cont_cls); | 211 | GNUNET_DHT_ReplyProcessor iter, |
212 | void *iter_cls, | ||
213 | struct GNUNET_TIME_Relative timeout, | ||
214 | GNUNET_SCHEDULER_Task cont, | ||
215 | void *cont_cls); | ||
216 | |||
217 | void | ||
218 | GNUNET_DHT_route_stop (struct GNUNET_DHT_FindPeerHandle *fph); | ||
174 | 219 | ||
175 | 220 | ||
176 | #if 0 /* keep Emacsens' auto-indent happy */ | 221 | #if 0 /* keep Emacsens' auto-indent happy */ |