[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-donau] branch master updated: [db] fix some errors
From: |
gnunet |
Subject: |
[taler-donau] branch master updated: [db] fix some errors |
Date: |
Mon, 04 Dec 2023 22:04:18 +0100 |
This is an automated email from the git hooks/post-receive script.
johannes-casaburi pushed a commit to branch master
in repository donau.
The following commit(s) were added to refs/heads/master by this push:
new 36a5d95 [db] fix some errors
36a5d95 is described below
commit 36a5d95a44c25ad1a14f905bd02ad26b33dca501
Author: Casaburi Johannes <johannes.casaburi@students.bfh.ch>
AuthorDate: Mon Dec 4 22:03:50 2023 +0100
[db] fix some errors
---
contrib/gana | 2 +-
src/donaudb/Makefile.am | 3 +-
src/donaudb/donaudb_plugin.c | 81 ++++++++--------
src/donaudb/donaudb_transactions.c | 190 -------------------------------------
src/include/donaudb_plugin.h | 161 +++++++++++++++++++++++++++++++
5 files changed, 204 insertions(+), 233 deletions(-)
diff --git a/contrib/gana b/contrib/gana
index 2ccbe6a..5570516 160000
--- a/contrib/gana
+++ b/contrib/gana
@@ -1 +1 @@
-Subproject commit 2ccbe6a28c86fb1618d30b3d76d9fd70c95203ae
+Subproject commit 557051695c575b45fb1bfdbacbc69d67c6908425
diff --git a/src/donaudb/Makefile.am b/src/donaudb/Makefile.am
index 7ab7674..313be19 100644
--- a/src/donaudb/Makefile.am
+++ b/src/donaudb/Makefile.am
@@ -88,8 +88,7 @@ lib_LTLIBRARIES = \
libtalerdonaudb.la
libtalerdonaudb_la_SOURCES = \
- donaudb_plugin.c \
- donaudb_transactions.c
+ donaudb_plugin.c
libtalerdonaudb_la_LIBADD = \
$(top_builddir)/src/util/libtalerdonauutil.la \
-lgnunetutil \
diff --git a/src/donaudb/donaudb_plugin.c b/src/donaudb/donaudb_plugin.c
index 40fd69e..a355656 100644
--- a/src/donaudb/donaudb_plugin.c
+++ b/src/donaudb/donaudb_plugin.c
@@ -21,53 +21,54 @@
*/
#include "taler/platform.h"
#include "donaudb_plugin.h"
+#include <gnunet/gnunet_db_lib.h>
#include <ltdl.h>
-// struct DONAUDB_Plugin *
-// DONAUDB_plugin_load (const struct GNUNET_CONFIGURATION_Handle *cfg)
-// {
-// char *plugin_name;
-// char *lib_name;
-// struct DONAUDB_Plugin *plugin;
+struct DONAUDB_Plugin *
+DONAUDB_plugin_load (const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+ char *plugin_name;
+ char *lib_name;
+ struct DONAUDB_Plugin *plugin;
-// if (GNUNET_SYSERR ==
-// GNUNET_CONFIGURATION_get_value_string (cfg,
-// "donau",
-// "db",
-// &plugin_name))
-// {
-// GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
-// "donau",
-// "db");
-// return NULL;
-// }
-// GNUNET_asprintf (&lib_name,
-// "libtaler_plugin_donaudb_%s",
-// plugin_name);
-// GNUNET_free (plugin_name);
-// plugin = GNUNET_PLUGIN_load (lib_name,
-// (void *) cfg);
-// if (NULL != plugin)
-// plugin->library_name = lib_name;
-// else
-// GNUNET_free (lib_name);
-// return plugin;
-// }
+ if (GNUNET_SYSERR ==
+ GNUNET_CONFIGURATION_get_value_string (cfg,
+ "donau",
+ "db",
+ &plugin_name))
+ {
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
+ "donau",
+ "db");
+ return NULL;
+ }
+ GNUNET_asprintf (&lib_name,
+ "libtaler_plugin_donaudb_%s",
+ plugin_name);
+ GNUNET_free (plugin_name);
+ plugin = GNUNET_PLUGIN_load (lib_name,
+ (void *) cfg);
+ if (NULL != plugin)
+ plugin->library_name = lib_name;
+ else
+ GNUNET_free (lib_name);
+ return plugin;
+}
-// void
-// DONAUDB_plugin_unload (struct DONAUDB_Plugin *plugin)
-// {
-// char *lib_name;
+void
+DONAUDB_plugin_unload (struct DONAUDB_Plugin *plugin)
+{
+ char *lib_name;
-// if (NULL == plugin)
-// return;
-// lib_name = plugin->library_name;
-// GNUNET_assert (NULL == GNUNET_PLUGIN_unload (lib_name,
-// plugin));
-// GNUNET_free (lib_name);
-// }
+ if (NULL == plugin)
+ return;
+ lib_name = plugin->library_name;
+ GNUNET_assert (NULL == GNUNET_PLUGIN_unload (lib_name,
+ plugin));
+ GNUNET_free (lib_name);
+}
/* end of donaudb_plugin.c */
diff --git a/src/donaudb/donaudb_transactions.c
b/src/donaudb/donaudb_transactions.c
deleted file mode 100644
index b26932c..0000000
--- a/src/donaudb/donaudb_transactions.c
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2017-2020 Taler Systems SA
-
- 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 CHARITYABILITY 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, see <http://www.gnu.org/licenses/>
-*/
-/**
- * @file donaudb/donaudb_transactions.c
- * @brief Logic to compute transaction totals of a transaction list for a coin
- * @author Christian Grothoff
- */
-#include "taler/platform.h"
-#include "donaudb_lib.h"
-
-
-// enum GNUNET_GenericReturnValue
-// DONAUDB_calculate_transaction_list_totals (
-// struct DONAUDB_TransactionList *tl,
-// const struct TALER_Amount *off,
-// struct TALER_Amount *ret)
-// {
-// struct TALER_Amount spent = *off;
-// struct TALER_Amount refunded;
-// struct TALER_Amount deposit_fee;
-// bool have_refund;
-
-// GNUNET_assert (GNUNET_OK ==
-// TALER_amount_set_zero (spent.currency,
-// &refunded));
-// have_refund = false;
-// for (struct DONAUDB_TransactionList *pos = tl;
-// NULL != pos;
-// pos = pos->next)
-// {
-// switch (pos->type)
-// {
-// case DONAUDB_TT_DEPOSIT:
-// /* spent += pos->amount_with_fee */
-// if (0 >
-// TALER_amount_add (&spent,
-// &spent,
-// &pos->details.deposit->amount_with_fee))
-// {
-// GNUNET_break (0);
-// return GNUNET_SYSERR;
-// }
-// deposit_fee = pos->details.deposit->deposit_fee;
-// break;
-// case DONAUDB_TT_MELT:
-// /* spent += pos->amount_with_fee */
-// if (0 >
-// TALER_amount_add (&spent,
-// &spent,
-// &pos->details.melt->amount_with_fee))
-// {
-// GNUNET_break (0);
-// return GNUNET_SYSERR;
-// }
-// break;
-// case DONAUDB_TT_REFUND:
-// /* refunded += pos->refund_amount - pos->refund_fee */
-// if (0 >
-// TALER_amount_add (&refunded,
-// &refunded,
-// &pos->details.refund->refund_amount))
-// {
-// GNUNET_break (0);
-// return GNUNET_SYSERR;
-// }
-// if (0 >
-// TALER_amount_add (&spent,
-// &spent,
-// &pos->details.refund->refund_fee))
-// {
-// GNUNET_break (0);
-// return GNUNET_SYSERR;
-// }
-// have_refund = true;
-// break;
-// case DONAUDB_TT_OLD_COIN_RECOUP:
-// /* refunded += pos->value */
-// if (0 >
-// TALER_amount_add (&refunded,
-// &refunded,
-// &pos->details.old_coin_recoup->value))
-// {
-// GNUNET_break (0);
-// return GNUNET_SYSERR;
-// }
-// break;
-// case DONAUDB_TT_RECOUP:
-// /* spent += pos->value */
-// if (0 >
-// TALER_amount_add (&spent,
-// &spent,
-// &pos->details.recoup->value))
-// {
-// GNUNET_break (0);
-// return GNUNET_SYSERR;
-// }
-// break;
-// case DONAUDB_TT_RECOUP_REFRESH:
-// /* spent += pos->value */
-// if (0 >
-// TALER_amount_add (&spent,
-// &spent,
-// &pos->details.recoup_refresh->value))
-// {
-// GNUNET_break (0);
-// return GNUNET_SYSERR;
-// }
-// break;
-// case DONAUDB_TT_PURSE_DEPOSIT:
-// /* spent += pos->amount_with_fee */
-// if (0 >
-// TALER_amount_add (&spent,
-// &spent,
-// &pos->details.purse_deposit->amount))
-// {
-// GNUNET_break (0);
-// return GNUNET_SYSERR;
-// }
-// deposit_fee = pos->details.purse_deposit->deposit_fee;
-// break;
-// case DONAUDB_TT_PURSE_REFUND:
-// /* refunded += pos->refund_amount - pos->refund_fee */
-// if (0 >
-// TALER_amount_add (&refunded,
-// &refunded,
-// &pos->details.purse_refund->refund_amount))
-// {
-// GNUNET_break (0);
-// return GNUNET_SYSERR;
-// }
-// if (0 >
-// TALER_amount_add (&spent,
-// &spent,
-// &pos->details.purse_refund->refund_fee))
-// {
-// GNUNET_break (0);
-// return GNUNET_SYSERR;
-// }
-// have_refund = true;
-// break;
-// case DONAUDB_TT_RESERVE_OPEN:
-// /* spent += pos->amount_with_fee */
-// if (0 >
-// TALER_amount_add (&spent,
-// &spent,
-// &pos->details.reserve_open->coin_contribution))
-// {
-// GNUNET_break (0);
-// return GNUNET_SYSERR;
-// }
-// break;
-// }
-// }
-// if (have_refund)
-// {
-// /* If we gave any refund, also discount ONE deposit fee */
-// if (0 >
-// TALER_amount_add (&refunded,
-// &refunded,
-// &deposit_fee))
-// {
-// GNUNET_break (0);
-// return GNUNET_SYSERR;
-// }
-// }
-// /* spent = spent - refunded */
-// if (0 >
-// TALER_amount_subtract (&spent,
-// &spent,
-// &refunded))
-// {
-// GNUNET_break (0);
-// return GNUNET_SYSERR;
-// }
-// *ret = spent;
-// return GNUNET_OK;
-// }
diff --git a/src/include/donaudb_plugin.h b/src/include/donaudb_plugin.h
index 4fbbdd7..73e777d 100644
--- a/src/include/donaudb_plugin.h
+++ b/src/include/donaudb_plugin.h
@@ -125,4 +125,165 @@ typedef void
const struct DONAUDB_SignkeyMetaData *meta);
+/**
+ * @brief The plugin API, returned from the plugin's "init" function.
+ * The argument given to "init" is simply a configuration handle.
+ */
+struct DONAUDB_Plugin
+{
+
+ /**
+ * Closure for all callbacks.
+ */
+ void *cls;
+
+ /**
+ * Name of the library which generated this plugin. Set by the
+ * plugin loader.
+ */
+ char *library_name;
+
+
+ /**
+ * Drop the Taler tables. This should only be used in testcases.
+ *
+ * @param cls the @e cls of this struct with the plugin-specific state
+ * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure
+ */
+ enum GNUNET_GenericReturnValue
+ (*drop_tables)(void *cls);
+
+ /**
+ * Create the necessary tables if they are not present
+ *
+ * @param cls the @e cls of this struct with the plugin-specific state
+ * @param support_partitions true to enable partitioning support (disables
foreign key constraints)
+ * @param num_partitions number of partitions to create,
+ * (0 to not actually use partitions, 1 to only
+ * setup a default partition, >1 for real partitions)
+ * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure
+ */
+ enum GNUNET_GenericReturnValue
+ (*create_tables)(void *cls,
+ bool support_partitions,
+ uint32_t num_partitions);
+
+
+ /**
+ * Start a transaction.
+ *
+ * @param cls the @e cls of this struct with the plugin-specific state
+ * @param name unique name identifying the transaction (for debugging),
+ * must point to a constant
+ * @return #GNUNET_OK on success
+ */
+ enum GNUNET_GenericReturnValue
+ (*start)(void *cls,
+ const char *name);
+
+
+ /**
+ * Start a READ COMMITTED transaction.
+ *
+ * @param cls the `struct PostgresClosure` with the plugin-specific state
+ * @param name unique name identifying the transaction (for debugging)
+ * must point to a constant
+ * @return #GNUNET_OK on success
+ */
+ enum GNUNET_GenericReturnValue
+ (*start_read_committed)(void *cls,
+ const char *name);
+
+ /**
+ * Start a READ ONLY serializable transaction.
+ *
+ * @param cls the `struct PostgresClosure` with the plugin-specific state
+ * @param name unique name identifying the transaction (for debugging)
+ * must point to a constant
+ * @return #GNUNET_OK on success
+ */
+ enum GNUNET_GenericReturnValue
+ (*start_read_only)(void *cls,
+ const char *name);
+
+
+ /**
+ * Commit a transaction.
+ *
+ * @param cls the @e cls of this struct with the plugin-specific state
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*commit)(void *cls);
+
+
+ /**
+ * Do a pre-flight check that we are not in an uncommitted transaction.
+ * If we are, try to commit the previous transaction and output a warning.
+ * Does not return anything, as we will continue regardless of the outcome.
+ *
+ * @param cls the `struct PostgresClosure` with the plugin-specific state
+ * @return #GNUNET_OK if everything is fine
+ * #GNUNET_NO if a transaction was rolled back
+ * #GNUNET_SYSERR on hard errors
+ */
+ enum GNUNET_GenericReturnValue
+ (*preflight)(void *cls);
+
+
+ /**
+ * Abort/rollback a transaction.
+ *
+ * @param cls the @e cls of this struct with the plugin-specific state
+ */
+ void
+ (*rollback) (void *cls);
+
+
+ /**
+ * Register callback to be invoked on events of type @a es.
+ *
+ * @param cls database context to use
+ * @param timeout how long to wait at most
+ * @param es specification of the event to listen for
+ * @param cb function to call when the event happens, possibly
+ * multiple times (until cancel is invoked)
+ * @param cb_cls closure for @a cb
+ * @return handle useful to cancel the listener
+ */
+ struct GNUNET_DB_EventHandler *
+ (*event_listen)(void *cls,
+ struct GNUNET_TIME_Relative timeout,
+ const struct GNUNET_DB_EventHeaderP *es,
+ GNUNET_DB_EventCallback cb,
+ void *cb_cls);
+
+ /**
+ * Stop notifications.
+ *
+ * @param cls database context to use
+ * @param eh handle to unregister.
+ */
+ void
+ (*event_listen_cancel)(void *cls,
+ struct GNUNET_DB_EventHandler *eh);
+
+
+ /**
+ * Notify all that listen on @a es of an event.
+ *
+ * @param cls database context to use
+ * @param es specification of the event to generate
+ * @param extra additional event data provided
+ * @param extra_size number of bytes in @a extra
+ */
+ void
+ (*event_notify)(void *cls,
+ const struct GNUNET_DB_EventHeaderP *es,
+ const void *extra,
+ size_t extra_size);
+
+};
+
+
#endif
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-donau] branch master updated: [db] fix some errors,
gnunet <=