aboutsummaryrefslogtreecommitdiff
path: root/src/block
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-02-22 11:10:02 +0100
committerChristian Grothoff <christian@grothoff.org>2017-02-22 11:10:02 +0100
commit8000747074b82caeacb0f43710940220d9840d37 (patch)
treeef0f40343a0acf45894e9cfc8bc2d571fa3db8e9 /src/block
parentcccdf454e79ab779989876135b964f039c647a10 (diff)
downloadgnunet-8000747074b82caeacb0f43710940220d9840d37.tar.gz
gnunet-8000747074b82caeacb0f43710940220d9840d37.zip
clean up new block logic, avoid direct linkage against blockgroup lib from DHT service
Diffstat (limited to 'src/block')
-rw-r--r--src/block/block.c34
1 files changed, 24 insertions, 10 deletions
diff --git a/src/block/block.c b/src/block/block.c
index b7a19ae90..23caacd38 100644
--- a/src/block/block.c
+++ b/src/block/block.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2010 GNUnet e.V. 3 Copyright (C) 2010, 2017 GNUnet e.V.
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -84,8 +84,12 @@ GNUNET_BLOCK_mingle_hash (const struct GNUNET_HashCode *in,
84{ 84{
85 struct GNUNET_HashCode m; 85 struct GNUNET_HashCode m;
86 86
87 GNUNET_CRYPTO_hash (&mingle_number, sizeof (uint32_t), &m); 87 GNUNET_CRYPTO_hash (&mingle_number,
88 GNUNET_CRYPTO_hash_xor (&m, in, hc); 88 sizeof (uint32_t),
89 &m);
90 GNUNET_CRYPTO_hash_xor (&m,
91 in,
92 hc);
89} 93}
90 94
91 95
@@ -111,7 +115,9 @@ add_plugin (void *cls,
111 plugin = GNUNET_new (struct Plugin); 115 plugin = GNUNET_new (struct Plugin);
112 plugin->api = api; 116 plugin->api = api;
113 plugin->library_name = GNUNET_strdup (library_name); 117 plugin->library_name = GNUNET_strdup (library_name);
114 GNUNET_array_append (ctx->plugins, ctx->num_plugins, plugin); 118 GNUNET_array_append (ctx->plugins,
119 ctx->num_plugins,
120 plugin);
115} 121}
116 122
117 123
@@ -129,7 +135,10 @@ GNUNET_BLOCK_context_create (const struct GNUNET_CONFIGURATION_Handle *cfg)
129 135
130 ctx = GNUNET_new (struct GNUNET_BLOCK_Context); 136 ctx = GNUNET_new (struct GNUNET_BLOCK_Context);
131 ctx->cfg = cfg; 137 ctx->cfg = cfg;
132 GNUNET_PLUGIN_load_all ("libgnunet_plugin_block_", NULL, &add_plugin, ctx); 138 GNUNET_PLUGIN_load_all ("libgnunet_plugin_block_",
139 NULL,
140 &add_plugin,
141 ctx);
133 return ctx; 142 return ctx;
134} 143}
135 144
@@ -149,7 +158,8 @@ GNUNET_BLOCK_context_destroy (struct GNUNET_BLOCK_Context *ctx)
149 { 158 {
150 plugin = ctx->plugins[i]; 159 plugin = ctx->plugins[i];
151 GNUNET_break (NULL == 160 GNUNET_break (NULL ==
152 GNUNET_PLUGIN_unload (plugin->library_name, plugin->api)); 161 GNUNET_PLUGIN_unload (plugin->library_name,
162 plugin->api));
153 GNUNET_free (plugin->library_name); 163 GNUNET_free (plugin->library_name);
154 GNUNET_free (plugin); 164 GNUNET_free (plugin);
155 } 165 }
@@ -249,10 +259,9 @@ find_plugin (struct GNUNET_BLOCK_Context *ctx,
249 enum GNUNET_BLOCK_Type type) 259 enum GNUNET_BLOCK_Type type)
250{ 260{
251 struct Plugin *plugin; 261 struct Plugin *plugin;
252 unsigned int i;
253 unsigned int j; 262 unsigned int j;
254 263
255 for (i = 0; i < ctx->num_plugins; i++) 264 for (unsigned i = 0; i < ctx->num_plugins; i++)
256 { 265 {
257 plugin = ctx->plugins[i]; 266 plugin = ctx->plugins[i];
258 j = 0; 267 j = 0;
@@ -294,7 +303,8 @@ GNUNET_BLOCK_group_create (struct GNUNET_BLOCK_Context *ctx,
294 type); 303 type);
295 if (NULL == plugin->create_group) 304 if (NULL == plugin->create_group)
296 return NULL; 305 return NULL;
297 va_start (ap, raw_data_size); 306 va_start (ap,
307 raw_data_size);
298 bg = plugin->create_group (plugin->cls, 308 bg = plugin->create_group (plugin->cls,
299 type, 309 type,
300 nonce, 310 nonce,
@@ -375,7 +385,11 @@ GNUNET_BLOCK_get_key (struct GNUNET_BLOCK_Context *ctx,
375 385
376 if (plugin == NULL) 386 if (plugin == NULL)
377 return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED; 387 return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED;
378 return plugin->get_key (plugin->cls, type, block, block_size, key); 388 return plugin->get_key (plugin->cls,
389 type,
390 block,
391 block_size,
392 key);
379} 393}
380 394
381 395