gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r16342 - gnunet/src/datastore


From: gnunet
Subject: [GNUnet-SVN] r16342 - gnunet/src/datastore
Date: Tue, 2 Aug 2011 23:37:26 +0200

Author: grothoff
Date: 2011-08-02 23:37:25 +0200 (Tue, 02 Aug 2011)
New Revision: 16342

Modified:
   gnunet/src/datastore/plugin_datastore_sqlite.c
Log:
use sqlite PRNG also on insertion

Modified: gnunet/src/datastore/plugin_datastore_sqlite.c
===================================================================
--- gnunet/src/datastore/plugin_datastore_sqlite.c      2011-08-02 21:35:09 UTC 
(rev 16341)
+++ gnunet/src/datastore/plugin_datastore_sqlite.c      2011-08-02 21:37:25 UTC 
(rev 16342)
@@ -326,13 +326,13 @@
       (sq_prepare (plugin->dbh,
                    "UPDATE gn090 SET repl = MAX (0, repl - 1) WHERE _ROWID_ = 
?",
                    &plugin->updRepl) != SQLITE_OK) ||
-#if 1
+#if 0
       /* FIXME: this is the O(n) version */
        (sq_prepare (plugin->dbh,
                    "SELECT type,prio,anonLevel,expire,hash,value,_ROWID_ FROM 
gn090"
                    " ORDER BY repl DESC, Random() LIMIT 1",
                    &plugin->selRepl) != SQLITE_OK) ||
-#elif 0
+#elif 1
       /* FIXME: this gives O(n) queries, presumably because the LEFT JOIN 
generates
         a temporary table with all matching expressions before the ORDER BY 
and LIMIT
         clauses are applied */
@@ -375,7 +375,7 @@
       (sq_prepare (plugin->dbh,
                    "INSERT INTO gn090 (repl, type, prio, "
                    "anonLevel, expire, rvalue, hash, vhash, value) "
-                   "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
+                   "VALUES (?, ?, ?, ?, ?, RANDOM(), ?, ?, ?)",
                    &plugin->insertContent) != SQLITE_OK) ||
       (sq_prepare (plugin->dbh,
                    "DELETE FROM gn090 WHERE _ROWID_ = ?",
@@ -524,7 +524,6 @@
   int ret;
   sqlite3_stmt *stmt;
   GNUNET_HashCode vhash;
-  uint64_t rvalue;
 
   if (size > MAX_ITEM_SIZE)
     return GNUNET_SYSERR;
@@ -540,21 +539,19 @@
 #endif
   GNUNET_CRYPTO_hash (data, size, &vhash);
   stmt = plugin->insertContent;
-  rvalue = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX);
   if ((SQLITE_OK != sqlite3_bind_int (stmt, 1, replication)) ||
       (SQLITE_OK != sqlite3_bind_int (stmt, 2, type)) ||
       (SQLITE_OK != sqlite3_bind_int (stmt, 3, priority)) ||
       (SQLITE_OK != sqlite3_bind_int (stmt, 4, anonymity)) ||
       (SQLITE_OK != sqlite3_bind_int64 (stmt, 5, expiration.abs_value)) ||
-      (SQLITE_OK != sqlite3_bind_int64 (stmt, 6, rvalue)) ||
       (SQLITE_OK !=
-       sqlite3_bind_blob (stmt, 7, key, sizeof (GNUNET_HashCode),
+       sqlite3_bind_blob (stmt, 6, key, sizeof (GNUNET_HashCode),
                           SQLITE_TRANSIENT)) ||
       (SQLITE_OK !=
-       sqlite3_bind_blob (stmt, 8, &vhash, sizeof (GNUNET_HashCode),
+       sqlite3_bind_blob (stmt, 7, &vhash, sizeof (GNUNET_HashCode),
                           SQLITE_TRANSIENT))
       || (SQLITE_OK !=
-          sqlite3_bind_blob (stmt, 9, data, size,
+          sqlite3_bind_blob (stmt, 8, data, size,
                              SQLITE_TRANSIENT)))
     {
       LOG_SQLITE (plugin,




reply via email to

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