diff options
Diffstat (limited to 'src/nse/gnunet-service-nse.c')
-rw-r--r-- | src/nse/gnunet-service-nse.c | 29 |
1 files changed, 7 insertions, 22 deletions
diff --git a/src/nse/gnunet-service-nse.c b/src/nse/gnunet-service-nse.c index 972b3a79d..35278db29 100644 --- a/src/nse/gnunet-service-nse.c +++ b/src/nse/gnunet-service-nse.c | |||
@@ -774,24 +774,6 @@ update_flood_message (void *cls) | |||
774 | 774 | ||
775 | 775 | ||
776 | /** | 776 | /** |
777 | * Count the leading zeroes in hash. | ||
778 | * | ||
779 | * @param hash to count leading zeros in | ||
780 | * @return the number of leading zero bits. | ||
781 | */ | ||
782 | static unsigned int | ||
783 | count_leading_zeroes (const struct GNUNET_HashCode *hash) | ||
784 | { | ||
785 | unsigned int hash_count; | ||
786 | |||
787 | hash_count = 0; | ||
788 | while (0 == GNUNET_CRYPTO_hash_get_bit_ltr (hash, hash_count)) | ||
789 | hash_count++; | ||
790 | return hash_count; | ||
791 | } | ||
792 | |||
793 | |||
794 | /** | ||
795 | * Check whether the given public key and integer are a valid proof of | 777 | * Check whether the given public key and integer are a valid proof of |
796 | * work. | 778 | * work. |
797 | * | 779 | * |
@@ -799,7 +781,7 @@ count_leading_zeroes (const struct GNUNET_HashCode *hash) | |||
799 | * @param val the integer | 781 | * @param val the integer |
800 | * @return #GNUNET_YES if valid, #GNUNET_NO if not | 782 | * @return #GNUNET_YES if valid, #GNUNET_NO if not |
801 | */ | 783 | */ |
802 | static int | 784 | static enum GNUNET_GenericReturnValue |
803 | check_proof_of_work (const struct GNUNET_CRYPTO_EddsaPublicKey *pkey, | 785 | check_proof_of_work (const struct GNUNET_CRYPTO_EddsaPublicKey *pkey, |
804 | uint64_t val) | 786 | uint64_t val) |
805 | { | 787 | { |
@@ -815,8 +797,10 @@ check_proof_of_work (const struct GNUNET_CRYPTO_EddsaPublicKey *pkey, | |||
815 | buf, | 797 | buf, |
816 | sizeof(buf), | 798 | sizeof(buf), |
817 | &result); | 799 | &result); |
818 | return (count_leading_zeroes (&result) >= nse_work_required) ? GNUNET_YES | 800 | return (GNUNET_CRYPTO_hash_count_leading_zeroes (&result) >= |
819 | : GNUNET_NO; | 801 | nse_work_required) |
802 | ? GNUNET_YES | ||
803 | : GNUNET_NO; | ||
820 | } | 804 | } |
821 | 805 | ||
822 | 806 | ||
@@ -877,7 +861,8 @@ find_proof (void *cls) | |||
877 | buf, | 861 | buf, |
878 | sizeof(buf), | 862 | sizeof(buf), |
879 | &result); | 863 | &result); |
880 | if (nse_work_required <= count_leading_zeroes (&result)) | 864 | if (nse_work_required <= |
865 | GNUNET_CRYPTO_hash_count_leading_zeroes (&result)) | ||
881 | { | 866 | { |
882 | my_proof = counter; | 867 | my_proof = counter; |
883 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 868 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |