diff options
author | Christian Grothoff <christian@grothoff.org> | 2022-01-15 19:24:33 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2022-02-19 12:39:55 +0100 |
commit | b0abdf7127f2403ff583d224e0d9d4e68c1c5bfc (patch) | |
tree | 47df762cdbcce501ec5536c8963b5c9ee55da31d /src/datacache/plugin_datacache_postgres.c | |
parent | 3a71153405e8fc26712807b4bdb5987fb3bf2b9e (diff) | |
download | gnunet-b0abdf7127f2403ff583d224e0d9d4e68c1c5bfc.tar.gz gnunet-b0abdf7127f2403ff583d224e0d9d4e68c1c5bfc.zip |
-more work on DHTU integration
Diffstat (limited to 'src/datacache/plugin_datacache_postgres.c')
-rw-r--r-- | src/datacache/plugin_datacache_postgres.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/datacache/plugin_datacache_postgres.c b/src/datacache/plugin_datacache_postgres.c index 6a44c44a5..61b699c8d 100644 --- a/src/datacache/plugin_datacache_postgres.c +++ b/src/datacache/plugin_datacache_postgres.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | Copyright (C) 2006, 2009, 2010, 2012, 2015, 2017, 2018 GNUnet e.V. | 3 | Copyright (C) 2006, 2009, 2010, 2012, 2015, 2017, 2018, 2022 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -109,9 +109,13 @@ init_connection (struct Plugin *plugin) | |||
109 | " ORDER BY prox ASC, discard_time ASC LIMIT 1", | 109 | " ORDER BY prox ASC, discard_time ASC LIMIT 1", |
110 | 0), | 110 | 0), |
111 | GNUNET_PQ_make_prepare ("get_closest", | 111 | GNUNET_PQ_make_prepare ("get_closest", |
112 | "SELECT discard_time,type,value,path,key FROM gn011dc " | 112 | "SELECT discard_time,type,value,path,key FROM gn011dc" |
113 | "WHERE key>=$1 AND discard_time >= $2 ORDER BY key ASC LIMIT $3", | 113 | " WHERE key >= $1" |
114 | 3), | 114 | " AND discard_time >= $2" |
115 | " AND ( (type = $3) OR ( 0 = $3) )" | ||
116 | " ORDER BY key ASC" | ||
117 | " LIMIT $4", | ||
118 | 4), | ||
115 | GNUNET_PQ_make_prepare ("delrow", | 119 | GNUNET_PQ_make_prepare ("delrow", |
116 | "DELETE FROM gn011dc WHERE oid=$1", | 120 | "DELETE FROM gn011dc WHERE oid=$1", |
117 | 1), | 121 | 1), |
@@ -511,6 +515,7 @@ extract_result_cb (void *cls, | |||
511 | * | 515 | * |
512 | * @param cls closure (internal context for the plugin) | 516 | * @param cls closure (internal context for the plugin) |
513 | * @param key area of the keyspace to look into | 517 | * @param key area of the keyspace to look into |
518 | * @param type desired block type for the replies | ||
514 | * @param num_results number of results that should be returned to @a iter | 519 | * @param num_results number of results that should be returned to @a iter |
515 | * @param iter maybe NULL (to just count) | 520 | * @param iter maybe NULL (to just count) |
516 | * @param iter_cls closure for @a iter | 521 | * @param iter_cls closure for @a iter |
@@ -519,16 +524,19 @@ extract_result_cb (void *cls, | |||
519 | static unsigned int | 524 | static unsigned int |
520 | postgres_plugin_get_closest (void *cls, | 525 | postgres_plugin_get_closest (void *cls, |
521 | const struct GNUNET_HashCode *key, | 526 | const struct GNUNET_HashCode *key, |
527 | enum GNUNET_BLOCK_Type type, | ||
522 | unsigned int num_results, | 528 | unsigned int num_results, |
523 | GNUNET_DATACACHE_Iterator iter, | 529 | GNUNET_DATACACHE_Iterator iter, |
524 | void *iter_cls) | 530 | void *iter_cls) |
525 | { | 531 | { |
526 | struct Plugin *plugin = cls; | 532 | struct Plugin *plugin = cls; |
527 | uint32_t num_results32 = (uint32_t) num_results; | 533 | uint32_t num_results32 = (uint32_t) num_results; |
534 | uint32_t type32 = (uint32_t) type; | ||
528 | struct GNUNET_TIME_Absolute now; | 535 | struct GNUNET_TIME_Absolute now; |
529 | struct GNUNET_PQ_QueryParam params[] = { | 536 | struct GNUNET_PQ_QueryParam params[] = { |
530 | GNUNET_PQ_query_param_auto_from_type (key), | 537 | GNUNET_PQ_query_param_auto_from_type (key), |
531 | GNUNET_PQ_query_param_absolute_time (&now), | 538 | GNUNET_PQ_query_param_absolute_time (&now), |
539 | GNUNET_PQ_query_param_uint32 (&type32), | ||
532 | GNUNET_PQ_query_param_uint32 (&num_results32), | 540 | GNUNET_PQ_query_param_uint32 (&num_results32), |
533 | GNUNET_PQ_query_param_end | 541 | GNUNET_PQ_query_param_end |
534 | }; | 542 | }; |