diff options
Diffstat (limited to 'src/namecache/plugin_namecache_postgres.c')
-rw-r--r-- | src/namecache/plugin_namecache_postgres.c | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/src/namecache/plugin_namecache_postgres.c b/src/namecache/plugin_namecache_postgres.c index 654a3ae81..ae0f71a1f 100644 --- a/src/namecache/plugin_namecache_postgres.c +++ b/src/namecache/plugin_namecache_postgres.c | |||
@@ -153,11 +153,11 @@ namecache_postgres_expire_blocks (struct Plugin *plugin) | |||
153 | static void | 153 | static void |
154 | delete_old_block (struct Plugin *plugin, | 154 | delete_old_block (struct Plugin *plugin, |
155 | const struct GNUNET_HashCode *query, | 155 | const struct GNUNET_HashCode *query, |
156 | struct GNUNET_TIME_AbsoluteNBO expiration_time) | 156 | struct GNUNET_TIME_Absolute expiration_time) |
157 | { | 157 | { |
158 | struct GNUNET_PQ_QueryParam params[] = { | 158 | struct GNUNET_PQ_QueryParam params[] = { |
159 | GNUNET_PQ_query_param_auto_from_type (query), | 159 | GNUNET_PQ_query_param_auto_from_type (query), |
160 | GNUNET_PQ_query_param_absolute_time_nbo (&expiration_time), | 160 | GNUNET_PQ_query_param_absolute_time (&expiration_time), |
161 | GNUNET_PQ_query_param_end | 161 | GNUNET_PQ_query_param_end |
162 | }; | 162 | }; |
163 | enum GNUNET_DB_QueryStatus res; | 163 | enum GNUNET_DB_QueryStatus res; |
@@ -182,21 +182,20 @@ namecache_postgres_cache_block (void *cls, | |||
182 | { | 182 | { |
183 | struct Plugin *plugin = cls; | 183 | struct Plugin *plugin = cls; |
184 | struct GNUNET_HashCode query; | 184 | struct GNUNET_HashCode query; |
185 | size_t block_size = ntohl (block->purpose.size) | 185 | size_t block_size = GNUNET_GNSRECORD_block_get_size (block); |
186 | + sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey) | 186 | struct GNUNET_TIME_Absolute exp; |
187 | + sizeof(struct GNUNET_CRYPTO_EcdsaSignature); | 187 | exp = GNUNET_GNSRECORD_block_get_expiration (block); |
188 | struct GNUNET_PQ_QueryParam params[] = { | 188 | struct GNUNET_PQ_QueryParam params[] = { |
189 | GNUNET_PQ_query_param_auto_from_type (&query), | 189 | GNUNET_PQ_query_param_auto_from_type (&query), |
190 | GNUNET_PQ_query_param_fixed_size (block, block_size), | 190 | GNUNET_PQ_query_param_fixed_size (block, block_size), |
191 | GNUNET_PQ_query_param_absolute_time_nbo (&block->expiration_time), | 191 | GNUNET_PQ_query_param_absolute_time (&exp), |
192 | GNUNET_PQ_query_param_end | 192 | GNUNET_PQ_query_param_end |
193 | }; | 193 | }; |
194 | enum GNUNET_DB_QueryStatus res; | 194 | enum GNUNET_DB_QueryStatus res; |
195 | 195 | ||
196 | namecache_postgres_expire_blocks (plugin); | 196 | namecache_postgres_expire_blocks (plugin); |
197 | GNUNET_CRYPTO_hash (&block->derived_key, | 197 | GNUNET_GNSRECORD_query_from_block (block, |
198 | sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey), | 198 | &query); |
199 | &query); | ||
200 | if (block_size > 64 * 65536) | 199 | if (block_size > 64 * 65536) |
201 | { | 200 | { |
202 | GNUNET_break (0); | 201 | GNUNET_break (0); |
@@ -204,7 +203,7 @@ namecache_postgres_cache_block (void *cls, | |||
204 | } | 203 | } |
205 | delete_old_block (plugin, | 204 | delete_old_block (plugin, |
206 | &query, | 205 | &query, |
207 | block->expiration_time); | 206 | exp); |
208 | 207 | ||
209 | res = GNUNET_PQ_eval_prepared_non_select (plugin->dbh, | 208 | res = GNUNET_PQ_eval_prepared_non_select (plugin->dbh, |
210 | "cache_block", | 209 | "cache_block", |
@@ -263,10 +262,7 @@ namecache_postgres_lookup_block (void *cls, | |||
263 | "Ending iteration (no more results)\n"); | 262 | "Ending iteration (no more results)\n"); |
264 | return GNUNET_NO; | 263 | return GNUNET_NO; |
265 | } | 264 | } |
266 | if ((bsize < sizeof(*block)) || | 265 | if ((bsize < sizeof(*block))) |
267 | (bsize != ntohl (block->purpose.size) | ||
268 | + sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey) | ||
269 | + sizeof(struct GNUNET_CRYPTO_EcdsaSignature))) | ||
270 | { | 266 | { |
271 | GNUNET_break (0); | 267 | GNUNET_break (0); |
272 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 268 | LOG (GNUNET_ERROR_TYPE_DEBUG, |