aboutsummaryrefslogtreecommitdiff
path: root/src/namestore
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-06-28 20:02:23 +0000
committerChristian Grothoff <christian@grothoff.org>2012-06-28 20:02:23 +0000
commit8113ba1371bfd97a4a09c47b070e8f4425ba10a9 (patch)
tree228453f6d1764aaac3f829896064ee1bf3c45b92 /src/namestore
parent3d1275946f7264fbd3baecfecddb3fd2e3a4fe57 (diff)
downloadgnunet-8113ba1371bfd97a4a09c47b070e8f4425ba10a9.tar.gz
gnunet-8113ba1371bfd97a4a09c47b070e8f4425ba10a9.zip
-more code cleanup in namestore
Diffstat (limited to 'src/namestore')
-rw-r--r--src/namestore/gnunet-service-namestore.c18
-rw-r--r--src/namestore/namestore.h33
-rw-r--r--src/namestore/namestore_api.c22
3 files changed, 42 insertions, 31 deletions
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c
index 619119725..3e29ba389 100644
--- a/src/namestore/gnunet-service-namestore.c
+++ b/src/namestore/gnunet-service-namestore.c
@@ -1254,7 +1254,7 @@ handle_record_remove_it (void *cls,
1254 if (0 == rd_count) 1254 if (0 == rd_count)
1255 { 1255 {
1256 /* Could not find record to remove */ 1256 /* Could not find record to remove */
1257 rrc->op_res = 1; 1257 rrc->op_res = RECORD_REMOVE_RESULT_NO_RECORDS;
1258 return; 1258 return;
1259 } 1259 }
1260 1260
@@ -1281,7 +1281,7 @@ handle_record_remove_it (void *cls,
1281 if (GNUNET_SYSERR == found) 1281 if (GNUNET_SYSERR == found)
1282 { 1282 {
1283 /* Could not find record to remove */ 1283 /* Could not find record to remove */
1284 rrc->op_res = 2; 1284 rrc->op_res = RECORD_REMOVE_RESULT_RECORD_NOT_FOUND;
1285 return; 1285 return;
1286 } 1286 }
1287 1287
@@ -1301,10 +1301,10 @@ handle_record_remove_it (void *cls,
1301 name)) 1301 name))
1302 { 1302 {
1303 /* Could not remove records from database */ 1303 /* Could not remove records from database */
1304 rrc->op_res = 3; 1304 rrc->op_res = RECORD_REMOVE_RESULT_FAILED_TO_SIGN; /* ??? */
1305 return; 1305 return;
1306 } 1306 }
1307 rrc->op_res = 0; 1307 rrc->op_res = RECORD_REMOVE_RESULT_SUCCESS;
1308 return; 1308 return;
1309 } 1309 }
1310 1310
@@ -1331,10 +1331,10 @@ handle_record_remove_it (void *cls,
1331 &dummy_signature)) 1331 &dummy_signature))
1332 { 1332 {
1333 /* Could not put records into database */ 1333 /* Could not put records into database */
1334 rrc->op_res = 4; 1334 rrc->op_res = RECORD_REMOVE_RESULT_FAILED_TO_PUT_UPDATE;
1335 return; 1335 return;
1336 } 1336 }
1337 rrc->op_res = 0; 1337 rrc->op_res = RECORD_REMOVE_RESULT_SUCCESS;
1338} 1338}
1339 1339
1340 1340
@@ -1429,7 +1429,7 @@ handle_record_remove (void *cls,
1429 { 1429 {
1430 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1430 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1431 "Received new private key for zone `%s'\n", 1431 "Received new private key for zone `%s'\n",
1432 GNUNET_short_h2s(&pubkey_hash)); 1432 GNUNET_short_h2s (&pubkey_hash));
1433 cc = GNUNET_malloc (sizeof (struct GNUNET_NAMESTORE_CryptoContainer)); 1433 cc = GNUNET_malloc (sizeof (struct GNUNET_NAMESTORE_CryptoContainer));
1434 cc->privkey = GNUNET_CRYPTO_rsa_decode_key (pkey_tmp, key_len); 1434 cc->privkey = GNUNET_CRYPTO_rsa_decode_key (pkey_tmp, key_len);
1435 cc->zone = pubkey_hash; 1435 cc->zone = pubkey_hash;
@@ -1458,9 +1458,9 @@ handle_record_remove (void *cls,
1458 name_tmp, (GNUNET_OK == res) ? "OK" : "FAIL"); 1458 name_tmp, (GNUNET_OK == res) ? "OK" : "FAIL");
1459 if (GNUNET_OK != res) 1459 if (GNUNET_OK != res)
1460 /* Could not remove entry from database */ 1460 /* Could not remove entry from database */
1461 res = 4; 1461 res = RECORD_REMOVE_RESULT_FAILED_TO_PUT_UPDATE;
1462 else 1462 else
1463 res = 0; 1463 res = RECORD_REMOVE_RESULT_SUCCESS;
1464 } 1464 }
1465 else 1465 else
1466 { 1466 {
diff --git a/src/namestore/namestore.h b/src/namestore/namestore.h
index 8968abdf2..c86a2513b 100644
--- a/src/namestore/namestore.h
+++ b/src/namestore/namestore.h
@@ -406,6 +406,32 @@ struct RecordRemoveMessage
406 406
407 407
408/** 408/**
409 * Removal of the record succeeded.
410 */
411#define RECORD_REMOVE_RESULT_SUCCESS 0
412
413/**
414 * There are NO records for the given name.
415 */
416#define RECORD_REMOVE_RESULT_NO_RECORDS 1
417
418/**
419 * The specific record that was to be removed was
420 * not found.
421 */
422#define RECORD_REMOVE_RESULT_RECORD_NOT_FOUND 2
423
424/**
425 * Internal error, failed to sign the remaining records.
426 */
427#define RECORD_REMOVE_RESULT_FAILED_TO_SIGN 3
428
429/**
430 * Internal error, failed to store the updated record set
431 */
432#define RECORD_REMOVE_RESULT_FAILED_TO_PUT_UPDATE 4
433
434/**
409 * Remove a record from the namestore response 435 * Remove a record from the namestore response
410 */ 436 */
411struct RecordRemoveResponseMessage 437struct RecordRemoveResponseMessage
@@ -416,12 +442,7 @@ struct RecordRemoveResponseMessage
416 struct GNUNET_NAMESTORE_Header gns_header; 442 struct GNUNET_NAMESTORE_Header gns_header;
417 443
418 /** 444 /**
419 * result: 445 * Result code (see RECORD_REMOVE_RESULT_*). In network byte order.
420 * 0 : successful
421 * 1 : no records for entry
422 * 2 : Could not find record to remove
423 * 3 : Failed to create new signature
424 * 4 : Failed to put new set of records in database
425 */ 446 */
426 int32_t op_result; 447 int32_t op_result;
427}; 448};
diff --git a/src/namestore/namestore_api.c b/src/namestore/namestore_api.c
index 3447dda44..34c83f0b4 100644
--- a/src/namestore/namestore_api.c
+++ b/src/namestore/namestore_api.c
@@ -390,41 +390,31 @@ handle_record_remove_response (struct GNUNET_NAMESTORE_QueueEntry *qe,
390 const struct RecordRemoveResponseMessage* msg, 390 const struct RecordRemoveResponseMessage* msg,
391 size_t size) 391 size_t size)
392{ 392{
393 int res;
394 int ret; 393 int ret;
395 const char *emsg; 394 const char *emsg;
396 395
397 /* Operation done, remove */ 396 /* Operation done, remove */
398 LOG (GNUNET_ERROR_TYPE_DEBUG, "Received `%s'\n", 397 LOG (GNUNET_ERROR_TYPE_DEBUG, "Received `%s'\n",
399 "RECORD_REMOVE_RESPONSE"); 398 "RECORD_REMOVE_RESPONSE");
400 /* 399 switch (ntohl (msg->op_result))
401 * results:
402 * 0 : successful
403 * 1 : No records for entry
404 * 2 : Could not find record to remove
405 * 3 : Failed to create new signature
406 * 4 : Failed to put new set of records in database
407 */
408 res = ntohl (msg->op_result);
409 switch (res)
410 { 400 {
411 case 0: 401 case RECORD_REMOVE_RESULT_SUCCESS:
412 ret = GNUNET_OK; 402 ret = GNUNET_OK;
413 emsg = NULL; 403 emsg = NULL;
414 break; 404 break;
415 case 1: 405 case RECORD_REMOVE_RESULT_NO_RECORDS:
416 ret = GNUNET_NO; 406 ret = GNUNET_NO;
417 emsg = NULL; 407 emsg = NULL;
418 break; 408 break;
419 case 2: 409 case RECORD_REMOVE_RESULT_RECORD_NOT_FOUND:
420 ret = GNUNET_NO; 410 ret = GNUNET_NO;
421 emsg = NULL; 411 emsg = NULL;
422 break; 412 break;
423 case 3: 413 case RECORD_REMOVE_RESULT_FAILED_TO_SIGN:
424 ret = GNUNET_SYSERR; 414 ret = GNUNET_SYSERR;
425 emsg = _("Failed to create new signature"); 415 emsg = _("Failed to create new signature");
426 break; 416 break;
427 case 4: 417 case RECORD_REMOVE_RESULT_FAILED_TO_PUT_UPDATE:
428 ret = GNUNET_SYSERR; 418 ret = GNUNET_SYSERR;
429 emsg = _("Failed to put new set of records in database"); 419 emsg = _("Failed to put new set of records in database");
430 break; 420 break;