gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-donau] branch master updated: [db] clean up and working on db fil


From: gnunet
Subject: [taler-donau] branch master updated: [db] clean up and working on db files
Date: Tue, 31 Oct 2023 09:50:31 +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 d8577c4  [db] clean up and working on db files
d8577c4 is described below

commit d8577c4c2a98ef5b8ea3c526d1d4a46853ce700a
Author: Casaburi Johannes <johannes.casaburi@students.bfh.ch>
AuthorDate: Tue Oct 31 09:49:54 2023 +0100

    [db] clean up and working on db files
---
 aclocal.m4                                         |  90 ++----------
 src/donaudb/pg_ensure_coin_known.c                 | 156 ---------------------
 src/donaudb/pg_ensure_coin_known.h                 |  44 ------
 src/donaudb/pg_gc.c                                |  80 -----------
 src/donaudb/pg_gc.h                                |  39 ------
 src/donaudb/pg_get_known_coin.c                    |  71 ----------
 src/donaudb/pg_get_known_coin.h                    |  40 ------
 src/donaudb/pg_helper.h                            |  32 +----
 src/donaudb/pg_insert_issued_receipt.h             |  10 +-
 src/donaudb/pg_lookup_denomination_key.c           |  83 -----------
 src/donaudb/pg_lookup_donation_unit_key.c          |  62 ++++++++
 ...ination_key.h => pg_lookup_donation_unit_key.h} |  22 +--
 12 files changed, 90 insertions(+), 639 deletions(-)

diff --git a/aclocal.m4 b/aclocal.m4
index 17f4822..a31ef3e 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -20,7 +20,7 @@ You have another version of autoconf.  It may work, but is 
not guaranteed to.
 If you have problems, you may need to regenerate the build system entirely.
 To do so, use the procedure documented by the package, typically 
'autoreconf'.])])
 
-# pkg.m4 - Macros to locate and use pkg-config.   -*- Autoconf -*-
+# pkg.m4 - Macros to locate and utilise pkg-config.   -*- Autoconf -*-
 # serial 12 (pkg-config-0.29.2)
 
 dnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
@@ -108,7 +108,7 @@ dnl Check to see whether a particular set of modules 
exists. Similar to
 dnl PKG_CHECK_MODULES(), but does not set variables or print errors.
 dnl
 dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
