diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-11-28 18:02:29 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-11-28 18:02:29 +0000 |
commit | 92698047334856292975c05b3fec68e930d73ac9 (patch) | |
tree | 99ad0eb4b0aaddf6c6aa0cdf0562273ed36ac46f /src/nse | |
parent | 9f1e7420469ff9cc79c5097a76a0625a9345f18e (diff) | |
download | gnunet-92698047334856292975c05b3fec68e930d73ac9.tar.gz gnunet-92698047334856292975c05b3fec68e930d73ac9.zip |
-trying harder to remove useless signing in NSE
Diffstat (limited to 'src/nse')
-rw-r--r-- | src/nse/gnunet-service-nse.c | 48 |
1 files changed, 9 insertions, 39 deletions
diff --git a/src/nse/gnunet-service-nse.c b/src/nse/gnunet-service-nse.c index ab8ef5a9e..163c40f6e 100644 --- a/src/nse/gnunet-service-nse.c +++ b/src/nse/gnunet-service-nse.c | |||
@@ -830,7 +830,6 @@ find_proof (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
830 | sizeof (uint64_t)]; | 830 | sizeof (uint64_t)]; |
831 | GNUNET_HashCode result; | 831 | GNUNET_HashCode result; |
832 | unsigned int i; | 832 | unsigned int i; |
833 | const struct GNUNET_CRYPTO_RsaSignature *sig_cache; | ||
834 | 833 | ||
835 | proof_task = GNUNET_SCHEDULER_NO_TASK; | 834 | proof_task = GNUNET_SCHEDULER_NO_TASK; |
836 | memcpy (&buf[sizeof (uint64_t)], &my_public_key, | 835 | memcpy (&buf[sizeof (uint64_t)], &my_public_key, |
@@ -848,36 +847,8 @@ find_proof (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
848 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Proof of work found: %llu!\n", | 847 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Proof of work found: %llu!\n", |
849 | (unsigned long long) GNUNET_ntohll (counter)); | 848 | (unsigned long long) GNUNET_ntohll (counter)); |
850 | #endif | 849 | #endif |
851 | sig_cache = NULL; | ||
852 | for (i = 0; i < HISTORY_SIZE; i++) | ||
853 | if (ntohl (size_estimate_messages[i].hop_count) == 0) | ||
854 | { | ||
855 | size_estimate_messages[i].proof_of_work = my_proof; | ||
856 | if (nse_work_required > 0) | ||
857 | { | ||
858 | if (sig_cache == NULL) | ||
859 | { | ||
860 | GNUNET_assert (GNUNET_OK == | ||
861 | GNUNET_CRYPTO_rsa_sign (my_private_key, | ||
862 | &size_estimate_messages | ||
863 | [i].purpose, | ||
864 | &size_estimate_messages | ||
865 | [i].signature)); | ||
866 | sig_cache = &size_estimate_messages[i].signature; | ||
867 | } | ||
868 | else | ||
869 | { | ||
870 | /* use cached signature */ | ||
871 | size_estimate_messages[i].signature = *sig_cache; | ||
872 | } | ||
873 | } | ||
874 | else | ||
875 | { | ||
876 | /* no signature required */ | ||
877 | memset (&size_estimate_messages[i].signature, 0, sizeof (struct GNUNET_CRYPTO_RsaSignature)); | ||
878 | } | ||
879 | } | ||
880 | write_proof (); | 850 | write_proof (); |
851 | setup_flood_message (estimate_index, current_timestamp); | ||
881 | return; | 852 | return; |
882 | } | 853 | } |
883 | counter++; | 854 | counter++; |
@@ -1270,7 +1241,6 @@ core_init (void *cls, struct GNUNET_CORE_Handle *server, | |||
1270 | { | 1241 | { |
1271 | struct GNUNET_TIME_Absolute now; | 1242 | struct GNUNET_TIME_Absolute now; |
1272 | struct GNUNET_TIME_Absolute prev_time; | 1243 | struct GNUNET_TIME_Absolute prev_time; |
1273 | unsigned int i; | ||
1274 | 1244 | ||
1275 | if (server == NULL) | 1245 | if (server == NULL) |
1276 | { | 1246 | { |
@@ -1288,17 +1258,17 @@ core_init (void *cls, struct GNUNET_CORE_Handle *server, | |||
1288 | (now.abs_value / gnunet_nse_interval.rel_value) * | 1258 | (now.abs_value / gnunet_nse_interval.rel_value) * |
1289 | gnunet_nse_interval.rel_value; | 1259 | gnunet_nse_interval.rel_value; |
1290 | next_timestamp.abs_value = | 1260 | next_timestamp.abs_value = |
1291 | current_timestamp.abs_value + gnunet_nse_interval.rel_value; | 1261 | current_timestamp.abs_value + gnunet_nse_interval.rel_value; |
1292 | 1262 | estimate_index = HISTORY_SIZE - 1; | |
1293 | for (i = 0; i < HISTORY_SIZE; i++) | 1263 | estimate_count = 0; |
1264 | if (GNUNET_YES == check_proof_of_work (&my_public_key, | ||
1265 | my_proof)) | ||
1294 | { | 1266 | { |
1295 | prev_time.abs_value = | 1267 | prev_time.abs_value = |
1296 | current_timestamp.abs_value - (HISTORY_SIZE - i - | 1268 | current_timestamp.abs_value - (estimate_index - 1) * gnunet_nse_interval.rel_value; |
1297 | 1) * gnunet_nse_interval.rel_value; | 1269 | setup_flood_message (estimate_index, prev_time); |
1298 | setup_flood_message (i, prev_time); | 1270 | estimate_count++; |
1299 | } | 1271 | } |
1300 | estimate_index = HISTORY_SIZE - 1; | ||
1301 | estimate_count = 2; | ||
1302 | flood_task = | 1272 | flood_task = |
1303 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining | 1273 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining |
1304 | (next_timestamp), &update_flood_message, | 1274 | (next_timestamp), &update_flood_message, |