second round of renamefest

This commit is contained in:
Christian Grothoff 2015-03-28 11:06:00 +01:00
parent eae1896a4b
commit c626ccac51
30 changed files with 277 additions and 282 deletions

View File

@ -174,7 +174,9 @@ AC_CONFIG_FILES([Makefile
src/include/Makefile src/include/Makefile
src/util/Makefile src/util/Makefile
src/pq/Makefile src/pq/Makefile
src/mintdb/Makefile
src/mint/Makefile src/mint/Makefile
src/lib/Makefile src/mint-tools/Makefile
src/mint-lib/Makefile
]) ])
AC_OUTPUT AC_OUTPUT

View File

@ -1,3 +1,3 @@
# This Makefile.am is in the public domain # This Makefile.am is in the public domain
AM_CPPFLAGS = -I$(top_srcdir)/src/include AM_CPPFLAGS = -I$(top_srcdir)/src/include
SUBDIRS = include util pq mint lib SUBDIRS = include util pq mintdb mint mint-tools mint-lib

View File

@ -8,6 +8,7 @@ talerinclude_HEADERS = \
taler_json_lib.h \ taler_json_lib.h \
taler_util.h \ taler_util.h \
taler_mint_service.h \ taler_mint_service.h \
taler_mintdb_lib.h \
taler_mintdb_plugin.h \ taler_mintdb_plugin.h \
taler_pq_lib.h \ taler_pq_lib.h \
taler_signatures.h taler_signatures.h

View File

@ -14,14 +14,14 @@
TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/> TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/>
*/ */
/** /**
* @file mint/key_io.h * @file include/taler_mintdb_lib.h
* @brief IO operations for the mint's private keys * @brief IO operations for the mint's private keys
* @author Florian Dold * @author Florian Dold
* @author Benedikt Mueller * @author Benedikt Mueller
* @author Christian Grothoff * @author Christian Grothoff
*/ */
#ifndef KEY_IO_H #ifndef TALER_MINTDB_LIB_H
#define KEY_IO_H #define TALER_MINTDB_LIB_H
#include <gnunet/gnunet_util_lib.h> #include <gnunet/gnunet_util_lib.h>
#include "taler_signatures.h" #include "taler_signatures.h"
@ -184,4 +184,24 @@ TALER_MINT_read_denom_key (const char *filename,
struct TALER_DenominationKeyIssueInformation *dki); struct TALER_DenominationKeyIssueInformation *dki);
/**
* Initialize the plugin.
*
* @param cfg configuration to use
* @return NULL on failure
*/
struct TALER_MINTDB_Plugin *
TALER_MINT_plugin_load (const struct GNUNET_CONFIGURATION_Handle *cfg);
/**
* Shutdown the plugin.
*
* @param plugin plugin to unload
*/
void
TALER_MINT_plugin_unload (struct TALER_MINTDB_Plugin *plugin);
#endif #endif

View File

