use libtalerwire instead of duplicating logic
This commit is contained in:
parent
b018d4d5b0
commit
af91cd87d6
@ -45,6 +45,7 @@ taler_exchange_wire_SOURCES = \
|
|||||||
taler-exchange-wire.c
|
taler-exchange-wire.c
|
||||||
taler_exchange_wire_LDADD = \
|
taler_exchange_wire_LDADD = \
|
||||||
$(LIBGCRYPT_LIBS) \
|
$(LIBGCRYPT_LIBS) \
|
||||||
|
$(top_builddir)/src/wire/libtalerwire.la \
|
||||||
$(top_builddir)/src/util/libtalerutil.la \
|
$(top_builddir)/src/util/libtalerutil.la \
|
||||||
-lgnunetjson \
|
-lgnunetjson \
|
||||||
-lgnunetutil \
|
-lgnunetutil \
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include <gnunet/gnunet_json_lib.h>
|
#include <gnunet/gnunet_json_lib.h>
|
||||||
#include "taler_crypto_lib.h"
|
#include "taler_crypto_lib.h"
|
||||||
#include "taler_wire_plugin.h"
|
#include "taler_wire_plugin.h"
|
||||||
|
#include "taler_wire_lib.h"
|
||||||
#include "taler_signatures.h"
|
#include "taler_signatures.h"
|
||||||
|
|
||||||
|
|
||||||
@ -90,7 +91,6 @@ main (int argc,
|
|||||||
json_error_t err;
|
json_error_t err;
|
||||||
char *json_out;
|
char *json_out;
|
||||||
struct GNUNET_HashCode salt;
|
struct GNUNET_HashCode salt;
|
||||||
char *lib_name;
|
|
||||||
struct TALER_WIRE_Plugin *plugin;
|
struct TALER_WIRE_Plugin *plugin;
|
||||||
|
|
||||||
GNUNET_assert (GNUNET_OK ==
|
GNUNET_assert (GNUNET_OK ==
|
||||||
@ -159,20 +159,15 @@ main (int argc,
|
|||||||
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
|
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
|
||||||
&salt,
|
&salt,
|
||||||
sizeof (salt));
|
sizeof (salt));
|
||||||
(void) GNUNET_asprintf (&lib_name,
|
plugin = TALER_WIRE_plugin_load (cfg,
|
||||||
"libtaler_plugin_wire_%s",
|
|
||||||
method);
|
method);
|
||||||
plugin = GNUNET_PLUGIN_load (lib_name,
|
|
||||||
NULL);
|
|
||||||
if (NULL == plugin)
|
if (NULL == plugin)
|
||||||
{
|
{
|
||||||
GNUNET_free (lib_name);
|
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||||
"Wire transfer method `%s' not supported\n",
|
"Wire transfer method `%s' not supported\n",
|
||||||
method);
|
method);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
plugin->library_name = lib_name;
|
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
plugin->sign_wire_details (plugin->cls,
|
plugin->sign_wire_details (plugin->cls,
|
||||||
j,
|
j,
|
||||||
@ -182,14 +177,10 @@ main (int argc,
|
|||||||
{
|
{
|
||||||
/* sign function should have logged applicable errors */
|
/* sign function should have logged applicable errors */
|
||||||
json_decref (j);
|
json_decref (j);
|
||||||
GNUNET_PLUGIN_unload (lib_name,
|
TALER_WIRE_plugin_unload (plugin);
|
||||||
plugin);
|
|
||||||
GNUNET_free (lib_name);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
GNUNET_PLUGIN_unload (lib_name,
|
TALER_WIRE_plugin_unload (plugin);
|
||||||
plugin);
|
|
||||||
GNUNET_free (lib_name);
|
|
||||||
GNUNET_free (eddsa_priv);
|
GNUNET_free (eddsa_priv);
|
||||||
|
|
||||||
/* add signature and salt to JSON message */
|
/* add signature and salt to JSON message */
|
||||||
|
@ -42,9 +42,10 @@ taler_exchange_httpd_SOURCES = \
|
|||||||
taler-exchange-httpd_validation.c taler-exchange-httpd_validation.h
|
taler-exchange-httpd_validation.c taler-exchange-httpd_validation.h
|
||||||
taler_exchange_httpd_LDADD = \
|
taler_exchange_httpd_LDADD = \
|
||||||
$(LIBGCRYPT_LIBS) \
|
$(LIBGCRYPT_LIBS) \
|
||||||
|
$(top_builddir)/src/wire/libtalerwire.la \
|
||||||
$(top_builddir)/src/json/libtalerjson.la \
|
$(top_builddir)/src/json/libtalerjson.la \
|
||||||
$(top_builddir)/src/util/libtalerutil.la \
|
|
||||||
$(top_builddir)/src/exchangedb/libtalerexchangedb.la \
|
$(top_builddir)/src/exchangedb/libtalerexchangedb.la \
|
||||||
|
$(top_builddir)/src/util/libtalerutil.la \
|
||||||
-lmicrohttpd \
|
-lmicrohttpd \
|
||||||
-lgnunetutil \
|
-lgnunetutil \
|
||||||
-lgnunetjson \
|
-lgnunetjson \
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include <gnunet/gnunet_util_lib.h>
|
#include <gnunet/gnunet_util_lib.h>
|
||||||
#include "taler-exchange-httpd.h"
|
#include "taler-exchange-httpd.h"
|
||||||
#include "taler-exchange-httpd_validation.h"
|
#include "taler-exchange-httpd_validation.h"
|
||||||
|
#include "taler_wire_lib.h"
|
||||||
#include "taler_wire_plugin.h"
|
#include "taler_wire_plugin.h"
|
||||||
|
|
||||||
|
|
||||||
@ -76,7 +77,6 @@ TMH_VALIDATION_init (const struct GNUNET_CONFIGURATION_Handle *cfg)
|
|||||||
{
|
{
|
||||||
struct Plugin *p;
|
struct Plugin *p;
|
||||||
char *wireformats;
|
char *wireformats;
|
||||||
char *lib_name;
|
|
||||||
const char *token;
|
const char *token;
|
||||||
|
|
||||||
/* Find out list of supported wire formats */
|
/* Find out list of supported wire formats */
|
||||||
@ -97,24 +97,19 @@ TMH_VALIDATION_init (const struct GNUNET_CONFIGURATION_Handle *cfg)
|
|||||||
token = strtok (NULL,
|
token = strtok (NULL,
|
||||||
" "))
|
" "))
|
||||||
{
|
{
|
||||||
(void) GNUNET_asprintf (&lib_name,
|
|
||||||
"libtaler_plugin_wire_%s",
|
|
||||||
token);
|
|
||||||
p = GNUNET_new (struct Plugin);
|
p = GNUNET_new (struct Plugin);
|
||||||
p->type = GNUNET_strdup (token);
|
p->type = GNUNET_strdup (token);
|
||||||
p->plugin = GNUNET_PLUGIN_load (lib_name,
|
p->plugin = TALER_WIRE_plugin_load (cfg,
|
||||||
(void *) cfg);
|
token);
|
||||||
if (NULL == p->plugin)
|
if (NULL == p->plugin)
|
||||||
{
|
{
|
||||||
GNUNET_free (p);
|
GNUNET_free (p);
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
"Failed to load plugin %s\n",
|
"Failed to load plugin %s\n",
|
||||||
lib_name);
|
token);
|
||||||
GNUNET_free (lib_name);
|
|
||||||
TMH_VALIDATION_done ();
|
TMH_VALIDATION_done ();
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
p->plugin->library_name = lib_name;
|
|
||||||
GNUNET_CONTAINER_DLL_insert (wire_head,
|
GNUNET_CONTAINER_DLL_insert (wire_head,
|
||||||
wire_tail,
|
wire_tail,
|
||||||
p);
|
p);
|
||||||
@ -131,17 +126,13 @@ void
|
|||||||
TMH_VALIDATION_done ()
|
TMH_VALIDATION_done ()
|
||||||
{
|
{
|
||||||
struct Plugin *p;
|
struct Plugin *p;
|
||||||
char *lib_name;
|
|
||||||
|
|
||||||
while (NULL != (p = wire_head))
|
while (NULL != (p = wire_head))
|
||||||
{
|
{
|
||||||
GNUNET_CONTAINER_DLL_remove (wire_head,
|
GNUNET_CONTAINER_DLL_remove (wire_head,
|
||||||
wire_tail,
|
wire_tail,
|
||||||
p);
|
p);
|
||||||
lib_name = p->plugin->library_name;
|
TALER_WIRE_plugin_unload (p->plugin);
|
||||||
GNUNET_assert (NULL == GNUNET_PLUGIN_unload (lib_name,
|
|
||||||
p->plugin));
|
|
||||||
GNUNET_free (lib_name);
|
|
||||||
GNUNET_free (p->type);
|
GNUNET_free (p->type);
|
||||||
GNUNET_free (p);
|
GNUNET_free (p);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user