aboutsummaryrefslogtreecommitdiff
path: root/src/namestore/namestore_api.c
diff options
context:
space:
mode:
authorMartin Schanzenbach <schanzen@gnunet.org>2022-09-23 14:57:57 +0900
committerMartin Schanzenbach <schanzen@gnunet.org>2022-09-23 14:57:57 +0900
commit7678d77b1cb0dcfd8887016d35b27fbedb136050 (patch)
treed2755d9f5f184e958f8259ed11bde6991d1bc273 /src/namestore/namestore_api.c
parent8ecf052b2976ee8148b20013b45114ba32e8cd78 (diff)
downloadgnunet-7678d77b1cb0dcfd8887016d35b27fbedb136050.tar.gz
gnunet-7678d77b1cb0dcfd8887016d35b27fbedb136050.zip
NAMESTORE: Add select ... for update / edit records APIs
Diffstat (limited to 'src/namestore/namestore_api.c')
-rw-r--r--src/namestore/namestore_api.c51
1 files changed, 24 insertions, 27 deletions
diff --git a/src/namestore/namestore_api.c b/src/namestore/namestore_api.c
index 26e1477f4..d5591378b 100644
--- a/src/namestore/namestore_api.c
+++ b/src/namestore/namestore_api.c
@@ -1158,32 +1158,16 @@ GNUNET_NAMESTORE_records_store (
1158 return qe; 1158 return qe;
1159} 1159}
1160 1160
1161/** 1161static struct GNUNET_NAMESTORE_QueueEntry *
1162 * TODO: Experimental API will replace API above. 1162records_lookup (
1163 */
1164struct GNUNET_NAMESTORE_QueueEntry *
1165GNUNET_NAMESTORE_records_replace (
1166 struct GNUNET_NAMESTORE_Handle *h,
1167 const struct GNUNET_IDENTITY_PrivateKey *pkey,
1168 const char *label,
1169 unsigned int rd_count,
1170 const struct GNUNET_GNSRECORD_Data *rd,
1171 GNUNET_NAMESTORE_ContinuationWithStatus cont,
1172 void *cont_cls)
1173{
1174 return GNUNET_NAMESTORE_records_store (h, pkey, label, rd_count, rd,
1175 cont, cont_cls);
1176}
1177
1178struct GNUNET_NAMESTORE_QueueEntry *
1179GNUNET_NAMESTORE_records_lookup (
1180 struct GNUNET_NAMESTORE_Handle *h, 1163 struct GNUNET_NAMESTORE_Handle *h,
1181 const struct GNUNET_IDENTITY_PrivateKey *pkey, 1164 const struct GNUNET_IDENTITY_PrivateKey *pkey,
1182 const char *label, 1165 const char *label,
1183 GNUNET_SCHEDULER_TaskCallback error_cb, 1166 GNUNET_SCHEDULER_TaskCallback error_cb,
1184 void *error_cb_cls, 1167 void *error_cb_cls,
1185 GNUNET_NAMESTORE_RecordMonitor rm, 1168 GNUNET_NAMESTORE_RecordMonitor rm,
1186 void *rm_cls) 1169 void *rm_cls,
1170 int is_edit_request)
1187{ 1171{
1188 struct GNUNET_NAMESTORE_QueueEntry *qe; 1172 struct GNUNET_NAMESTORE_QueueEntry *qe;
1189 struct GNUNET_MQ_Envelope *env; 1173 struct GNUNET_MQ_Envelope *env;
@@ -1210,6 +1194,7 @@ GNUNET_NAMESTORE_records_lookup (
1210 GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP); 1194 GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP);
1211 msg->gns_header.r_id = htonl (qe->op_id); 1195 msg->gns_header.r_id = htonl (qe->op_id);
1212 msg->zone = *pkey; 1196 msg->zone = *pkey;
1197 msg->is_edit_request = htonl (is_edit_request);
1213 msg->label_len = htonl (label_len); 1198 msg->label_len = htonl (label_len);
1214 GNUNET_memcpy (&msg[1], label, label_len); 1199 GNUNET_memcpy (&msg[1], label, label_len);
1215 if (NULL == h->mq) 1200 if (NULL == h->mq)
@@ -1219,12 +1204,24 @@ GNUNET_NAMESTORE_records_lookup (
1219 return qe; 1204 return qe;
1220} 1205}
1221 1206
1207struct GNUNET_NAMESTORE_QueueEntry *
1208GNUNET_NAMESTORE_records_lookup (
1209 struct GNUNET_NAMESTORE_Handle *h,
1210 const struct GNUNET_IDENTITY_PrivateKey *pkey,
1211 const char *label,
1212 GNUNET_SCHEDULER_TaskCallback error_cb,
1213 void *error_cb_cls,
1214 GNUNET_NAMESTORE_RecordMonitor rm,
1215 void *rm_cls)
1216{
1217 records_lookup (h, pkey, label,
1218 error_cb, error_cb_cls,
1219 rm, rm_cls, GNUNET_NO);
1220
1221}
1222 1222
1223/**
1224 * TODO experimental API. Will replace old API above.
1225 */
1226struct GNUNET_NAMESTORE_QueueEntry * 1223struct GNUNET_NAMESTORE_QueueEntry *
1227GNUNET_NAMESTORE_records_select ( 1224GNUNET_NAMESTORE_records_edit (
1228 struct GNUNET_NAMESTORE_Handle *h, 1225 struct GNUNET_NAMESTORE_Handle *h,
1229 const struct GNUNET_IDENTITY_PrivateKey *pkey, 1226 const struct GNUNET_IDENTITY_PrivateKey *pkey,
1230 const char *label, 1227 const char *label,
@@ -1233,9 +1230,9 @@ GNUNET_NAMESTORE_records_select (
1233 GNUNET_NAMESTORE_RecordMonitor rm, 1230 GNUNET_NAMESTORE_RecordMonitor rm,
1234 void *rm_cls) 1231 void *rm_cls)
1235{ 1232{
1236 return GNUNET_NAMESTORE_records_lookup (h, pkey, label, 1233 return records_lookup (h, pkey, label,
1237 error_cb, error_cb_cls, 1234 error_cb, error_cb_cls,
1238 rm, rm_cls); 1235 rm, rm_cls, GNUNET_YES);
1239} 1236}
1240 1237
1241struct GNUNET_NAMESTORE_QueueEntry * 1238struct GNUNET_NAMESTORE_QueueEntry *