diff options
author | grothoff <grothoff@140774ce-b5e7-0310-ab8b-a85725594a96> | 2012-06-28 20:02:23 +0000 |
---|---|---|
committer | grothoff <grothoff@140774ce-b5e7-0310-ab8b-a85725594a96> | 2012-06-28 20:02:23 +0000 |
commit | 84fa553c9c1d315dc9e797dfa00ea23e8fc3023e (patch) | |
tree | 228453f6d1764aaac3f829896064ee1bf3c45b92 /src/namestore | |
parent | 3ab1b845100e0f22336b7557d48f4e3d87a569ea (diff) |
-more code cleanup in namestore
git-svn-id: https://gnunet.org/svn/gnunet@22367 140774ce-b5e7-0310-ab8b-a85725594a96
Diffstat (limited to 'src/namestore')
-rw-r--r-- | src/namestore/gnunet-service-namestore.c | 18 | ||||
-rw-r--r-- | src/namestore/namestore.h | 33 | ||||
-rw-r--r-- | src/namestore/namestore_api.c | 22 |
3 files changed, 42 insertions, 31 deletions
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c index 619119725a..3e29ba3895 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, if (0 == rd_count) { /* Could not find record to remove */ - rrc->op_res = 1; + rrc->op_res = RECORD_REMOVE_RESULT_NO_RECORDS; return; } @@ -1281,7 +1281,7 @@ handle_record_remove_it (void *cls, if (GNUNET_SYSERR == found) { /* Could not find record to remove */ - rrc->op_res = 2; + rrc->op_res = RECORD_REMOVE_RESULT_RECORD_NOT_FOUND; return; } @@ -1301,10 +1301,10 @@ handle_record_remove_it (void *cls, name)) { /* Could not remove records from database */ - rrc->op_res = 3; + rrc->op_res = RECORD_REMOVE_RESULT_FAILED_TO_SIGN; /* ??? */ return; } - rrc->op_res = 0; + rrc->op_res = RECORD_REMOVE_RESULT_SUCCESS; return; } @@ -1331,10 +1331,10 @@ handle_record_remove_it (void *cls, &dummy_signature)) { /* Could not put records into database */ - rrc->op_res = 4; + rrc->op_res = RECORD_REMOVE_RESULT_FAILED_TO_PUT_UPDATE; return; } - rrc->op_res = 0; + rrc->op_res = RECORD_REMOVE_RESULT_SUCCESS; } @@ -1429,7 +1429,7 @@ handle_record_remove (void *cls, { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received new private key for zone `%s'\n", - GNUNET_short_h2s(&pubkey_hash)); + GNUNET_short_h2s (&pubkey_hash)); cc = GNUNET_malloc (sizeof (struct GNUNET_NAMESTORE_CryptoContainer)); cc->privkey = GNUNET_CRYPTO_rsa_decode_key (pkey_tmp, key_len); cc->zone = pubkey_hash; @@ -1458,9 +1458,9 @@ handle_record_remove (void *cls, name_tmp, (GNUNET_OK == res) ? "OK" : "FAIL"); if (GNUNET_OK != res) /* Could not remove entry from database */ - res = 4; + res = RECORD_REMOVE_RESULT_FAILED_TO_PUT_UPDATE; else - res = 0; + res = RECORD_REMOVE_RESULT_SUCCESS; } else { diff --git a/src/namestore/namestore.h b/src/namestore/namestore.h index 8968abdf21..c86a2513b8 100644 --- a/src/namestore/namestore.h +++ b/src/namestore/namestore.h @@ -406,6 +406,32 @@ struct RecordRemoveMessage /** + * Removal of the record succeeded. + */ +#define RECORD_REMOVE_RESULT_SUCCESS 0 + +/** + * There are NO records for the given name. + */ +#define RECORD_REMOVE_RESULT_NO_RECORDS 1 + +/** + * The specific record that was to be removed was + * not found. + */ +#define RECORD_REMOVE_RESULT_RECORD_NOT_FOUND 2 + +/** + * Internal error, failed to sign the remaining records. + */ +#define RECORD_REMOVE_RESULT_FAILED_TO_SIGN 3 + +/** + * Internal error, failed to store the updated record set + */ +#define RECORD_REMOVE_RESULT_FAILED_TO_PUT_UPDATE 4 + +/** * Remove a record from the namestore response */ struct RecordRemoveResponseMessage @@ -416,12 +442,7 @@ struct RecordRemoveResponseMessage struct GNUNET_NAMESTORE_Header gns_header; /** - * result: - * 0 : successful - * 1 : no records for entry - * 2 : Could not find record to remove - * 3 : Failed to create new signature - * 4 : Failed to put new set of records in database + * Result code (see RECORD_REMOVE_RESULT_*). In network byte order. */ int32_t op_result; }; diff --git a/src/namestore/namestore_api.c b/src/namestore/namestore_api.c index 3447dda446..34c83f0b4b 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, const struct RecordRemoveResponseMessage* msg, size_t size) { - int res; int ret; const char *emsg; /* Operation done, remove */ LOG (GNUNET_ERROR_TYPE_DEBUG, "Received `%s'\n", "RECORD_REMOVE_RESPONSE"); - /* - * results: - * 0 : successful - * 1 : No records for entry - * 2 : Could not find record to remove - * 3 : Failed to create new signature - * 4 : Failed to put new set of records in database - */ - res = ntohl (msg->op_result); - switch (res) + switch (ntohl (msg->op_result)) { - case 0: + case RECORD_REMOVE_RESULT_SUCCESS: ret = GNUNET_OK; emsg = NULL; break; - case 1: + case RECORD_REMOVE_RESULT_NO_RECORDS: ret = GNUNET_NO; emsg = NULL; break; - case 2: + case RECORD_REMOVE_RESULT_RECORD_NOT_FOUND: ret = GNUNET_NO; emsg = NULL; break; - case 3: + case RECORD_REMOVE_RESULT_FAILED_TO_SIGN: ret = GNUNET_SYSERR; emsg = _("Failed to create new signature"); break; - case 4: + case RECORD_REMOVE_RESULT_FAILED_TO_PUT_UPDATE: ret = GNUNET_SYSERR; emsg = _("Failed to put new set of records in database"); break; |