gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r16149 - gnunet/src/nse


From: gnunet
Subject: [GNUnet-SVN] r16149 - gnunet/src/nse
Date: Sat, 23 Jul 2011 16:19:10 +0200

Author: grothoff
Date: 2011-07-23 16:19:09 +0200 (Sat, 23 Jul 2011)
New Revision: 16149

Modified:
   gnunet/src/nse/gnunet-service-nse.c
Log:
fixes

Modified: gnunet/src/nse/gnunet-service-nse.c
===================================================================
--- gnunet/src/nse/gnunet-service-nse.c 2011-07-23 13:23:40 UTC (rev 16148)
+++ gnunet/src/nse/gnunet-service-nse.c 2011-07-23 14:19:09 UTC (rev 16149)
@@ -643,20 +643,20 @@
 
 
 /**
- * Count the trailing zeroes in hash.
+ * Count the leading zeroes in hash.
  *
  * @param hash
- * @return the number of trailing zero bits.
+ * @return the number of leading zero bits.
  */
 static unsigned int 
-count_trailing_zeroes(const GNUNET_HashCode *hash)
+count_leading_zeroes(const GNUNET_HashCode *hash)
 {
   unsigned int hash_count;
   
-  hash_count = sizeof(GNUNET_HashCode) * 8;
+  hash_count = 0;
   while ((0 == GNUNET_CRYPTO_hash_get_bit(hash, hash_count)))
-    hash_count--;
-  return (sizeof(GNUNET_HashCode) * 8) - hash_count;
+    hash_count++;
+  return hash_count;
 }
 
 
@@ -683,13 +683,13 @@
          pkey, 
          sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded));
   GNUNET_CRYPTO_hash (buf, sizeof (buf), &result);
-  return (count_trailing_zeroes (&result) >= NSE_WORK_REQUIRED) ? GNUNET_YES : 
GNUNET_NO;
+  return (count_leading_zeroes (&result) >= NSE_WORK_REQUIRED) ? GNUNET_YES : 
GNUNET_NO;
 }
 
 
 /**
  * Given a public key, find an integer such that the hash of the key
- * concatenated with the integer has NSE_WORK_REQUIRED trailing 0
+ * concatenated with the integer has NSE_WORK_REQUIRED leading 0
  * bits.  FIXME: this is a synchronous function... bad
  *
  * @param pkey the public key
@@ -712,7 +712,7 @@
              &counter, 
              sizeof(uint64_t));
       GNUNET_CRYPTO_hash (buf, sizeof (buf), &result);
-      if (NSE_WORK_REQUIRED <= count_trailing_zeroes(&result))
+      if (NSE_WORK_REQUIRED <= count_leading_zeroes(&result))
         break;
       counter++;
     }
@@ -1131,7 +1131,7 @@
 main(int argc, char * const *argv)
 {
   return (GNUNET_OK == GNUNET_SERVICE_run (argc, argv, 
-                                          "gnunet-service-nse",
+                                          "nse",
                                            GNUNET_SERVICE_OPTION_NONE, &run,
                                            NULL)) ? 0 : 1;
 }




reply via email to

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