@ -479,9 +479,10 @@ struct TALER_MINTDB_Plugin
void *cls; void *cls;
/** /**
* Name of the library which generated this plugin * Name of the library which generated this plugin. Set by the
* plugin loader.
*/ */
const char *library_name; char *library_name;
/** /**
* Get the thread-local database-handle. * Get the thread-local database-handle.

View File

@ -0,0 +1,63 @@
# This Makefile.am is in the public domain
AM_CPPFLAGS = -I$(top_srcdir)/src/include
bin_PROGRAMS = \
taler-mint-keyup \
taler-mint-keycheck \
taler-mint-reservemod \
taler-mint-dbinit
taler_mint_keyup_SOURCES = \
taler-mint-keyup.c
taler_mint_keyup_LDADD = \
$(LIBGCRYPT_LIBS) \
$(top_builddir)/src/util/libtalerutil.la \
$(top_builddir)/src/pq/libtalerpq.la \
$(top_builddir)/src/mint/libtalermint_common.la \
-lgnunetutil
taler_mint_keyup_LDFLAGS = $(POSTGRESQL_LDFLAGS)
taler_mint_keycheck_SOURCES = \
taler-mint-keycheck.c
taler_mint_keycheck_LDADD = \
$(LIBGCRYPT_LIBS) \
$(top_builddir)/src/util/libtalerutil.la \
$(top_builddir)/src/pq/libtalerpq.la \
$(top_builddir)/src/mint/libtalermint_common.la \
-lgnunetutil
taler_mint_keycheck_LDFLAGS = $(POSTGRESQL_LDFLAGS)
taler_mint_reservemod_SOURCES = \
taler-mint-reservemod.c
taler_mint_reservemod_LDADD = \
$(LIBGCRYPT_LIBS) \
$(top_builddir)/src/util/libtalerutil.la \
$(top_builddir)/src/pq/libtalerpq.la \
$(top_builddir)/src/mint/libtalermint_common.la \
-lpq \
-lgnunetutil
taler_mint_reservemod_LDFLAGS = \
$(POSTGRESQL_LDFLAGS)
taler_mint_reservemod_CPPFLAGS = \
-I$(top_srcdir)/src/include \
-I$(top_srcdir)/src/pq/ \
$(POSTGRESQL_CPPFLAGS)
taler_mint_dbinit_SOURCES = \
taler-mint-dbinit.c
taler_mint_dbinit_LDADD = \
$(LIBGCRYPT_LIBS) \
$(top_builddir)/src/util/libtalerutil.la \
$(top_builddir)/src/pq/libtalerpq.la \
$(top_builddir)/src/mint/libtalermint_common.la \
-lpq \
-lgnunetutil
taler_mint_dbinit_LDFLAGS = \
$(POSTGRESQL_LDFLAGS)
taler_mint_dbinit_CPPFLAGS = \
-I$(top_srcdir)/src/include \
-I$(top_srcdir)/src/pq/ \
$(POSTGRESQL_CPPFLAGS)

View File

@ -23,7 +23,7 @@
#include <libpq-fe.h> #include <libpq-fe.h>
#include "taler_util.h" #include "taler_util.h"
#include "taler_mintdb_plugin.h" #include "taler_mintdb_plugin.h"
#include "plugin.h" #include "taler_mintdb_lib.h"
/** /**
* Mint directory with the keys. * Mint directory with the keys.
@ -35,6 +35,11 @@ static char *mint_base_dir;
*/ */
static struct GNUNET_CONFIGURATION_Handle *cfg; static struct GNUNET_CONFIGURATION_Handle *cfg;
/**
* Our DB plugin.
*/
static struct TALER_MINTDB_Plugin *plugin;
/** /**
* The main function of the database initialization tool. * The main function of the database initialization tool.
@ -78,8 +83,8 @@ main (int argc,
"Failed to load mint configuration.\n"); "Failed to load mint configuration.\n");
return 1; return 1;
} }
if (GNUNET_OK != if (NULL ==
TALER_MINT_plugin_load (cfg)) (plugin = TALER_MINT_plugin_load (cfg)))
{ {
fprintf (stderr, fprintf (stderr,
"Failed to initialize database plugin.\n"); "Failed to initialize database plugin.\n");
@ -91,10 +96,10 @@ main (int argc,
{ {
fprintf (stderr, fprintf (stderr,
"Failed to initialize database.\n"); "Failed to initialize database.\n");
TALER_MINT_plugin_unload (); TALER_MINT_plugin_unload (plugin);
return 1; return 1;
} }
TALER_MINT_plugin_unload (); TALER_MINT_plugin_unload (plugin);
return 0; return 0;
} }

View File

@ -24,7 +24,7 @@
*/ */
#include <platform.h> #include <platform.h>
#include <gnunet/gnunet_util_lib.h> #include <gnunet/gnunet_util_lib.h>
#include "key_io.h" #include "taler_mintdb_lib.h"
/** /**
* Mint directory with the keys. * Mint directory with the keys.

View File

@ -24,7 +24,7 @@
#include <platform.h> #include <platform.h>
#include <gnunet/gnunet_util_lib.h> #include <gnunet/gnunet_util_lib.h>
#include "taler_util.h" #include "taler_util.h"
#include "key_io.h" #include "taler_mintdb_lib.h"
/** /**
* When generating filenames from a cryptographic hash, we do not use * When generating filenames from a cryptographic hash, we do not use

View File

@ -25,7 +25,7 @@
#include "taler_util.h" #include "taler_util.h"
#include "taler_signatures.h" #include "taler_signatures.h"
#include "taler_mintdb_plugin.h" #include "taler_mintdb_plugin.h"
#include "taler_pq_lib.h" #include "taler_mintdb_lib.h"
/** /**

View File

@ -1,82 +1,8 @@
# This Makefile.am is in the public domain # This Makefile.am is in the public domain
AM_CPPFLAGS = -I$(top_srcdir)/src/include -I$(top_srcdir)/src/pq/ $(POSTGRESQL_CPPFLAGS) AM_CPPFLAGS = -I$(top_srcdir)/src/include
plugindir = $(libdir)/taler
plugin_LTLIBRARIES = \
libtaler_plugin_mintdb_postgres.la
EXTRA_DIST = plugin_mintdb_common.c
libtaler_plugin_mintdb_postgres_la_SOURCES = \
plugin_mintdb_postgres.c
libtaler_plugin_mintdb_postgres_la_LIBADD = \
$(LTLIBINTL)
libtaler_plugin_mintdb_postgres_la_LDFLAGS = \
$(TALER_PLUGIN_LDFLAGS) \
-lpq \
-lgnunetutil
lib_LTLIBRARIES = \
libtalermint_common.la
libtalermint_common_la_SOURCES = \
key_io.c key_io.h \
plugin.c plugin.h
libtalermint_common_la_LIBADD = \
$(top_builddir)/src/util/libtalerutil.la \
-lgnunetutil
libtalermint_common_la_LDFLAGS = \
$(POSTGRESQL_LDFLAGS) \
-version-info 0:0:0 \
-no-undefined
bin_PROGRAMS = \ bin_PROGRAMS = \
taler-mint-keyup \ taler-mint-httpd
taler-mint-keycheck \
taler-mint-reservemod \
taler-mint-httpd \
taler-mint-dbinit
taler_mint_keyup_SOURCES = \
taler-mint-keyup.c
taler_mint_keyup_LDADD = \
$(LIBGCRYPT_LIBS) \
$(top_builddir)/src/util/libtalerutil.la \
$(top_builddir)/src/pq/libtalerpq.la \
$(top_builddir)/src/mint/libtalermint_common.la \
-lpq \
-lgnunetutil
taler_mint_keyup_LDFLAGS = $(POSTGRESQL_LDFLAGS)
taler_mint_keycheck_SOURCES = \
taler-mint-keycheck.c
taler_mint_keycheck_LDADD = \
$(LIBGCRYPT_LIBS) \
$(top_builddir)/src/util/libtalerutil.la \
$(top_builddir)/src/pq/libtalerpq.la \
$(top_builddir)/src/mint/libtalermint_common.la \
-lgnunetutil \
-lpq
taler_mint_keycheck_LDFLAGS = $(POSTGRESQL_LDFLAGS)
taler_mint_reservemod_SOURCES = \
taler-mint-reservemod.c
taler_mint_reservemod_LDADD = \
$(LIBGCRYPT_LIBS) \
$(top_builddir)/src/util/libtalerutil.la \
$(top_builddir)/src/pq/libtalerpq.la \
$(top_builddir)/src/mint/libtalermint_common.la \
-lpq \
-lgnunetutil
taler_mint_reservemod_LDFLAGS = \
$(POSTGRESQL_LDFLAGS)
taler_mint_httpd_SOURCES = \ taler_mint_httpd_SOURCES = \
taler-mint-httpd.c \ taler-mint-httpd.c \
@ -92,56 +18,8 @@ taler_mint_httpd_LDADD = \
$(LIBGCRYPT_LIBS) \ $(LIBGCRYPT_LIBS) \
$(top_builddir)/src/util/libtalerutil.la \ $(top_builddir)/src/util/libtalerutil.la \
$(top_builddir)/src/pq/libtalerpq.la \ $(top_builddir)/src/pq/libtalerpq.la \
$(top_builddir)/src/mint/libtalermint_common.la \ $(top_builddir)/src/mintdb/libtalermintdb.la \
-lpq \
-lmicrohttpd \ -lmicrohttpd \
-ljansson \ -ljansson \
-lgnunetutil \ -lgnunetutil \
-lpthread -lpthread
taler_mint_httpd_LDFLAGS = \
$(POSTGRESQL_LDFLAGS)
taler_mint_dbinit_SOURCES = \
taler-mint-dbinit.c
taler_mint_dbinit_LDADD = \
$(LIBGCRYPT_LIBS) \
$(top_builddir)/src/util/libtalerutil.la \
$(top_builddir)/src/pq/libtalerpq.la \
$(top_builddir)/src/mint/libtalermint_common.la \
-lpq \
-lgnunetutil
taler_mint_dbinit_LDFLAGS = $(POSTGRESQL_LDFLAGS)
check_PROGRAMS = \
test-mint-deposits \
test-mint-common \
test-mint-db-postgres
test_mint_deposits_SOURCES = \
test_mint_deposits.c
test_mint_deposits_LDADD = \
libtalermint_common.la \
$(top_srcdir)/src/util/libtalerutil.la \
$(top_srcdir)/src/pq/libtalerpq.la \
-lgnunetutil \
-ljansson \
-lpq
test_mint_common_SOURCES = \
test_mint_common.c
test_mint_common_LDADD = \
libtalermint_common.la \
$(top_srcdir)/src/util/libtalerutil.la \
$(top_srcdir)/src/pq/libtalerpq.la \
-lgnunetutil
test_mint_db_postgres_SOURCES = \
test_mint_db.c
test_mint_db_postgres_LDADD = \
libtalermint_common.la \
$(top_srcdir)/src/util/libtalerutil.la \
$(top_srcdir)/src/pq/libtalerpq.la \
-lgnunetutil -ljansson
EXTRA_test_mint_db_postgres_DEPENDENCIES = \
libtaler_plugin_mintdb_postgres.la

View File

@ -1,50 +0,0 @@
/*
This file is part of TALER
Copyright (C) 2015 Christian Grothoff (and other contributing authors)
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
TALER is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/>
*/
/**
* @file mint/plugin.h
* @brief Logic to load database plugins
* @author Christian Grothoff
*/
#ifndef PLUGIN_H
#define PLUGIN_H
#include <gnunet/gnunet_util_lib.h>
#include "taler_mintdb_plugin.h"
/**
* Global variable with the plugin (once loaded).
*/
extern struct TALER_MINTDB_Plugin *plugin;
/**
* Initialize the plugin.
*
* @param cfg configuration to use
* @return #GNUNET_OK on success
*/
int
TALER_MINT_plugin_load (const struct GNUNET_CONFIGURATION_Handle *cfg);
/**
* Shutdown the plugin.
*/
void
TALER_MINT_plugin_unload (void);
#endif

