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/util/Makefile
src/pq/Makefile
src/mintdb/Makefile
src/mint/Makefile
src/lib/Makefile
src/mint-tools/Makefile
src/mint-lib/Makefile
])
AC_OUTPUT

View File

@ -1,3 +1,3 @@
# This Makefile.am is in the public domain
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_util.h \
taler_mint_service.h \
taler_mintdb_lib.h \
taler_mintdb_plugin.h \
taler_pq_lib.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/>
*/
/**
* @file mint/key_io.h
* @file include/taler_mintdb_lib.h
* @brief IO operations for the mint's private keys
* @author Florian Dold
* @author Benedikt Mueller
* @author Christian Grothoff
*/
#ifndef KEY_IO_H
#define KEY_IO_H
#ifndef TALER_MINTDB_LIB_H
#define TALER_MINTDB_LIB_H
#include <gnunet/gnunet_util_lib.h>
#include "taler_signatures.h"
@ -184,4 +184,24 @@ TALER_MINT_read_denom_key (const char *filename,
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

View File

@ -479,9 +479,10 @@ struct TALER_MINTDB_Plugin
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.

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

View File

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

View File

@ -24,7 +24,7 @@
#include <platform.h>
#include <gnunet/gnunet_util_lib.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

View File

@ -25,7 +25,7 @@
#include "taler_util.h"
#include "taler_signatures.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
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 = \
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
AM_CPPFLAGS = -I$(top_srcdir)/src/include
bin_PROGRAMS = \
taler-mint-keyup \
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
taler_mint_httpd_SOURCES = \
taler-mint-httpd.c \
@ -92,56 +18,8 @@ taler_mint_httpd_LDADD = \
$(LIBGCRYPT_LIBS) \
$(top_builddir)/src/util/libtalerutil.la \
$(top_builddir)/src/pq/libtalerpq.la \
$(top_builddir)/src/mint/libtalermint_common.la \
-lpq \
$(top_builddir)/src/mintdb/libtalermintdb.la \
-lmicrohttpd \
-ljansson \
-lgnunetutil \
-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 <jansson.h>
#include <microhttpd.h>
#include <libpq-fe.h>
#include <pthread.h>
#include "taler_signatures.h"
#include "taler_util.h"
@ -36,7 +35,6 @@
#include "taler-mint-httpd_refresh.h"
#include "taler-mint-httpd_keystate.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";
/**
* Our DB plugin.
*/
struct TALER_MINTDB_Plugin *TMH_plugin;
/**
* The HTTP Daemon.
*/
@ -260,8 +263,8 @@ mint_serve_process_config (const char *mint_directory)
}
GNUNET_free (TMH_master_public_key_str);
if (GNUNET_OK !=
TALER_MINT_plugin_load (cfg))
if (NULL ==
(TMH_plugin = TALER_MINT_plugin_load (cfg)))
{
fprintf (stderr,
"failed to initialize DB subsystem\n");
@ -355,5 +358,6 @@ main (int argc, char *const *argv)
ret = TMH_KS_loop ();
MHD_stop_daemon (mydaemon);
TALER_MINT_plugin_unload (TMH_plugin);
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;
/**
* Our DB plugin.
*/
extern struct TALER_MINTDB_Plugin *TMH_plugin;
/**
* Struct describing an URL and the handler for it.

View File

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

View File

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

View File

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

View File

@ -26,7 +26,7 @@
#include <gnunet/gnunet_util_lib.h>
#include <microhttpd.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 <jansson.h>
#include <microhttpd.h>
#include <libpq-fe.h>
#include <pthread.h>
#include "taler-mint-httpd_responses.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/>
*/
/**
* @file mint/key_io.c
* @file mintdb/mintdb_keyio.c
* @brief I/O operations for the Mint's private keys
* @author Florian Dold
* @author Benedikt Mueller
@ -22,7 +22,7 @@
* @author Christian Grothoff
*/
#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/>
*/
/**
* @file mint/plugin.c
* @file mintdb/mintdb_plugin.c
* @brief Logic to load database plugin
* @author Christian Grothoff
*/
#include "platform.h"
#include "plugin.h"
#include "taler_mintdb_lib.h"
#include "taler_mintdb_plugin.h"
#include <ltdl.h>
/**
* Global variable with the plugin (once loaded).
*/
struct TALER_MINTDB_Plugin *plugin;
/**
* Libtool search path before we started.
*/
@ -40,15 +36,14 @@ static char *old_dlsearchpath;
* @param cfg configuration to use
* @return #GNUNET_OK on success
*/
int
struct TALER_MINTDB_Plugin *
TALER_MINT_plugin_load (const struct GNUNET_CONFIGURATION_Handle *cfg)
{
char *plugin_name;
char *lib_name;
struct GNUNET_CONFIGURATION_Handle *cfg_dup;
struct TALER_MINTDB_Plugin *plugin;
if (NULL != plugin)
return GNUNET_OK;
if (GNUNET_SYSERR ==
GNUNET_CONFIGURATION_get_value_string (cfg,
"mint",
@ -58,7 +53,7 @@ TALER_MINT_plugin_load (const struct GNUNET_CONFIGURATION_Handle *cfg)
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"mint",
"db");
return GNUNET_SYSERR;
return NULL;
}
(void) GNUNET_asprintf (&lib_name,
"libtaler_plugin_mintdb_%s",
@ -66,24 +61,31 @@ TALER_MINT_plugin_load (const struct GNUNET_CONFIGURATION_Handle *cfg)
GNUNET_free (plugin_name);
cfg_dup = GNUNET_CONFIGURATION_dup (cfg);
plugin = GNUNET_PLUGIN_load (lib_name, cfg_dup);
if (NULL != plugin)
plugin->library_name = lib_name;
else
GNUNET_free (lib_name);
GNUNET_CONFIGURATION_destroy (cfg_dup);
GNUNET_free (lib_name);
if (NULL == plugin)
return GNUNET_SYSERR;
return GNUNET_OK;
return plugin;
}
/**
* Shutdown the plugin.
*
* @param plugin the plugin to unload
*/
void
TALER_MINT_plugin_unload ()
TALER_MINT_plugin_unload (struct TALER_MINTDB_Plugin *plugin)
{
char *lib_name;
if (NULL == plugin)
return;
GNUNET_assert (NULL == GNUNET_PLUGIN_unload (plugin->library_name,
lib_name = plugin->library_name;
GNUNET_assert (NULL == GNUNET_PLUGIN_unload (lib_name,
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->cls = pg;
plugin->library_name = "libtaler_plugin_mintdb_postgres";
plugin->get_session = &postgres_get_session;
plugin->drop_temporary = &postgres_drop_temporary;
plugin->create_tables = &postgres_create_tables;