gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r18361 - gnunet/src/nse
Date: Mon, 28 Nov 2011 18:39:25 +0100

Author: grothoff
Date: 2011-11-28 18:39:25 +0100 (Mon, 28 Nov 2011)
New Revision: 18361

Modified:
   gnunet/src/nse/gnunet-service-nse.c
   gnunet/src/nse/nse_api.c
Log:
cache signature upon first generation to avoid useless re-signing of the same 
data

Modified: gnunet/src/nse/gnunet-service-nse.c
===================================================================
--- gnunet/src/nse/gnunet-service-nse.c 2011-11-28 17:24:11 UTC (rev 18360)
+++ gnunet/src/nse/gnunet-service-nse.c 2011-11-28 17:39:25 UTC (rev 18361)
@@ -828,6 +828,7 @@
            sizeof (uint64_t)];
   GNUNET_HashCode result;
   unsigned int i;
+  const struct GNUNET_CRYPTO_RsaSignature *sig_cache;
 
   proof_task = GNUNET_SCHEDULER_NO_TASK;
   memcpy (&buf[sizeof (uint64_t)], &my_public_key,
@@ -845,19 +846,34 @@
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Proof of work found: %llu!\n",
                   (unsigned long long) GNUNET_ntohll (counter));
 #endif
+      sig_cache = NULL;
       for (i = 0; i < HISTORY_SIZE; i++)
         if (ntohl (size_estimate_messages[i].hop_count) == 0)
         {
           size_estimate_messages[i].proof_of_work = my_proof;
          if (nse_work_required > 0)
-           GNUNET_assert (GNUNET_OK ==
-                          GNUNET_CRYPTO_rsa_sign (my_private_key,
-                                                  &size_estimate_messages
-                                                  [i].purpose,
-                                                  &size_estimate_messages
-                                                  [i].signature));
+         {
+           if (sig_cache == NULL)
+           {
+             GNUNET_assert (GNUNET_OK ==
+                            GNUNET_CRYPTO_rsa_sign (my_private_key,
+                                                    &size_estimate_messages
+                                                    [i].purpose,
+                                                    &size_estimate_messages
+                                                    [i].signature));
+             sig_cache = &size_estimate_messages[i].signature;
+           }
+           else
+           {         
+             /* use cached signature */
+             size_estimate_messages[i].signature = *sig_cache;
+           }
+         }
          else
+         {
+           /* no signature required */
            memset (&size_estimate_messages[i].signature, 0, sizeof (struct 
GNUNET_CRYPTO_RsaSignature));
+         }
         }
       write_proof ();
       return;

Modified: gnunet/src/nse/nse_api.c
===================================================================
--- gnunet/src/nse/nse_api.c    2011-11-28 17:24:11 UTC (rev 18360)
+++ gnunet/src/nse/nse_api.c    2011-11-28 17:39:25 UTC (rev 18361)
@@ -105,7 +105,7 @@
 
   if (msg == NULL)
   {
-    /* Error, timeout, death */
+    /* Error, timeout, death */    
     GNUNET_CLIENT_disconnect (h->client, GNUNET_NO);
     h->client = NULL;
     h->reconnect_task =




reply via email to

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