View File

@ -25,7 +25,6 @@
#include <gnunet/gnunet_util_lib.h> #include <gnunet/gnunet_util_lib.h>
#include <jansson.h> #include <jansson.h>
#include <microhttpd.h> #include <microhttpd.h>
#include <libpq-fe.h>
#include <pthread.h> #include <pthread.h>
#include "taler_signatures.h" #include "taler_signatures.h"
#include "taler_util.h" #include "taler_util.h"
@ -36,7 +35,6 @@
#include "taler-mint-httpd_refresh.h" #include "taler-mint-httpd_refresh.h"
#include "taler-mint-httpd_keystate.h" #include "taler-mint-httpd_keystate.h"
#include "taler_mintdb_plugin.h" #include "taler_mintdb_plugin.h"
#include "plugin.h"
/** /**
@ -60,6 +58,11 @@ struct GNUNET_CRYPTO_EddsaPublicKey TMH_master_public_key;
*/ */
char *TMH_expected_wire_format = "sepa"; char *TMH_expected_wire_format = "sepa";
/**
* Our DB plugin.
*/
struct TALER_MINTDB_Plugin *TMH_plugin;
/** /**
* The HTTP Daemon. * The HTTP Daemon.
*/ */
@ -260,8 +263,8 @@ mint_serve_process_config (const char *mint_directory)
} }
GNUNET_free (TMH_master_public_key_str); GNUNET_free (TMH_master_public_key_str);
if (GNUNET_OK != if (NULL ==
TALER_MINT_plugin_load (cfg)) (TMH_plugin = TALER_MINT_plugin_load (cfg)))
{ {
fprintf (stderr, fprintf (stderr,
"failed to initialize DB subsystem\n"); "failed to initialize DB subsystem\n");
@ -355,5 +358,6 @@ main (int argc, char *const *argv)
ret = TMH_KS_loop (); ret = TMH_KS_loop ();
MHD_stop_daemon (mydaemon); MHD_stop_daemon (mydaemon);
TALER_MINT_plugin_unload (TMH_plugin);
return (GNUNET_OK == ret) ? 0 : 1; return (GNUNET_OK == ret) ? 0 : 1;
} }

View File

