summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2015-09-22 01:47:36 +0000
committerFlorian Dold <florian.dold@gmail.com>2015-09-22 01:47:36 +0000
commit68e2709a38f9c481f96024138a6f9ae57a280a57 (patch)
tree92fa0952ea1e9c3387194bc54aa06c819a8d2270 /src
parentafc7d17dc798216e89506fb4e66aabb7e0f0077b (diff)
downloadgnunet-68e2709a38f9c481f96024138a6f9ae57a280a57.tar.gz
gnunet-68e2709a38f9c481f96024138a6f9ae57a280a57.zip
set api changes
Diffstat (limited to 'src')
-rw-r--r--src/include/gnunet_set_service.h45
-rw-r--r--src/set/gnunet-service-set_union.c9
-rw-r--r--src/set/gnunet-set-profiler.c4
-rw-r--r--src/set/set_api.c2
4 files changed, 51 insertions, 9 deletions
diff --git a/src/include/gnunet_set_service.h b/src/include/gnunet_set_service.h
index 1000aea7b..f9ae122b4 100644
--- a/src/include/gnunet_set_service.h
+++ b/src/include/gnunet_set_service.h
@@ -99,10 +99,33 @@ enum GNUNET_SET_Status
99 * Everything went ok, we are transmitting an element of the 99 * Everything went ok, we are transmitting an element of the
100 * result (in set, or to be removed from set, depending on 100 * result (in set, or to be removed from set, depending on
101 * the `enum GNUNET_SET_ResultMode`). 101 * the `enum GNUNET_SET_ResultMode`).
102 *
103 * Only applies to
104 * #GNUNET_SET_RESULT_FULL,
105 * #GNUNET_SET_RESULT_ADDED,
106 * #GNUNET_SET_RESULT_REMOVED,
102 */ 107 */
103 GNUNET_SET_STATUS_OK, 108 GNUNET_SET_STATUS_OK,
104 109
105 /** 110 /**
111 * Element should be added to the result set
112 * of the local peer, i.e. the local peer is
113 * missing an element.
114 *
115 * Only applies to #GNUNET_SET_RESULT_SYMMETRIC
116 */
117 GNUNET_SET_STATUS_ADD_LOCAL,
118
119 /**
120 * Element should be added to the result set
121 * of the remove peer, i.e. the remote peer is
122 * missing an element.
123 *
124 * Only applies to #GNUNET_SET_RESULT_SYMMETRIC
125 */
126 GNUNET_SET_STATUS_ADD_REMOTE,
127
128 /**
106 * The other peer refused to to the operation with us, 129 * The other peer refused to to the operation with us,
107 * or something went wrong. 130 * or something went wrong.
108 */ 131 */
@@ -129,20 +152,32 @@ enum GNUNET_SET_ResultMode
129{ 152{
130 /** 153 /**
131 * Client gets every element in the resulting set. 154 * Client gets every element in the resulting set.
155 *
156 * Only supported for set intersection.
132 */ 157 */
133 GNUNET_SET_RESULT_FULL, 158 GNUNET_SET_RESULT_FULL,
134 159
135 /** 160 /**
136 * Client gets only elements that have been added to the set. 161 * Client gets notified of the required changes
137 * Only works with set union. 162 * for both the local and the remote set.
163 *
164 * Only supported for set
165 */
166 GNUNET_SET_RESULT_SYMMETRIC,
167
168 /**
169 * Client gets only elements that have been removed from the set.
170 *
171 * Only supported for set intersection.
138 */ 172 */
139 GNUNET_SET_RESULT_ADDED, 173 GNUNET_SET_RESULT_REMOVED,
140 174
141 /** 175 /**
142 * Client gets only elements that have been removed from the set. 176 * Client gets only elements that have been removed from the set.
143 * Only works with set intersection. 177 *
178 * Only supported for set union.
144 */ 179 */
145 GNUNET_SET_RESULT_REMOVED 180 GNUNET_SET_RESULT_ADDED
146}; 181};
147 182
148 183
diff --git a/src/set/gnunet-service-set_union.c b/src/set/gnunet-service-set_union.c
index 5975ef19f..5b452cae1 100644
--- a/src/set/gnunet-service-set_union.c
+++ b/src/set/gnunet-service-set_union.c
@@ -1003,7 +1003,12 @@ send_client_element (struct Operation *op,
1003 GNUNET_break (0); 1003 GNUNET_break (0);
1004 return; 1004 return;
1005 } 1005 }
1006 rm->result_status = htons (GNUNET_SET_STATUS_OK); 1006
1007 if (GNUNET_SET_RESULT_ADDED == op->spec->result_mode)
1008 rm->result_status = htons (GNUNET_SET_STATUS_OK);
1009 else if (GNUNET_SET_RESULT_SYMMETRIC == op->spec->result_mode)
1010 rm->result_status = htons (GNUNET_SET_STATUS_ADD_LOCAL);
1011
1007 rm->request_id = htonl (op->spec->client_request_id); 1012 rm->request_id = htonl (op->spec->client_request_id);
1008 rm->element_type = element->element_type; 1013 rm->element_type = element->element_type;
1009 memcpy (&rm[1], element->data, element->size); 1014 memcpy (&rm[1], element->data, element->size);
@@ -1167,7 +1172,7 @@ handle_p2p_elements (void *cls,
1167 1172
1168 op_register_element (op, ee); 1173 op_register_element (op, ee);
1169 /* only send results immediately if the client wants it */ 1174 /* only send results immediately if the client wants it */
1170 if (GNUNET_SET_RESULT_ADDED == op->spec->result_mode) 1175 if (GNUNET_SET_RESULT_FULL != op->spec->result_mode)
1171 send_client_element (op, &ee->element); 1176 send_client_element (op, &ee->element);
1172} 1177}
1173 1178
diff --git a/src/set/gnunet-set-profiler.c b/src/set/gnunet-set-profiler.c
index 286cc6fb3..1569c29b7 100644
--- a/src/set/gnunet-set-profiler.c
+++ b/src/set/gnunet-set-profiler.c
@@ -150,7 +150,7 @@ set_listen_cb (void *cls,
150 GNUNET_assert (NULL == info2.oh); 150 GNUNET_assert (NULL == info2.oh);
151 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 151 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
152 "set listen cb called\n"); 152 "set listen cb called\n");
153 info2.oh = GNUNET_SET_accept (request, GNUNET_SET_RESULT_ADDED, 153 info2.oh = GNUNET_SET_accept (request, GNUNET_SET_RESULT_SYMMETRIC,
154 set_result_cb, &info2); 154 set_result_cb, &info2);
155 GNUNET_SET_commit (info2.oh, info2.set); 155 GNUNET_SET_commit (info2.oh, info2.set);
156} 156}
@@ -273,7 +273,7 @@ run (void *cls, char *const *args, const char *cfgfile,
273 &app_id, set_listen_cb, NULL); 273 &app_id, set_listen_cb, NULL);
274 274
275 info1.oh = GNUNET_SET_prepare (&local_peer, &app_id, NULL, 275 info1.oh = GNUNET_SET_prepare (&local_peer, &app_id, NULL,
276 GNUNET_SET_RESULT_ADDED, 276 GNUNET_SET_RESULT_SYMMETRIC,
277 set_result_cb, &info1); 277 set_result_cb, &info1);
278 GNUNET_SET_commit (info1.oh, info1.set); 278 GNUNET_SET_commit (info1.oh, info1.set);
279 GNUNET_SET_destroy (info1.set); 279 GNUNET_SET_destroy (info1.set);
diff --git a/src/set/set_api.c b/src/set/set_api.c
index 920571a01..51a494d7f 100644
--- a/src/set/set_api.c
+++ b/src/set/set_api.c
@@ -417,6 +417,8 @@ handle_result (void *cls,
417 switch (result_status) 417 switch (result_status)
418 { 418 {
419 case GNUNET_SET_STATUS_OK: 419 case GNUNET_SET_STATUS_OK:
420 case GNUNET_SET_STATUS_ADD_LOCAL:
421 case GNUNET_SET_STATUS_ADD_REMOTE:
420 break; 422 break;
421 case GNUNET_SET_STATUS_FAILURE: 423 case GNUNET_SET_STATUS_FAILURE:
422 oh->result_cb = NULL; 424 oh->result_cb = NULL;