aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-07-23 14:19:09 +0000
committerChristian Grothoff <christian@grothoff.org>2011-07-23 14:19:09 +0000
commit924311893e9ea66d32edd0d477ba32c8861b3528 (patch)
tree4eb4c30c1cfbbf1b0f5c40801e5b77a49a28dbe7 /src
parentf53e991a59f4befa47b0ce90d8b68318dcd23864 (diff)
downloadgnunet-924311893e9ea66d32edd0d477ba32c8861b3528.tar.gz
gnunet-924311893e9ea66d32edd0d477ba32c8861b3528.zip
fixes
Diffstat (limited to 'src')
-rw-r--r--src/nse/gnunet-service-nse.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/nse/gnunet-service-nse.c b/src/nse/gnunet-service-nse.c
index 6128300dd..2d323a36a 100644
--- a/src/nse/gnunet-service-nse.c
+++ b/src/nse/gnunet-service-nse.c
@@ -643,20 +643,20 @@ update_flood_message(void *cls,
643 643
644 644
645/** 645/**
646 * Count the trailing zeroes in hash. 646 * Count the leading zeroes in hash.
647 * 647 *
648 * @param hash 648 * @param hash
649 * @return the number of trailing zero bits. 649 * @return the number of leading zero bits.
650 */ 650 */
651static unsigned int 651static unsigned int
652count_trailing_zeroes(const GNUNET_HashCode *hash) 652count_leading_zeroes(const GNUNET_HashCode *hash)
653{ 653{
654 unsigned int hash_count; 654 unsigned int hash_count;
655 655
656 hash_count = sizeof(GNUNET_HashCode) * 8; 656 hash_count = 0;
657 while ((0 == GNUNET_CRYPTO_hash_get_bit(hash, hash_count))) 657 while ((0 == GNUNET_CRYPTO_hash_get_bit(hash, hash_count)))
658 hash_count--; 658 hash_count++;
659 return (sizeof(GNUNET_HashCode) * 8) - hash_count; 659 return hash_count;
660} 660}
661 661
662 662
@@ -683,13 +683,13 @@ check_proof_of_work(const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *pkey,
683 pkey, 683 pkey,
684 sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); 684 sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded));
685 GNUNET_CRYPTO_hash (buf, sizeof (buf), &result); 685 GNUNET_CRYPTO_hash (buf, sizeof (buf), &result);
686 return (count_trailing_zeroes (&result) >= NSE_WORK_REQUIRED) ? GNUNET_YES : GNUNET_NO; 686 return (count_leading_zeroes (&result) >= NSE_WORK_REQUIRED) ? GNUNET_YES : GNUNET_NO;
687} 687}
688 688
689 689
690/** 690/**
691 * Given a public key, find an integer such that the hash of the key 691 * Given a public key, find an integer such that the hash of the key
692 * concatenated with the integer has NSE_WORK_REQUIRED trailing 0 692 * concatenated with the integer has NSE_WORK_REQUIRED leading 0
693 * bits. FIXME: this is a synchronous function... bad 693 * bits. FIXME: this is a synchronous function... bad
694 * 694 *
695 * @param pkey the public key 695 * @param pkey the public key
@@ -712,7 +712,7 @@ find_proof_of_work(const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *pkey)
712 &counter, 712 &counter,
713 sizeof(uint64_t)); 713 sizeof(uint64_t));
714 GNUNET_CRYPTO_hash (buf, sizeof (buf), &result); 714 GNUNET_CRYPTO_hash (buf, sizeof (buf), &result);
715 if (NSE_WORK_REQUIRED <= count_trailing_zeroes(&result)) 715 if (NSE_WORK_REQUIRED <= count_leading_zeroes(&result))
716 break; 716 break;
717 counter++; 717 counter++;
718 } 718 }
@@ -1131,7 +1131,7 @@ int
1131main(int argc, char * const *argv) 1131main(int argc, char * const *argv)
1132{ 1132{
1133 return (GNUNET_OK == GNUNET_SERVICE_run (argc, argv, 1133 return (GNUNET_OK == GNUNET_SERVICE_run (argc, argv,
1134 "gnunet-service-nse", 1134 "nse",
1135 GNUNET_SERVICE_OPTION_NONE, &run, 1135 GNUNET_SERVICE_OPTION_NONE, &run,
1136 NULL)) ? 0 : 1; 1136 NULL)) ? 0 : 1;
1137} 1137}