gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r22367 - gnunet/src/namestore


From: gnunet
Subject: [GNUnet-SVN] r22367 - gnunet/src/namestore
Date: Thu, 28 Jun 2012 22:02:23 +0200

Author: grothoff
Date: 2012-06-28 22:02:23 +0200 (Thu, 28 Jun 2012)
New Revision: 22367

Modified:
   gnunet/src/namestore/gnunet-service-namestore.c
   gnunet/src/namestore/namestore.h
   gnunet/src/namestore/namestore_api.c
Log:
-more code cleanup in namestore

Modified: gnunet/src/namestore/gnunet-service-namestore.c
===================================================================
--- gnunet/src/namestore/gnunet-service-namestore.c     2012-06-28 19:42:01 UTC 
(rev 22366)
+++ gnunet/src/namestore/gnunet-service-namestore.c     2012-06-28 20:02:23 UTC 
(rev 22367)
@@ -1254,7 +1254,7 @@
   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 @@
   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 @@
                                      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 @@
                                &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 @@
   {
     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 @@
                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
   {

Modified: gnunet/src/namestore/namestore.h
===================================================================
--- gnunet/src/namestore/namestore.h    2012-06-28 19:42:01 UTC (rev 22366)
+++ gnunet/src/namestore/namestore.h    2012-06-28 20:02:23 UTC (rev 22367)
@@ -406,6 +406,32 @@
 
 
 /**
+ * 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 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;
 };

Modified: gnunet/src/namestore/namestore_api.c
===================================================================
--- gnunet/src/namestore/namestore_api.c        2012-06-28 19:42:01 UTC (rev 
22366)
+++ gnunet/src/namestore/namestore_api.c        2012-06-28 20:02:23 UTC (rev 
22367)
@@ -390,41 +390,31 @@
                               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;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]