@ -59,6 +59,11 @@ extern struct GNUNET_CRYPTO_EddsaPublicKey TMH_master_public_key;
*/ */
extern struct GNUNET_CRYPTO_EddsaPrivateKey TMH_mint_private_signing_key; extern struct GNUNET_CRYPTO_EddsaPrivateKey TMH_mint_private_signing_key;
/**
* Our DB plugin.
*/
extern struct TALER_MINTDB_Plugin *TMH_plugin;
/** /**
* Struct describing an URL and the handler for it. * Struct describing an URL and the handler for it.

View File

@ -26,7 +26,7 @@
#include "taler-mint-httpd_responses.h" #include "taler-mint-httpd_responses.h"
#include "taler_util.h" #include "taler_util.h"
#include "taler-mint-httpd_keystate.h" #include "taler-mint-httpd_keystate.h"
#include "plugin.h" #include "taler_mintdb_lib.h"
/** /**
@ -109,14 +109,14 @@ TMH_DB_execute_deposit (struct MHD_Connection *connection,
struct TALER_DenominationKeyIssueInformation *dki; struct TALER_DenominationKeyIssueInformation *dki;
int ret; int ret;
if (NULL == (session = plugin->get_session (plugin->cls, if (NULL == (session = TMH_plugin->get_session (TMH_plugin->cls,
GNUNET_NO))) GNUNET_NO)))
{ {
GNUNET_break (0); GNUNET_break (0);
return TMH_RESPONSE_reply_internal_db_error (connection); return TMH_RESPONSE_reply_internal_db_error (connection);
} }
if (GNUNET_YES == if (GNUNET_YES ==
plugin->have_deposit (plugin->cls, TMH_plugin->have_deposit (TMH_plugin->cls,
session, session,
deposit)) deposit))
{ {
@ -136,7 +136,7 @@ TMH_DB_execute_deposit (struct MHD_Connection *connection,
TMH_KS_release (mks); TMH_KS_release (mks);
if (GNUNET_OK != if (GNUNET_OK !=
plugin->start (plugin->cls, TMH_plugin->start (TMH_plugin->cls,
session)) session))
{ {
GNUNET_break (0); GNUNET_break (0);
@ -145,7 +145,7 @@ TMH_DB_execute_deposit (struct MHD_Connection *connection,
/* fee for THIS transaction */ /* fee for THIS transaction */
spent = deposit->amount_with_fee; spent = deposit->amount_with_fee;
/* add cost of all previous transactions */ /* add cost of all previous transactions */
tl = plugin->get_coin_transactions (plugin->cls, tl = TMH_plugin->get_coin_transactions (TMH_plugin->cls,
session, session,
&deposit->coin.coin_pub); &deposit->coin.coin_pub);
if (GNUNET_OK != if (GNUNET_OK !=
@ -153,7 +153,7 @@ TMH_DB_execute_deposit (struct MHD_Connection *connection,
&spent, &spent,
&spent)) &spent))
{ {
plugin->free_coin_transaction_list (plugin->cls, TMH_plugin->free_coin_transaction_list (TMH_plugin->cls,
tl); tl);
return TMH_RESPONSE_reply_internal_db_error (connection); return TMH_RESPONSE_reply_internal_db_error (connection);
} }
@ -162,30 +162,30 @@ TMH_DB_execute_deposit (struct MHD_Connection *connection,
if (0 < TALER_amount_cmp (&spent, if (0 < TALER_amount_cmp (&spent,
&value)) &value))
{ {
plugin->rollback (plugin->cls, TMH_plugin->rollback (TMH_plugin->cls,
session); session);
ret = TMH_RESPONSE_reply_deposit_insufficient_funds (connection, ret = TMH_RESPONSE_reply_deposit_insufficient_funds (connection,
tl); tl);
plugin->free_coin_transaction_list (plugin->cls, TMH_plugin->free_coin_transaction_list (TMH_plugin->cls,
tl); tl);
return ret; return ret;
} }
plugin->free_coin_transaction_list (plugin->cls, TMH_plugin->free_coin_transaction_list (TMH_plugin->cls,
tl); tl);
if (GNUNET_OK != if (GNUNET_OK !=
plugin->insert_deposit (plugin->cls, TMH_plugin->insert_deposit (TMH_plugin->cls,
session, session,
deposit)) deposit))
{ {
TALER_LOG_WARNING ("Failed to store /deposit information in database\n"); TALER_LOG_WARNING ("Failed to store /deposit information in database\n");
plugin->rollback (plugin->cls, TMH_plugin->rollback (TMH_plugin->cls,
session); session);
return TMH_RESPONSE_reply_internal_db_error (connection); return TMH_RESPONSE_reply_internal_db_error (connection);
} }
if (GNUNET_OK != if (GNUNET_OK !=
plugin->commit (plugin->cls, TMH_plugin->commit (TMH_plugin->cls,
session)) session))
{ {
TALER_LOG_WARNING ("/deposit transaction commit failed\n"); TALER_LOG_WARNING ("/deposit transaction commit failed\n");
@ -217,13 +217,13 @@ TMH_DB_execute_withdraw_status (struct MHD_Connection *connection,
struct ReserveHistory *rh; struct ReserveHistory *rh;
int res; int res;
if (NULL == (session = plugin->get_session (plugin->cls, if (NULL == (session = TMH_plugin->get_session (TMH_plugin->cls,
GNUNET_NO))) GNUNET_NO)))
{ {
GNUNET_break (0); GNUNET_break (0);
return TMH_RESPONSE_reply_internal_db_error (connection); return TMH_RESPONSE_reply_internal_db_error (connection);
} }
rh = plugin->get_reserve_history (plugin->cls, rh = TMH_plugin->get_reserve_history (TMH_plugin->cls,
session, session,
reserve_pub); reserve_pub);
if (NULL == rh) if (NULL == rh)
@ -233,7 +233,7 @@ TMH_DB_execute_withdraw_status (struct MHD_Connection *connection,
"error", "Reserve not found"); "error", "Reserve not found");
res = TMH_RESPONSE_reply_withdraw_status_success (connection, res = TMH_RESPONSE_reply_withdraw_status_success (connection,
rh); rh);
plugin->free_reserve_history (plugin->cls, TMH_plugin->free_reserve_history (TMH_plugin->cls,
rh); rh);
return res; return res;
} }
@ -282,13 +282,13 @@ TMH_DB_execute_withdraw_sign (struct MHD_Connection *connection,
blinded_msg_len, blinded_msg_len,
&h_blind); &h_blind);
if (NULL == (session = plugin->get_session (plugin->cls, if (NULL == (session = TMH_plugin->get_session (TMH_plugin->cls,
GNUNET_NO))) GNUNET_NO)))
{ {
GNUNET_break (0); GNUNET_break (0);
return TMH_RESPONSE_reply_internal_db_error (connection); return TMH_RESPONSE_reply_internal_db_error (connection);
} }
res = plugin->get_collectable_blindcoin (plugin->cls, res = TMH_plugin->get_collectable_blindcoin (TMH_plugin->cls,
session, session,
&h_blind, &h_blind,
&collectable); &collectable);
@ -323,7 +323,7 @@ TMH_DB_execute_withdraw_sign (struct MHD_Connection *connection,
"Denomination not found"); "Denomination not found");
} }
if (GNUNET_OK != if (GNUNET_OK !=
plugin->start (plugin->cls, TMH_plugin->start (TMH_plugin->cls,
session)) session))
{ {
GNUNET_break (0); GNUNET_break (0);
@ -331,12 +331,12 @@ TMH_DB_execute_withdraw_sign (struct MHD_Connection *connection,
return TMH_RESPONSE_reply_internal_db_error (connection); return TMH_RESPONSE_reply_internal_db_error (connection);
} }
rh = plugin->get_reserve_history (plugin->cls, rh = TMH_plugin->get_reserve_history (TMH_plugin->cls,
session, session,
reserve); reserve);
if (NULL == rh) if (NULL == rh)
{ {
plugin->rollback (plugin->cls, TMH_plugin->rollback (TMH_plugin->cls,
session); session);
TMH_KS_release (key_state); TMH_KS_release (key_state);
return TMH_RESPONSE_reply_json_pack (connection, return TMH_RESPONSE_reply_json_pack (connection,
@ -357,7 +357,7 @@ TMH_DB_execute_withdraw_sign (struct MHD_Connection *connection,
&value, &value,
&fee_withdraw)) &fee_withdraw))
{ {
plugin->rollback (plugin->cls, TMH_plugin->rollback (TMH_plugin->cls,
session); session);
TMH_KS_release (key_state); TMH_KS_release (key_state);
return TMH_RESPONSE_reply_internal_db_error (connection); return TMH_RESPONSE_reply_internal_db_error (connection);
@ -378,7 +378,7 @@ TMH_DB_execute_withdraw_sign (struct MHD_Connection *connection,
&deposit_total, &deposit_total,
&pos->details.bank->amount)) &pos->details.bank->amount))
{ {
plugin->rollback (plugin->cls, TMH_plugin->rollback (TMH_plugin->cls,
session); session);
TMH_KS_release (key_state); TMH_KS_release (key_state);
return TMH_RESPONSE_reply_internal_db_error (connection); return TMH_RESPONSE_reply_internal_db_error (connection);
@ -398,7 +398,7 @@ TMH_DB_execute_withdraw_sign (struct MHD_Connection *connection,
&withdraw_total, &withdraw_total,
&value)) &value))
{ {
plugin->rollback (plugin->cls, TMH_plugin->rollback (TMH_plugin->cls,
session); session);
TMH_KS_release (key_state); TMH_KS_release (key_state);
return TMH_RESPONSE_reply_internal_db_error (connection); return TMH_RESPONSE_reply_internal_db_error (connection);
@ -416,15 +416,15 @@ TMH_DB_execute_withdraw_sign (struct MHD_Connection *connection,
&balance)) &balance))
{ {
TMH_KS_release (key_state); TMH_KS_release (key_state);
plugin->rollback (plugin->cls, TMH_plugin->rollback (TMH_plugin->cls,
session); session);
res = TMH_RESPONSE_reply_withdraw_sign_insufficient_funds (connection, res = TMH_RESPONSE_reply_withdraw_sign_insufficient_funds (connection,
rh); rh);
plugin->free_reserve_history (plugin->cls, TMH_plugin->free_reserve_history (TMH_plugin->cls,
rh); rh);
return res; return res;
} }
plugin->free_reserve_history (plugin->cls, TMH_plugin->free_reserve_history (TMH_plugin->cls,
rh); rh);
/* Balance is good, sign the coin! */ /* Balance is good, sign the coin! */
@ -435,7 +435,7 @@ TMH_DB_execute_withdraw_sign (struct MHD_Connection *connection,
if (NULL == sig) if (NULL == sig)
{ {
GNUNET_break (0); GNUNET_break (0);
plugin->rollback (plugin->cls, TMH_plugin->rollback (TMH_plugin->cls,
session); session);
return TMH_RESPONSE_reply_internal_error (connection, return TMH_RESPONSE_reply_internal_error (connection,
"Internal error"); "Internal error");
@ -448,7 +448,7 @@ TMH_DB_execute_withdraw_sign (struct MHD_Connection *connection,
&collectable.h_coin_envelope); &collectable.h_coin_envelope);
collectable.reserve_sig = *signature; collectable.reserve_sig = *signature;
if (GNUNET_OK != if (GNUNET_OK !=
plugin->insert_collectable_blindcoin (plugin->cls, TMH_plugin->insert_collectable_blindcoin (TMH_plugin->cls,
session, session,
&h_blind, &h_blind,
amount_required, amount_required,
@ -456,12 +456,12 @@ TMH_DB_execute_withdraw_sign (struct MHD_Connection *connection,
{ {
GNUNET_break (0); GNUNET_break (0);
GNUNET_CRYPTO_rsa_signature_free (sig); GNUNET_CRYPTO_rsa_signature_free (sig);
plugin->rollback (plugin->cls, TMH_plugin->rollback (TMH_plugin->cls,
session); session);
return TMH_RESPONSE_reply_internal_db_error (connection); return TMH_RESPONSE_reply_internal_db_error (connection);
} }
if (GNUNET_OK != if (GNUNET_OK !=
plugin->commit (plugin->cls, TMH_plugin->commit (TMH_plugin->cls,
session)) session))
{ {
TALER_LOG_WARNING ("/withdraw/sign transaction commit failed\n"); TALER_LOG_WARNING ("/withdraw/sign transaction commit failed\n");
@ -523,7 +523,7 @@ refresh_accept_melts (struct MHD_Connection *connection,
/* fee for THIS transaction; the melt amount includes the fee! */ /* fee for THIS transaction; the melt amount includes the fee! */
spent = coin_details->melt_amount_with_fee; spent = coin_details->melt_amount_with_fee;
/* add historic transaction costs of this coin */ /* add historic transaction costs of this coin */
tl = plugin->get_coin_transactions (plugin->cls, tl = TMH_plugin->get_coin_transactions (TMH_plugin->cls,
session, session,
&coin_public_info->coin_pub); &coin_public_info->coin_pub);
if (GNUNET_OK != if (GNUNET_OK !=
@ -532,7 +532,7 @@ refresh_accept_melts (struct MHD_Connection *connection,
&spent)) &spent))
{ {
GNUNET_break (0); GNUNET_break (0);
plugin->free_coin_transaction_list (plugin->cls, TMH_plugin->free_coin_transaction_list (TMH_plugin->cls,
tl); tl);
return TMH_RESPONSE_reply_internal_db_error (connection); return TMH_RESPONSE_reply_internal_db_error (connection);
} }
@ -553,11 +553,11 @@ refresh_accept_melts (struct MHD_Connection *connection,
coin_details->melt_amount_with_fee, coin_details->melt_amount_with_fee,
coin_residual)) coin_residual))
? GNUNET_NO : GNUNET_SYSERR; ? GNUNET_NO : GNUNET_SYSERR;
plugin->free_coin_transaction_list (plugin->cls, TMH_plugin->free_coin_transaction_list (TMH_plugin->cls,
tl); tl);
return res; return res;
} }
plugin->free_coin_transaction_list (plugin->cls, TMH_plugin->free_coin_transaction_list (TMH_plugin->cls,
tl); tl);
melt.coin = *coin_public_info; melt.coin = *coin_public_info;
@ -565,7 +565,7 @@ refresh_accept_melts (struct MHD_Connection *connection,
melt.session_hash = *session_hash; melt.session_hash = *session_hash;
melt.amount_with_fee = coin_details->melt_amount_with_fee; melt.amount_with_fee = coin_details->melt_amount_with_fee;
if (GNUNET_OK != if (GNUNET_OK !=
plugin->insert_refresh_melt (plugin->cls, TMH_plugin->insert_refresh_melt (TMH_plugin->cls,
session, session,
oldcoin_index, oldcoin_index,
&melt)) &melt))
@ -617,26 +617,26 @@ TMH_DB_execute_refresh_melt (struct MHD_Connection *connection,
int res; int res;
unsigned int i; unsigned int i;
if (NULL == (session = plugin->get_session (plugin->cls, if (NULL == (session = TMH_plugin->get_session (TMH_plugin->cls,
GNUNET_NO))) GNUNET_NO)))
{ {
GNUNET_break (0); GNUNET_break (0);
return TMH_RESPONSE_reply_internal_db_error (connection); return TMH_RESPONSE_reply_internal_db_error (connection);
} }
if (GNUNET_OK != if (GNUNET_OK !=
plugin->start (plugin->cls, TMH_plugin->start (TMH_plugin->cls,
session)) session))
{ {
GNUNET_break (0); GNUNET_break (0);
return TMH_RESPONSE_reply_internal_db_error (connection); return TMH_RESPONSE_reply_internal_db_error (connection);
} }
res = plugin->get_refresh_session (plugin->cls, res = TMH_plugin->get_refresh_session (TMH_plugin->cls,
session, session,
session_hash, session_hash,
&refresh_session); &refresh_session);
if (GNUNET_YES == res) if (GNUNET_YES == res)
{ {
plugin->rollback (plugin->cls, TMH_plugin->rollback (TMH_plugin->cls,
session); session);
res = TMH_RESPONSE_reply_refresh_melt_success (connection, res = TMH_RESPONSE_reply_refresh_melt_success (connection,
session_hash, session_hash,
@ -645,7 +645,7 @@ TMH_DB_execute_refresh_melt (struct MHD_Connection *connection,
} }
if (GNUNET_SYSERR == res) if (GNUNET_SYSERR == res)
{ {
plugin->rollback (plugin->cls, TMH_plugin->rollback (TMH_plugin->cls,
session); session);
return TMH_RESPONSE_reply_internal_db_error (connection); return TMH_RESPONSE_reply_internal_db_error (connection);
} }
@ -664,7 +664,7 @@ TMH_DB_execute_refresh_melt (struct MHD_Connection *connection,
i))) i)))
{ {
TMH_KS_release (key_state); TMH_KS_release (key_state);
plugin->rollback (plugin->cls, TMH_plugin->rollback (TMH_plugin->cls,
session); session);
return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES; return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES;
} }
@ -673,13 +673,13 @@ TMH_DB_execute_refresh_melt (struct MHD_Connection *connection,
/* store requested new denominations */ /* store requested new denominations */
if (GNUNET_OK != if (GNUNET_OK !=
plugin->insert_refresh_order (plugin->cls, TMH_plugin->insert_refresh_order (TMH_plugin->cls,
session, session,
session_hash, session_hash,
num_new_denoms, num_new_denoms,
denom_pubs)) denom_pubs))
{ {
plugin->rollback (plugin->cls, TMH_plugin->rollback (TMH_plugin->cls,
session); session);
return TMH_RESPONSE_reply_internal_db_error (connection); return TMH_RESPONSE_reply_internal_db_error (connection);
} }
@ -687,14 +687,14 @@ TMH_DB_execute_refresh_melt (struct MHD_Connection *connection,
for (i = 0; i < TALER_CNC_KAPPA; i++) for (i = 0; i < TALER_CNC_KAPPA; i++)
{ {
if (GNUNET_OK != if (GNUNET_OK !=
plugin->insert_refresh_commit_coins (plugin->cls, TMH_plugin->insert_refresh_commit_coins (TMH_plugin->cls,
session, session,
session_hash, session_hash,
i, i,
num_new_denoms, num_new_denoms,
commit_coin[i])) commit_coin[i]))
{ {
plugin->rollback (plugin->cls, TMH_plugin->rollback (TMH_plugin->cls,
session); session);
return TMH_RESPONSE_reply_internal_db_error (connection); return TMH_RESPONSE_reply_internal_db_error (connection);
} }
@ -702,14 +702,14 @@ TMH_DB_execute_refresh_melt (struct MHD_Connection *connection,
for (i = 0; i < TALER_CNC_KAPPA; i++) for (i = 0; i < TALER_CNC_KAPPA; i++)
{ {
if (GNUNET_OK != if (GNUNET_OK !=
plugin->insert_refresh_commit_links (plugin->cls, TMH_plugin->insert_refresh_commit_links (TMH_plugin->cls,
session, session,
session_hash, session_hash,
i, i,
coin_count, coin_count,
commit_link[i])) commit_link[i]))
{ {
plugin->rollback (plugin->cls, TMH_plugin->rollback (TMH_plugin->cls,
session); session);
return TMH_RESPONSE_reply_internal_db_error (connection); return TMH_RESPONSE_reply_internal_db_error (connection);
} }
@ -723,12 +723,12 @@ TMH_DB_execute_refresh_melt (struct MHD_Connection *connection,
= GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG,
TALER_CNC_KAPPA); TALER_CNC_KAPPA);
if (GNUNET_OK != if (GNUNET_OK !=
(res = plugin->create_refresh_session (plugin->cls, (res = TMH_plugin->create_refresh_session (TMH_plugin->cls,
session, session,
session_hash, session_hash,
&refresh_session))) &refresh_session)))
{ {
plugin->rollback (plugin->cls, TMH_plugin->rollback (TMH_plugin->cls,
session); session);
return TMH_RESPONSE_reply_internal_db_error (connection); return TMH_RESPONSE_reply_internal_db_error (connection);
} }
@ -736,7 +736,7 @@ TMH_DB_execute_refresh_melt (struct MHD_Connection *connection,
if (GNUNET_OK != if (GNUNET_OK !=
plugin->commit (plugin->cls, TMH_plugin->commit (TMH_plugin->cls,
session)) session))
{ {
TALER_LOG_WARNING ("/refresh/melt transaction commit failed\n"); TALER_LOG_WARNING ("/refresh/melt transaction commit failed\n");
@ -789,7 +789,7 @@ check_commitment (struct MHD_Connection *connection,
commit_links = GNUNET_malloc (num_oldcoins * commit_links = GNUNET_malloc (num_oldcoins *
sizeof (struct RefreshCommitLink)); sizeof (struct RefreshCommitLink));
if (GNUNET_OK != if (GNUNET_OK !=
plugin->get_refresh_commit_links (plugin->cls, TMH_plugin->get_refresh_commit_links (TMH_plugin->cls,
session, session,
session_hash, session_hash,
off, off,
@ -888,7 +888,7 @@ check_commitment (struct MHD_Connection *connection,
sizeof (struct RefreshCommitCoin)); sizeof (struct RefreshCommitCoin));
if (GNUNET_OK != if (GNUNET_OK !=
plugin->get_refresh_commit_coins (plugin->cls, TMH_plugin->get_refresh_commit_coins (TMH_plugin->cls,
session, session,
session_hash, session_hash,
off, off,
@ -1008,7 +1008,7 @@ refresh_mint_coin (struct MHD_Connection *connection,
return ev_sig; return ev_sig;
} }
if (GNUNET_OK != if (GNUNET_OK !=
plugin->insert_refresh_collectable (plugin->cls, TMH_plugin->insert_refresh_collectable (TMH_plugin->cls,
session, session,
session_hash, session_hash,
coin_off, coin_off,
@ -1054,14 +1054,14 @@ TMH_DB_execute_refresh_reveal (struct MHD_Connection *connection,
unsigned int j; unsigned int j;
unsigned int off; unsigned int off;
if (NULL == (session = plugin->get_session (plugin->cls, if (NULL == (session = TMH_plugin->get_session (TMH_plugin->cls,
GNUNET_NO))) GNUNET_NO)))
{ {
GNUNET_break (0); GNUNET_break (0);
return TMH_RESPONSE_reply_internal_db_error (connection); return TMH_RESPONSE_reply_internal_db_error (connection);
} }
res = plugin->get_refresh_session (plugin->cls, res = TMH_plugin->get_refresh_session (TMH_plugin->cls,
session, session,
session_hash, session_hash,
&refresh_session); &refresh_session);
@ -1081,7 +1081,7 @@ TMH_DB_execute_refresh_reveal (struct MHD_Connection *connection,
for (j=0;j<refresh_session.num_oldcoins;j++) for (j=0;j<refresh_session.num_oldcoins;j++)
{ {
if (GNUNET_OK != if (GNUNET_OK !=
plugin->get_refresh_melt (plugin->cls, TMH_plugin->get_refresh_melt (TMH_plugin->cls,
session, session,
session_hash, session_hash,
j, j,
@ -1095,7 +1095,7 @@ TMH_DB_execute_refresh_reveal (struct MHD_Connection *connection,
denom_pubs = GNUNET_malloc (refresh_session.num_newcoins * denom_pubs = GNUNET_malloc (refresh_session.num_newcoins *
sizeof (struct TALER_DenominationPublicKey)); sizeof (struct TALER_DenominationPublicKey));
if (GNUNET_OK != if (GNUNET_OK !=
plugin->get_refresh_order (plugin->cls, TMH_plugin->get_refresh_order (TMH_plugin->cls,
session, session,
session_hash, session_hash,
refresh_session.num_newcoins, refresh_session.num_newcoins,
@ -1136,7 +1136,7 @@ TMH_DB_execute_refresh_reveal (struct MHD_Connection *connection,
/* Client request OK, start transaction */ /* Client request OK, start transaction */
if (GNUNET_OK != if (GNUNET_OK !=
plugin->start (plugin->cls, TMH_plugin->start (TMH_plugin->cls,
session)) session))
{ {
GNUNET_break (0); GNUNET_break (0);
@ -1149,7 +1149,7 @@ TMH_DB_execute_refresh_reveal (struct MHD_Connection *connection,
commit_coins = GNUNET_malloc (refresh_session.num_newcoins * commit_coins = GNUNET_malloc (refresh_session.num_newcoins *
sizeof (struct RefreshCommitCoin)); sizeof (struct RefreshCommitCoin));
if (GNUNET_OK != if (GNUNET_OK !=
plugin->get_refresh_commit_coins (plugin->cls, TMH_plugin->get_refresh_commit_coins (TMH_plugin->cls,
session, session,
session_hash, session_hash,
refresh_session.noreveal_index, refresh_session.noreveal_index,
@ -1195,7 +1195,7 @@ TMH_DB_execute_refresh_reveal (struct MHD_Connection *connection,
GNUNET_free (commit_coins); GNUNET_free (commit_coins);
if (GNUNET_OK != if (GNUNET_OK !=
plugin->commit (plugin->cls, TMH_plugin->commit (TMH_plugin->cls,
session)) session))
{ {
TALER_LOG_WARNING ("/refresh/reveal transaction commit failed\n"); TALER_LOG_WARNING ("/refresh/reveal transaction commit failed\n");
@ -1234,13 +1234,13 @@ TMH_DB_execute_refresh_link (struct MHD_Connection *connection,
struct TALER_EncryptedLinkSecretP shared_secret_enc; struct TALER_EncryptedLinkSecretP shared_secret_enc;
struct LinkDataList *ldl; struct LinkDataList *ldl;
if (NULL == (session = plugin->get_session (plugin->cls, if (NULL == (session = TMH_plugin->get_session (TMH_plugin->cls,
GNUNET_NO))) GNUNET_NO)))
{ {
GNUNET_break (0); GNUNET_break (0);
return TMH_RESPONSE_reply_internal_db_error (connection); return TMH_RESPONSE_reply_internal_db_error (connection);
} }
res = plugin->get_transfer (plugin->cls, res = TMH_plugin->get_transfer (TMH_plugin->cls,
session, session,
coin_pub, coin_pub,
&transfer_pub, &transfer_pub,
@ -1260,7 +1260,7 @@ TMH_DB_execute_refresh_link (struct MHD_Connection *connection,
} }
GNUNET_assert (GNUNET_OK == res); GNUNET_assert (GNUNET_OK == res);
ldl = plugin->get_link_data_list (plugin->cls, ldl = TMH_plugin->get_link_data_list (TMH_plugin->cls,
session, session,
coin_pub); coin_pub);
if (NULL == ldl) if (NULL == ldl)
@ -1275,7 +1275,7 @@ TMH_DB_execute_refresh_link (struct MHD_Connection *connection,
&transfer_pub, &transfer_pub,
&shared_secret_enc, &shared_secret_enc,
ldl); ldl);
plugin->free_link_data_list (plugin->cls, TMH_plugin->free_link_data_list (TMH_plugin->cls,
ldl); ldl);
return res; return res;
} }

View File

@ -21,7 +21,6 @@
#ifndef TALER_MINT_HTTPD_DB_H #ifndef TALER_MINT_HTTPD_DB_H
#define TALER_MINT_HTTPD_DB_H #define TALER_MINT_HTTPD_DB_H
#include <libpq-fe.h>
#include <microhttpd.h> #include <microhttpd.h>
#include <gnunet/gnunet_util_lib.h> #include <gnunet/gnunet_util_lib.h>
#include "taler_util.h" #include "taler_util.h"

View File

@ -30,7 +30,6 @@
#include <gnunet/gnunet_util_lib.h> #include <gnunet/gnunet_util_lib.h>
#include <jansson.h> #include <jansson.h>
#include <microhttpd.h> #include <microhttpd.h>
#include <libpq-fe.h>
#include <pthread.h> #include <pthread.h>
#include "taler_mintdb_plugin.h" #include "taler_mintdb_plugin.h"
#include "taler_signatures.h" #include "taler_signatures.h"

View File

@ -26,7 +26,7 @@
#include <gnunet/gnunet_util_lib.h> #include <gnunet/gnunet_util_lib.h>
#include <microhttpd.h> #include <microhttpd.h>
#include "taler-mint-httpd.h" #include "taler-mint-httpd.h"
#include "key_io.h" #include "taler_mintdb_lib.h"
/** /**

View File

@ -27,7 +27,6 @@
#include <gnunet/gnunet_util_lib.h> #include <gnunet/gnunet_util_lib.h>
#include <jansson.h> #include <jansson.h>
#include <microhttpd.h> #include <microhttpd.h>
#include <libpq-fe.h>
#include <pthread.h> #include <pthread.h>
#include "taler-mint-httpd_responses.h" #include "taler-mint-httpd_responses.h"
#include "taler-mint-httpd.h" #include "taler-mint-httpd.h"

68
src/mintdb/Makefile.am Normal file
View File

@ -0,0 +1,68 @@
# This Makefile.am is in the public domain
AM_CPPFLAGS = -I$(top_srcdir)/src/include -I$(top_srcdir)/src/pq/ $(POSTGRESQL_CPPFLAGS)
plugindir = $(libdir)/taler
plugin_LTLIBRARIES = \
libtaler_plugin_mintdb_postgres.la
EXTRA_DIST = plugin_mintdb_common.c
libtaler_plugin_mintdb_postgres_la_SOURCES = \
plugin_mintdb_postgres.c
libtaler_plugin_mintdb_postgres_la_LIBADD = \
$(LTLIBINTL)
libtaler_plugin_mintdb_postgres_la_LDFLAGS = \
$(TALER_PLUGIN_LDFLAGS) \
-lpq \
-lgnunetutil
lib_LTLIBRARIES = \
libtalermintdb.la
libtalermintdb_la_SOURCES = \
mintdb_keyio.c \
mintdb_plugin.c
libtalermintdb_la_LIBADD = \
$(top_builddir)/src/util/libtalerutil.la \
-lgnunetutil
libtalermintdb_la_LDFLAGS = \
$(POSTGRESQL_LDFLAGS) \
-version-info 0:0:0 \
-no-undefined
check_PROGRAMS = \
test-mintdb-deposits \
test-mintdb-keyio \
test-mintdb-postgres
test_mintdb_deposits_SOURCES = \
test_mintdb_deposits.c
test_mintdb_deposits_LDADD = \
libtalermintdb.la \
$(top_srcdir)/src/util/libtalerutil.la \
$(top_srcdir)/src/pq/libtalerpq.la \
-lgnunetutil \
-ljansson \
-lpq
test_mintdb_keyio_SOURCES = \
test_mintdb_keyio.c
test_mintdb_keyio_LDADD = \
libtalermintdb.la \
$(top_srcdir)/src/util/libtalerutil.la \
$(top_srcdir)/src/pq/libtalerpq.la \
-lgnunetutil
test_mintdb_postgres_SOURCES = \
test_mintdb.c
test_mintdb_postgres_LDADD = \
libtalermintdb.la \
$(top_srcdir)/src/util/libtalerutil.la \
$(top_srcdir)/src/pq/libtalerpq.la \
-lgnunetutil -ljansson
EXTRA_test_mintdb_postgres_DEPENDENCIES = \
libtaler_plugin_mintdb_postgres.la

View File

@ -14,7 +14,7 @@
TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/> TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/>
*/ */
/** /**
* @file mint/key_io.c * @file mintdb/mintdb_keyio.c
* @brief I/O operations for the Mint's private keys * @brief I/O operations for the Mint's private keys
* @author Florian Dold * @author Florian Dold
* @author Benedikt Mueller * @author Benedikt Mueller
@ -22,7 +22,7 @@
* @author Christian Grothoff * @author Christian Grothoff
*/ */
#include "platform.h" #include "platform.h"
#include "key_io.h" #include "taler_mintdb_lib.h"
/** /**

View File

@ -14,20 +14,16 @@
TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/> TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/>
*/ */
/** /**
* @file mint/plugin.c * @file mintdb/mintdb_plugin.c
* @brief Logic to load database plugin * @brief Logic to load database plugin
* @author Christian Grothoff * @author Christian Grothoff
*/ */
#include "platform.h" #include "platform.h"
#include "plugin.h" #include "taler_mintdb_lib.h"
#include "taler_mintdb_plugin.h"
#include <ltdl.h> #include <ltdl.h>
/**
* Global variable with the plugin (once loaded).
*/
struct TALER_MINTDB_Plugin *plugin;
/** /**
* Libtool search path before we started. * Libtool search path before we started.
*/ */
@ -40,15 +36,14 @@ static char *old_dlsearchpath;
* @param cfg configuration to use * @param cfg configuration to use
* @return #GNUNET_OK on success * @return #GNUNET_OK on success
*/ */
int struct TALER_MINTDB_Plugin *
TALER_MINT_plugin_load (const struct GNUNET_CONFIGURATION_Handle *cfg) TALER_MINT_plugin_load (const struct GNUNET_CONFIGURATION_Handle *cfg)
{ {
char *plugin_name; char *plugin_name;
char *lib_name; char *lib_name;
struct GNUNET_CONFIGURATION_Handle *cfg_dup; struct GNUNET_CONFIGURATION_Handle *cfg_dup;
struct TALER_MINTDB_Plugin *plugin;
if (NULL != plugin)
return GNUNET_OK;
if (GNUNET_SYSERR == if (GNUNET_SYSERR ==
GNUNET_CONFIGURATION_get_value_string (cfg, GNUNET_CONFIGURATION_get_value_string (cfg,
"mint", "mint",
@ -58,7 +53,7 @@ TALER_MINT_plugin_load (const struct GNUNET_CONFIGURATION_Handle *cfg)
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"mint", "mint",
"db"); "db");
return GNUNET_SYSERR; return NULL;
} }
(void) GNUNET_asprintf (&lib_name, (void) GNUNET_asprintf (&lib_name,
"libtaler_plugin_mintdb_%s", "libtaler_plugin_mintdb_%s",
@ -66,24 +61,31 @@ TALER_MINT_plugin_load (const struct GNUNET_CONFIGURATION_Handle *cfg)
GNUNET_free (plugin_name); GNUNET_free (plugin_name);
cfg_dup = GNUNET_CONFIGURATION_dup (cfg); cfg_dup = GNUNET_CONFIGURATION_dup (cfg);
plugin = GNUNET_PLUGIN_load (lib_name, cfg_dup); plugin = GNUNET_PLUGIN_load (lib_name, cfg_dup);
GNUNET_CONFIGURATION_destroy (cfg_dup); if (NULL != plugin)
plugin->library_name = lib_name;
else
GNUNET_free (lib_name); GNUNET_free (lib_name);
if (NULL == plugin) GNUNET_CONFIGURATION_destroy (cfg_dup);
return GNUNET_SYSERR; return plugin;
return GNUNET_OK;
} }
/** /**
* Shutdown the plugin. * Shutdown the plugin.
*
* @param plugin the plugin to unload
*/ */
void void
TALER_MINT_plugin_unload () TALER_MINT_plugin_unload (struct TALER_MINTDB_Plugin *plugin)
{ {
char *lib_name;
if (NULL == plugin) if (NULL == plugin)
return; return;
GNUNET_assert (NULL == GNUNET_PLUGIN_unload (plugin->library_name, lib_name = plugin->library_name;
GNUNET_assert (NULL == GNUNET_PLUGIN_unload (lib_name,
plugin)); plugin));
GNUNET_free (lib_name);
} }

View File

@ -2299,7 +2299,6 @@ libtaler_plugin_mintdb_postgres_init (void *cls)
} }
plugin = GNUNET_new (struct TALER_MINTDB_Plugin); plugin = GNUNET_new (struct TALER_MINTDB_Plugin);
plugin->cls = pg; plugin->cls = pg;
plugin->library_name = "libtaler_plugin_mintdb_postgres";
plugin->get_session = &postgres_get_session; plugin->get_session = &postgres_get_session;
plugin->drop_temporary = &postgres_drop_temporary; plugin->drop_temporary = &postgres_drop_temporary;
plugin->create_tables = &postgres_create_tables; plugin->create_tables = &postgres_create_tables;