-more code cleanup in namestore
authorChristian Grothoff <christian@grothoff.org>
Thu, 28 Jun 2012 20:02:23 +0000 (20:02 +0000)
committerChristian Grothoff <christian@grothoff.org>
Thu, 28 Jun 2012 20:02:23 +0000 (20:02 +0000)
src/namestore/gnunet-service-namestore.c
src/namestore/namestore.h
src/namestore/namestore_api.c

index 619119725afbc55c23c0a4e479d8da6e2fafb9cc..3e29ba38958c2998aa91054792734298a52a5b6e 100644 (file)
@@ -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
   {
index 8968abdf215e40f27ae9ad6e0505491d2f1314e5..c86a2513b80624d04342fed6d8634a82cb55f19a 100644 (file)
@@ -405,6 +405,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
  */
@@ -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;
 };
index 3447dda446c0990107c227f12d69359b5103b5c4..34c83f0b4b6df8771821586cab5cb97a8e17a050 100644 (file)
@@ -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;