-dnl only at the first occurrence in configure.ac, so if the first place
+dnl only at the first occurence in configure.ac, so if the first place
 dnl it's called might be skipped (such as if it is within an "if", you
 dnl have to call PKG_CHECK_EXISTS manually
 AC_DEFUN([PKG_CHECK_EXISTS],
@@ -177,14 +177,14 @@ if test $pkg_failed = yes; then
         AC_MSG_RESULT([no])
         _PKG_SHORT_ERRORS_SUPPORTED
         if test $_pkg_short_errors_supported = yes; then
-                $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors 
--cflags --libs "$2" 2>&1`
+               $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors 
--cflags --libs "$2" 2>&1`
         else
-                $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs 
"$2" 2>&1`
+               $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs 
"$2" 2>&1`
         fi
-        # Put the nasty error message in config.log where it belongs
-        echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
+       # Put the nasty error message in config.log where it belongs
+       echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
 
-        m4_default([$4], [AC_MSG_ERROR(
+       m4_default([$4], [AC_MSG_ERROR(
 [Package requirements ($2) were not met:
 
 $$1_PKG_ERRORS
@@ -196,7 +196,7 @@ _PKG_TEXT])[]dnl
         ])
 elif test $pkg_failed = untried; then
         AC_MSG_RESULT([no])
-        m4_default([$4], [AC_MSG_FAILURE(
+       m4_default([$4], [AC_MSG_FAILURE(
 [The pkg-config script could not be found or is too old.  Make sure it
 is in your PATH or set the PKG_CONFIG environment variable to the full
 path to pkg-config.
@@ -206,10 +206,10 @@ _PKG_TEXT
 To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl
         ])
 else
-        $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
-        $1[]_LIBS=$pkg_cv_[]$1[]_LIBS
+       $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
+       $1[]_LIBS=$pkg_cv_[]$1[]_LIBS
         AC_MSG_RESULT([yes])
-        $3
+       $3
 fi[]dnl
 ])dnl PKG_CHECK_MODULES
 
@@ -296,74 +296,6 @@ AS_VAR_COPY([$1], [pkg_cv_][$1])
 AS_VAR_IF([$1], [""], [$5], [$4])dnl
 ])dnl PKG_CHECK_VAR
 
-dnl PKG_WITH_MODULES(VARIABLE-PREFIX, MODULES,
-dnl   [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND],
-dnl   [DESCRIPTION], [DEFAULT])
-dnl ------------------------------------------
-dnl
-dnl Prepare a "--with-" configure option using the lowercase
-dnl [VARIABLE-PREFIX] name, merging the behaviour of AC_ARG_WITH and
-dnl PKG_CHECK_MODULES in a single macro.
-AC_DEFUN([PKG_WITH_MODULES],
-[
-m4_pushdef([with_arg], m4_tolower([$1]))
-
-m4_pushdef([description],
-           [m4_default([$5], [build with ]with_arg[ support])])
-
-m4_pushdef([def_arg], [m4_default([$6], [auto])])
-m4_pushdef([def_action_if_found], [AS_TR_SH([with_]with_arg)=yes])
-m4_pushdef([def_action_if_not_found], [AS_TR_SH([with_]with_arg)=no])
-
-m4_case(def_arg,
-            [yes],[m4_pushdef([with_without], [--without-]with_arg)],
-            [m4_pushdef([with_without],[--with-]with_arg)])
-
-AC_ARG_WITH(with_arg,
-     AS_HELP_STRING(with_without, description[ @<:@default=]def_arg[@:>@]),,
-    [AS_TR_SH([with_]with_arg)=def_arg])
-
-AS_CASE([$AS_TR_SH([with_]with_arg)],
-            [yes],[PKG_CHECK_MODULES([$1],[$2],$3,$4)],
-            [auto],[PKG_CHECK_MODULES([$1],[$2],
-                                        [m4_n([def_action_if_found]) $3],
-                                        [m4_n([def_action_if_not_found]) $4])])
-
-m4_popdef([with_arg])
-m4_popdef([description])
-m4_popdef([def_arg])
-
-])dnl PKG_WITH_MODULES
-
-dnl PKG_HAVE_WITH_MODULES(VARIABLE-PREFIX, MODULES,
-dnl   [DESCRIPTION], [DEFAULT])
-dnl -----------------------------------------------
-dnl
-dnl Convenience macro to trigger AM_CONDITIONAL after PKG_WITH_MODULES
-dnl check._[VARIABLE-PREFIX] is exported as make variable.
-AC_DEFUN([PKG_HAVE_WITH_MODULES],
-[
-PKG_WITH_MODULES([$1],[$2],,,[$3],[$4])
-
-AM_CONDITIONAL([HAVE_][$1],
-               [test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"])
-])dnl PKG_HAVE_WITH_MODULES
-
-dnl PKG_HAVE_DEFINE_WITH_MODULES(VARIABLE-PREFIX, MODULES,
-dnl   [DESCRIPTION], [DEFAULT])
-dnl ------------------------------------------------------
-dnl
-dnl Convenience macro to run AM_CONDITIONAL and AC_DEFINE after
-dnl PKG_WITH_MODULES check. HAVE_[VARIABLE-PREFIX] is exported as make
-dnl and preprocessor variable.
-AC_DEFUN([PKG_HAVE_DEFINE_WITH_MODULES],
-[
-PKG_HAVE_WITH_MODULES([$1],[$2],[$3],[$4])
-
-AS_IF([test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"],
-        [AC_DEFINE([HAVE_][$1], 1, [Enable ]m4_tolower([$1])[ support])])
-])dnl PKG_HAVE_DEFINE_WITH_MODULES
-
 # Copyright (C) 2002-2021 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
diff --git a/src/donaudb/pg_ensure_coin_known.c 
b/src/donaudb/pg_ensure_coin_known.c
deleted file mode 100644
index d973e03..0000000
--- a/src/donaudb/pg_ensure_coin_known.c
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
-   This file is part of TALER
-   Copyright (C) 2022 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/pg_ensure_coin_known.c
- * @brief Implementation of the ensure_coin_known function for Postgres
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "taler_error_codes.h"
-#include "taler_dbevents.h"
-#include "taler_pq_lib.h"
-#include "pg_ensure_coin_known.h"
-#include "pg_helper.h"
-
-
-enum TALER_DONAUDB_CoinKnownStatus
-TEH_PG_ensure_coin_known (void *cls,
-                          const struct TALER_CoinPublicInfo *coin,
-                          uint64_t *known_coin_id,
-                          struct TALER_DenominationHashP *denom_hash,
-                          struct TALER_AgeCommitmentHash *h_age_commitment)
-{
-  struct PostgresClosure *pg = cls;
-  enum GNUNET_DB_QueryStatus qs;
-  bool existed;
-  bool is_denom_pub_hash_null = false;
-  bool is_age_hash_null = false;
-  struct GNUNET_PQ_QueryParam params[] = {
-    GNUNET_PQ_query_param_auto_from_type (&coin->coin_pub),
-    GNUNET_PQ_query_param_auto_from_type (&coin->denom_pub_hash),
-    coin->no_age_commitment
-    ? GNUNET_PQ_query_param_null ()
-    : GNUNET_PQ_query_param_auto_from_type (&coin->h_age_commitment),
-    TALER_PQ_query_param_denom_sig (&coin->denom_sig),
-    GNUNET_PQ_query_param_end
-  };
-  struct GNUNET_PQ_ResultSpec rs[] = {
-    GNUNET_PQ_result_spec_bool ("existed",
-                                &existed),
-    GNUNET_PQ_result_spec_uint64 ("known_coin_id",
-                                  known_coin_id),
-    GNUNET_PQ_result_spec_allow_null (
-      GNUNET_PQ_result_spec_auto_from_type ("denom_pub_hash",
-                                            denom_hash),
-      &is_denom_pub_hash_null),
-    GNUNET_PQ_result_spec_allow_null (
-      GNUNET_PQ_result_spec_auto_from_type ("age_commitment_hash",
-                                            h_age_commitment),
-      &is_age_hash_null),
-    GNUNET_PQ_result_spec_end
-  };
-
-  /*
-     See also:
-     
https://stackoverflow.com/questions/34708509/how-to-use-returning-with-on-conflict-in-postgresql/37543015#37543015
-  */
-  PREPARE (pg,
-           "insert_known_coin",
-           "WITH dd"
-           "  (denominations_serial"
-           "  ,coin"
-           "  ) AS ("
-           "    SELECT "
-           "       denominations_serial"
-           "      ,coin"
-           "        FROM denominations"
-           "        WHERE denom_pub_hash=$2"
-           "  ), input_rows"
-           "    (coin_pub) AS ("
-           "      VALUES ($1::BYTEA)"
-           "  ), ins AS ("
-           "  INSERT INTO known_coins "
-           "  (coin_pub"
-           "  ,denominations_serial"
-           "  ,age_commitment_hash"
-           "  ,denom_sig"
-           "  ,remaining"
-           "  ) SELECT "
-           "     $1"
-           "    ,denominations_serial"
-           "    ,$3"
-           "    ,$4"
-           "    ,coin"
-           "  FROM dd"
-           "  ON CONFLICT DO NOTHING" /* CONFLICT on (coin_pub) */
-           "  RETURNING "
-           "     known_coin_id"
-           "  ) "
-           "SELECT "
-           "   FALSE AS existed"
-           "  ,known_coin_id"
-           "  ,NULL AS denom_pub_hash"
-           "  ,NULL AS age_commitment_hash"
-           "  FROM ins "
-           "UNION ALL "
-           "SELECT "
-           "   TRUE AS existed"
-           "  ,known_coin_id"
-           "  ,denom_pub_hash"
-           "  ,kc.age_commitment_hash"
-           "  FROM input_rows"
-           "  JOIN known_coins kc USING (coin_pub)"
-           "  JOIN denominations USING (denominations_serial)"
-           "  LIMIT 1");
-  qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
-                                                 "insert_known_coin",
-                                                 params,
-                                                 rs);
-  switch (qs)
-  {
-  case GNUNET_DB_STATUS_HARD_ERROR:
-    GNUNET_break (0);
-    return TALER_DONAUDB_CKS_HARD_FAIL;
-  case GNUNET_DB_STATUS_SOFT_ERROR:
-    return TALER_DONAUDB_CKS_SOFT_FAIL;
-  case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
-    GNUNET_break (0); /* should be impossible */
-    return TALER_DONAUDB_CKS_HARD_FAIL;
-  case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
-    if (! existed)
-      return TALER_DONAUDB_CKS_ADDED;
-    break; /* continued below */
-  }
-
-  if ( (! is_denom_pub_hash_null) &&
-       (0 != GNUNET_memcmp (&denom_hash->hash,
-                            &coin->denom_pub_hash.hash)) )
-  {
-    GNUNET_break_op (0);
-    return TALER_DONAUDB_CKS_DENOM_CONFLICT;
-  }
-
-  if ( (! is_age_hash_null) &&
-       (0 != GNUNET_memcmp (h_age_commitment,
-                            &coin->h_age_commitment)) )
-  {
-    GNUNET_break (GNUNET_is_zero (h_age_commitment));
-    GNUNET_break_op (0);
-    return TALER_DONAUDB_CKS_AGE_CONFLICT;
-  }
-
-  return TALER_DONAUDB_CKS_PRESENT;
-}
diff --git a/src/donaudb/pg_ensure_coin_known.h 
b/src/donaudb/pg_ensure_coin_known.h
deleted file mode 100644
index 89137a7..0000000
--- a/src/donaudb/pg_ensure_coin_known.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
-   This file is part of TALER
-   Copyright (C) 2022 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/pg_ensure_coin_known.h
- * @brief implementation of the ensure_coin_known function for Postgres
- * @author Christian Grothoff
- */
-#ifndef PG_ENSURE_COIN_KNOWN_H
-#define PG_ENSURE_COIN_KNOWN_H
-
-#include "taler_util.h"
-#include "taler_json_lib.h"
-#include "taler_donaudb_plugin.h"
-/**
- * Make sure the given @a donation unit is known to the database.
- *
- * @param cls database connection plugin state
- * @param coin the coin that must be made known
- * @param[out] known_coin_id set to the unique row of the coin
- * @param[out] denom_hash set to the denomination hash of the existing
- *             coin (for conflict error reporting)
- * @param[out] h_age_commitment  set to the conflicting age commitment hash on 
conflict
- * @return database transaction status, non-negative on success
- */
-enum TALER_DONAUDB_CoinKnownStatus
-TEH_PG_ensure_coin_known (void *cls,
-                          const struct TALER_CoinPublicInfo *coin,
-                          uint64_t *known_coin_id,
-                          struct TALER_DenominationHashP *denom_hash);
-
-#endif
diff --git a/src/donaudb/pg_gc.c b/src/donaudb/pg_gc.c
deleted file mode 100644
index 02383fe..0000000
--- a/src/donaudb/pg_gc.c
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
-   This file is part of TALER
-   Copyright (C) 2022 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/pg_gc.c
- * @brief Implementation of the gc function for Postgres
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "taler_error_codes.h"
-#include "taler_dbevents.h"
-#include "taler_pq_lib.h"
-#include "pg_gc.h"
-#include "pg_helper.h"
-
-
-enum GNUNET_GenericReturnValue
-TEH_PG_gc (void *cls)
-{
-  struct PostgresClosure *pg = cls;
-  struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
-  struct GNUNET_TIME_Absolute long_ago;
-  struct GNUNET_PQ_QueryParam params[] = {
-    GNUNET_PQ_query_param_absolute_time (&long_ago),
-    GNUNET_PQ_query_param_absolute_time (&now),
-    GNUNET_PQ_query_param_end
-  };
-  struct GNUNET_PQ_Context *conn;
-  enum GNUNET_GenericReturnValue ret;
-
-  /* Keep wire fees for 10 years, that should always
-     be enough _and_ they are tiny so it does not
-     matter to make this tight */
-  long_ago = GNUNET_TIME_absolute_subtract (
-    now,
-    GNUNET_TIME_relative_multiply (
-      GNUNET_TIME_UNIT_YEARS,
-      10));
-  {
-    struct GNUNET_PQ_ExecuteStatement es[] = {
-      GNUNET_PQ_make_try_execute ("SET search_path TO donau;"),
-      GNUNET_PQ_EXECUTE_STATEMENT_END
-    };
-    struct GNUNET_PQ_PreparedStatement ps[] = {
-      /* Used in #postgres_gc() */
-      GNUNET_PQ_make_prepare ("run_gc",
-                              "CALL"
-                              " donau_do_gc"
-                              " ($1,$2);"),
-      GNUNET_PQ_PREPARED_STATEMENT_END
-    };
-
-    conn = GNUNET_PQ_connect_with_cfg (pg->cfg,
-                                       "donaudb-postgres",
-                                       NULL,
-                                       es,
-                                       ps);
-  }
-  if (NULL == conn)
-    return GNUNET_SYSERR;
-  ret = GNUNET_OK;
-  if (0 > GNUNET_PQ_eval_prepared_non_select (conn,
-                                              "run_gc",
-                                              params))
-    ret = GNUNET_SYSERR;
-  GNUNET_PQ_disconnect (conn);
-  return ret;
-}
diff --git a/src/donaudb/pg_gc.h b/src/donaudb/pg_gc.h
deleted file mode 100644
index a6f32b2..0000000
--- a/src/donaudb/pg_gc.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
-   This file is part of TALER
-   Copyright (C) 2022 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/pg_gc.h
- * @brief implementation of the gc function for Postgres
- * @author Christian Grothoff
- */
-#ifndef PG_GC_H
-#define PG_GC_H
-
-#include "taler_util.h"
-#include "taler_json_lib.h"
-#include "taler_donaudb_plugin.h"
-
-/**
- * Function called to perform "garbage collection" on the
- * database, expiring records we no longer require.
- *
- * @param cls closure
- * @return #GNUNET_OK on success,
- *         #GNUNET_SYSERR on DB errors
- */
-enum GNUNET_GenericReturnValue
-TEH_PG_gc (void *cls);
-
-#endif
diff --git a/src/donaudb/pg_get_known_coin.c b/src/donaudb/pg_get_known_coin.c
deleted file mode 100644
index e3d1c4e..0000000
--- a/src/donaudb/pg_get_known_coin.c
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
-   This file is part of TALER
-   Copyright (C) 2022 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/pg_get_known_coin.c
- * @brief Implementation of the get_known_coin function for Postgres
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "taler_error_codes.h"
-#include "taler_dbevents.h"
-#include "taler_pq_lib.h"
-#include "pg_get_known_coin.h"
-#include "pg_helper.h"
-
-enum GNUNET_DB_QueryStatus
-TEH_PG_get_known_coin (void *cls,
-                       const struct TALER_CoinSpendPublicKeyP *coin_pub,
-                       struct TALER_CoinPublicInfo *coin_info)
-{
-  struct PostgresClosure *pg = cls;
-  struct GNUNET_PQ_QueryParam params[] = {
-    GNUNET_PQ_query_param_auto_from_type (coin_pub),
-    GNUNET_PQ_query_param_end
-  };
-  struct GNUNET_PQ_ResultSpec rs[] = {
-    GNUNET_PQ_result_spec_auto_from_type ("denom_pub_hash",
-                                          &coin_info->denom_pub_hash),
-    GNUNET_PQ_result_spec_allow_null (
-      GNUNET_PQ_result_spec_auto_from_type ("age_commitment_hash",
-                                            &coin_info->h_age_commitment),
-      &coin_info->no_age_commitment),
-    TALER_PQ_result_spec_denom_sig ("denom_sig",
-                                    &coin_info->denom_sig),
-    GNUNET_PQ_result_spec_end
-  };
-
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Getting known coin data for coin %s\n",
-              TALER_B2S (coin_pub));
-  coin_info->coin_pub = *coin_pub;
-  /* Used in #postgres_get_known_coin() to fetch
-     the denomination public key and signature for
-     a coin known to the donau. */
-  PREPARE (pg,
-           "get_known_coin",
-           "SELECT"
-           " denominations.denom_pub_hash"
-           ",age_commitment_hash"
-           ",denom_sig"
-           " FROM known_coins"
-           " JOIN denominations USING (denominations_serial)"
-           " WHERE coin_pub=$1;");
-
-  return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
-                                                   "get_known_coin",
-                                                   params,
-                                                   rs);
-}
diff --git a/src/donaudb/pg_get_known_coin.h b/src/donaudb/pg_get_known_coin.h
deleted file mode 100644
index dcbbc82..0000000
--- a/src/donaudb/pg_get_known_coin.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
-   This file is part of TALER
-   Copyright (C) 2022 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/pg_get_known_coin.h
- * @brief implementation of the get_known_coin function for Postgres
- * @author Christian Grothoff
- */
-#ifndef PG_GET_KNOWN_COIN_H
-#define PG_GET_KNOWN_COIN_H
-
-#include "taler_util.h"
-#include "taler_json_lib.h"
-#include "taler_donaudb_plugin.h"
-/**
- * Retrieve the record for a known coin.
- *
- * @param cls the plugin closure
- * @param coin_pub the public key of the coin to search for
- * @param coin_info place holder for the returned coin information object
- * @return transaction status code
- */
-enum GNUNET_DB_QueryStatus
-TEH_PG_get_known_coin (void *cls,
-                       const struct TALER_CoinSpendPublicKeyP *coin_pub,
-                       struct TALER_CoinPublicInfo *coin_info);
-
-#endif
diff --git a/src/donaudb/pg_helper.h b/src/donaudb/pg_helper.h
index dcf5b48..b17be81 100644
--- a/src/donaudb/pg_helper.h
+++ b/src/donaudb/pg_helper.h
@@ -1,6 +1,6 @@
 /*
    This file is part of TALER
-   Copyright (C) 2022 Taler Systems SA
+   Copyright (C) 2023 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
@@ -16,7 +16,7 @@
 /**
  * @file pg_helper.h
  * @brief shared internal definitions for postgres DB plugin
- * @author Christian Grothoff
+ * @author Johannes Casaburi
  */
 #ifndef PG_HELPER_H
 #define PG_HELPER_H
@@ -39,23 +39,6 @@ struct PostgresClosure
    */
   char *sql_dir;
 
-  /**
-   * After how long should idle reserves be closed?
-   */
-  struct GNUNET_TIME_Relative idle_reserve_expiration_time;
-
-  /**
-   * After how long should reserves that have seen withdraw operations
-   * be garbage collected?
-   */
-  struct GNUNET_TIME_Relative legal_reserve_expiration_time;
-
-  /**
-   * What delay should we introduce before ready transactions
-   * are actually aggregated?
-   */
-  struct GNUNET_TIME_Relative aggregator_shift;
-
   /**
    * Which currency should we assume all amounts to be in?
    */
@@ -71,23 +54,12 @@ struct PostgresClosure
    */
   struct GNUNET_PQ_Context *conn;
 
-  /**
-   * Name of the current transaction, for debugging.
-   */
-  const char *transaction_name;
-
   /**
    * Counts how often we have established a fresh @e conn
    * to the database. Used to re-prepare statements.
    */
   unsigned long long prep_gen;
 
-  /**
-   * Number of purses we allow to be opened concurrently
-   * for one year per annual fee payment.
-   */
-  uint32_t def_purse_limit;
-
 };
 
 
diff --git a/src/donaudb/pg_insert_issued_receipt.h 
b/src/donaudb/pg_insert_issued_receipt.h
index eec9a10..1271f7b 100644
--- a/src/donaudb/pg_insert_issued_receipt.h
+++ b/src/donaudb/pg_insert_issued_receipt.h
@@ -29,15 +29,13 @@
  * Insert information about an auditor that will audit this exchange.
  *
  * @param cls closure
- * @param auditor_pub key of the auditor
- * @param auditor_url base URL of the auditor's REST service
- * @param auditor_name name of the auditor (for humans)
- * @param start_date date when the auditor was added by the offline system
- *                      (only to be used for replay detection)
+ * @param charity_sig signature from the charity
+ * @param charity_id identifier of the charity
+ * @param h_receipt hash of the donation receipt
  * @return transaction status code
  */
 enum GNUNET_DB_QueryStatus
-TEH_PG_insert_auditor (void *cls,
+TEH_PG_insert_issued_receipt (void *cls,
                        const struct TALER_CharitySignatureP *charity_sig,
                        const uint64_t charity_id,
                        const struct TALER_DonationReceiptHashP *h_receipt,
diff --git a/src/donaudb/pg_lookup_denomination_key.c 
b/src/donaudb/pg_lookup_denomination_key.c
deleted file mode 100644
index cbf8fc5..0000000
--- a/src/donaudb/pg_lookup_denomination_key.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
-   This file is part of TALER
-   Copyright (C) 2022 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/pg_lookup_denomination_key.c
- * @brief Implementation of the lookup_denomination_key function for Postgres
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "taler_error_codes.h"
-#include "taler_dbevents.h"
-#include "taler_pq_lib.h"
-#include "pg_lookup_denomination_key.h"
-#include "pg_helper.h"
-
-enum GNUNET_DB_QueryStatus
-TEH_PG_lookup_denomination_key (
-  void *cls,
-  const struct TALER_DenominationHashP *h_denom_pub,
-  struct TALER_DONAUDB_DenominationKeyMetaData *meta)
-{
-  struct PostgresClosure *pg = cls;
-  struct GNUNET_PQ_QueryParam params[] = {
-    GNUNET_PQ_query_param_auto_from_type (h_denom_pub),
-    GNUNET_PQ_query_param_end
-  };
-  struct GNUNET_PQ_ResultSpec rs[] = {
-    GNUNET_PQ_result_spec_timestamp ("valid_from",
-                                     &meta->start),
-    GNUNET_PQ_result_spec_timestamp ("expire_withdraw",
-                                     &meta->expire_withdraw),
-    GNUNET_PQ_result_spec_timestamp ("expire_deposit",
-                                     &meta->expire_deposit),
-    GNUNET_PQ_result_spec_timestamp ("expire_legal",
-                                     &meta->expire_legal),
-    TALER_PQ_RESULT_SPEC_AMOUNT ("coin",
-                                 &meta->value),
-    TALER_PQ_RESULT_SPEC_AMOUNT ("fee_withdraw",
-                                 &meta->fees.withdraw),
-    TALER_PQ_RESULT_SPEC_AMOUNT ("fee_deposit",
-                                 &meta->fees.deposit),
-    TALER_PQ_RESULT_SPEC_AMOUNT ("fee_refresh",
-                                 &meta->fees.refresh),
-    TALER_PQ_RESULT_SPEC_AMOUNT ("fee_refund",
-                                 &meta->fees.refund),
-    GNUNET_PQ_result_spec_uint32 ("age_mask",
-                                  &meta->age_mask.bits),
-    GNUNET_PQ_result_spec_end
-  };
-
-  /* used in #postgres_lookup_denomination_key() */
-  PREPARE (pg,
-           "lookup_denomination_key",
-           "SELECT"
-           " valid_from"
-           ",expire_withdraw"
-           ",expire_deposit"
-           ",expire_legal"
-           ",coin"
-           ",fee_withdraw"
-           ",fee_deposit"
-           ",fee_refresh"
-           ",fee_refund"
-           ",age_mask"
-           " FROM denominations"
-           " WHERE denom_pub_hash=$1;");
-  return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
-                                                   "lookup_denomination_key",
-                                                   params,
-                                                   rs);
-}
diff --git a/src/donaudb/pg_lookup_donation_unit_key.c 
b/src/donaudb/pg_lookup_donation_unit_key.c
new file mode 100644
index 0000000..97d036e
--- /dev/null
+++ b/src/donaudb/pg_lookup_donation_unit_key.c
@@ -0,0 +1,62 @@
+/*
+   This file is part of TALER
+   Copyright (C) 2023 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/pg_lookup_donation_unit_key.c
+ * @brief Implementation of the lookup_donation_unit_key function for Postgres
+ * @author Johannes Casaburi
+ */
+#include "platform.h"
+#include "taler_error_codes.h"
+#include "taler_dbevents.h"
+#include "taler_pq_lib.h"
+#include "pg_lookup_donation_unit_key.h"
+#include "pg_helper.h"
+
+enum GNUNET_DB_QueryStatus
+TEH_PG_lookup_donation_unit_key (
+  void *cls,
+  const struct TALER_DonationUnitHashP *h_donation_unit_pub,
+  struct TALER_DONAUDB_DonationUnitKeyMetaData *meta)
+{
+  struct PostgresClosure *pg = cls;
+  struct GNUNET_PQ_QueryParam params[] = {
+    GNUNET_PQ_query_param_auto_from_type (h_donation_unit_pub),
+    GNUNET_PQ_query_param_end
+  };
+  struct GNUNET_PQ_ResultSpec rs[] = {
+    GNUNET_PQ_result_spec_auto_from_type ("donation_unit_pub",
+                                 &meta->donation_unit_pub),
+    GNUNET_PQ_query_param_uint64 ("validity_year",
+                                 &meta->validity_year),
+    TALER_PQ_RESULT_SPEC_AMOUNT ("amount",
+                                 &meta->value),
+    GNUNET_PQ_result_spec_end
+  };
+
+  /* used in #postgres_lookup_donation_unit_key() */
+  PREPARE (pg,
+           "lookup_donation_unit_key",
+           "SELECT"
+           ",donation_unit_pub"
+           " validity_year"
+           ",amount"
+           " FROM donation_units"
+           " WHERE donation_unit_pub_hash=$1;");
+  return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
+                                                   "lookup_donation_unit_key",
+                                                   params,
+                                                   rs);
+}
diff --git a/src/donaudb/pg_lookup_denomination_key.h 
b/src/donaudb/pg_lookup_donation_unit_key.h
similarity index 63%
rename from src/donaudb/pg_lookup_denomination_key.h
rename to src/donaudb/pg_lookup_donation_unit_key.h
index e7ab873..31a3054 100644
--- a/src/donaudb/pg_lookup_denomination_key.h
+++ b/src/donaudb/pg_lookup_donation_unit_key.h
@@ -1,6 +1,6 @@
 /*
    This file is part of TALER
-   Copyright (C) 2022 Taler Systems SA
+   Copyright (C) 2023 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
@@ -14,28 +14,28 @@
    TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
  */
 /**
- * @file donaudb/pg_lookup_denomination_key.h
- * @brief implementation of the lookup_denomination_key function for Postgres
- * @author Christian Grothoff
+ * @file donaudb/pg_lookup_donation_unit_key.h
+ * @brief implementation of the lookup_donation_unit_key function for Postgres
+ * @author Johannes Casaburi
  */
-#ifndef PG_LOOKUP_DENOMINATION_KEY_H
-#define PG_LOOKUP_DENOMINATION_KEY_H
+#ifndef PG_LOOKUP_DONATION_UNIT_KEY_H
+#define PG_LOOKUP_DONATION_UNIT_KEY_H
 
 #include "taler_util.h"
 #include "taler_json_lib.h"
 #include "taler_donaudb_plugin.h"
 /**
- * Lookup information about current denomination key.
+ * Lookup information about current donation_unit key.
  *
  * @param cls closure
- * @param h_denom_pub hash of the denomination public key
+ * @param h_denom_pub hash of the donation_unit public key
  * @param[out] meta set to various meta data about the key
  * @return transaction status code
  */
 enum GNUNET_DB_QueryStatus
-TEH_PG_lookup_denomination_key (
+TEH_PG_lookup_donation_unit_key (
   void *cls,
-  const struct TALER_DenominationHashP *h_denom_pub,
-  struct TALER_DONAUDB_DenominationKeyMetaData *meta);
+  const struct TALER_DonationUnitHashP *h_denom_pub,
+  struct TALER_DONAUDB_DonationUnitKeyMetaData *meta);
 
 #endif

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]