diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-08-02 21:35:09 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-08-02 21:35:09 +0000 |
commit | 60b8cc395876876e5b477e8a7a9b028734878e26 (patch) | |
tree | 4939161e231494d7c1343cd530fedded9fce207a /src/datastore | |
parent | bd0fcbc4b2502e0297db8aff345e74cc916afd12 (diff) | |
download | gnunet-60b8cc395876876e5b477e8a7a9b028734878e26.tar.gz gnunet-60b8cc395876876e5b477e8a7a9b028734878e26.zip |
use postgres PRNG also on insertion
Diffstat (limited to 'src/datastore')
-rw-r--r-- | src/datastore/plugin_datastore_postgres.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/datastore/plugin_datastore_postgres.c b/src/datastore/plugin_datastore_postgres.c index 0327018e4..056138d97 100644 --- a/src/datastore/plugin_datastore_postgres.c +++ b/src/datastore/plugin_datastore_postgres.c | |||
@@ -311,7 +311,7 @@ init_connection (struct Plugin *plugin) | |||
311 | pq_prepare (plugin, | 311 | pq_prepare (plugin, |
312 | "put", | 312 | "put", |
313 | "INSERT INTO gn090 (repl, type, prio, anonLevel, expire, rvalue, hash, vhash, value) " | 313 | "INSERT INTO gn090 (repl, type, prio, anonLevel, expire, rvalue, hash, vhash, value) " |
314 | "VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)", | 314 | "VALUES ($1, $2, $3, $4, $5, RANDOM(), $6, $7, $8)", |
315 | 9, | 315 | 9, |
316 | __LINE__)) || | 316 | __LINE__)) || |
317 | (GNUNET_OK != | 317 | (GNUNET_OK != |
@@ -477,14 +477,12 @@ postgres_plugin_put (void *cls, | |||
477 | uint32_t banon = htonl (anonymity); | 477 | uint32_t banon = htonl (anonymity); |
478 | uint32_t brepl = htonl (replication); | 478 | uint32_t brepl = htonl (replication); |
479 | uint64_t bexpi = GNUNET_TIME_absolute_hton (expiration).abs_value__; | 479 | uint64_t bexpi = GNUNET_TIME_absolute_hton (expiration).abs_value__; |
480 | uint64_t rvalue = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX); | ||
481 | const char *paramValues[] = { | 480 | const char *paramValues[] = { |
482 | (const char *) &brepl, | 481 | (const char *) &brepl, |
483 | (const char *) &btype, | 482 | (const char *) &btype, |
484 | (const char *) &bprio, | 483 | (const char *) &bprio, |
485 | (const char *) &banon, | 484 | (const char *) &banon, |
486 | (const char *) &bexpi, | 485 | (const char *) &bexpi, |
487 | (const char *) &rvalue, | ||
488 | (const char *) key, | 486 | (const char *) key, |
489 | (const char *) &vhash, | 487 | (const char *) &vhash, |
490 | (const char *) data | 488 | (const char *) data |
@@ -495,16 +493,15 @@ postgres_plugin_put (void *cls, | |||
495 | sizeof (bprio), | 493 | sizeof (bprio), |
496 | sizeof (banon), | 494 | sizeof (banon), |
497 | sizeof (bexpi), | 495 | sizeof (bexpi), |
498 | sizeof (rvalue), | ||
499 | sizeof (GNUNET_HashCode), | 496 | sizeof (GNUNET_HashCode), |
500 | sizeof (GNUNET_HashCode), | 497 | sizeof (GNUNET_HashCode), |
501 | size | 498 | size |
502 | }; | 499 | }; |
503 | const int paramFormats[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1 }; | 500 | const int paramFormats[] = { 1, 1, 1, 1, 1, 1, 1, 1 }; |
504 | 501 | ||
505 | GNUNET_CRYPTO_hash (data, size, &vhash); | 502 | GNUNET_CRYPTO_hash (data, size, &vhash); |
506 | ret = PQexecPrepared (plugin->dbh, | 503 | ret = PQexecPrepared (plugin->dbh, |
507 | "put", 9, paramValues, paramLengths, paramFormats, 1); | 504 | "put", 8, paramValues, paramLengths, paramFormats, 1); |
508 | if (GNUNET_OK != check_result (plugin, ret, | 505 | if (GNUNET_OK != check_result (plugin, ret, |
509 | PGRES_COMMAND_OK, | 506 | PGRES_COMMAND_OK, |
510 | "PQexecPrepared", "put", __LINE__)) | 507 | "PQexecPrepared", "put", __LINE__)) |