summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/exchange/taler-exchange-httpd_keystate.c40
-rw-r--r--src/exchangedb/plugin_exchangedb_postgres.c6
-rw-r--r--src/include/taler_exchangedb_plugin.h14
-rw-r--r--src/json/.gitignore1
-rw-r--r--src/json/Makefile.am16
-rw-r--r--src/json/test_json_wire.c59
6 files changed, 131 insertions, 5 deletions
diff --git a/src/exchange/taler-exchange-httpd_keystate.c b/src/exchange/taler-exchange-httpd_keystate.c
index c4e550210..24eef36ea 100644
--- a/src/exchange/taler-exchange-httpd_keystate.c
+++ b/src/exchange/taler-exchange-httpd_keystate.c
@@ -104,6 +104,46 @@ struct DenominationKeyEntry
*/
struct GNUNET_HashCode denom_key_hash;
+#ifdef OPTIMIZE_5777_AUDITOR_BY_COUNT_REALTIME_DETECTION
+
+ /**
+ * Mutex that must be held before threads may access or update
+ * @e known_coin_counter or @e known_coin_counter_db.
+ */
+ pthread_mutex_t known_coin_counter_mutex;
+
+ /**
+ * Mutex that must be held before threads may access or update
+ * @e issued_coin_counter or @e issued_coin_counter_db.
+ */
+ pthread_mutex_t issued_coin_counter_mutex;
+
+ /**
+ * How many coins of this denomination have been redeemed so far (according
+ * to only this process)?
+ */
+ uint64_t known_coin_counter;
+
+ /**
+ * How many coins of this denomination have been redeemed so far (based on
+ * the last time we synchronized the value with our database).
+ */
+ uint64_t known_coin_counter_db;
+
+ /**
+ * How many coins of this denomination have been issued so far (according
+ * to only this process)?
+ */
+ uint64_t issued_coin_counter;
+
+ /**
+ * How many coins of this denomination have been issued so far (based on the
+ * last time we synchronized the value with our database)?
+ */
+ uint64_t issued_coin_counter_db;
+
+#endif
+
};
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c
index 9f0f044b4..19956d2aa 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -3384,9 +3384,9 @@ postgres_count_known_coins (void *cls,
enum GNUNET_DB_QueryStatus qs;
qs = GNUNET_PQ_eval_prepared_singleton_select (session->conn,
- "count_known_coins",
- params,
- rs);
+ "count_known_coins",
+ params,
+ rs);
if (0 > qs)
return (long long) qs;
return (long long) count;
diff --git a/src/include/taler_exchangedb_plugin.h b/src/include/taler_exchangedb_plugin.h
index 67ebc62fc..49aac827f 100644
--- a/src/include/taler_exchangedb_plugin.h
+++ b/src/include/taler_exchangedb_plugin.h
@@ -1463,6 +1463,20 @@ struct TALER_EXCHANGEDB_Plugin
struct TALER_EXCHANGEDB_Session *session,
const struct TALER_CoinPublicInfo *coin);
+
+ /**
+ * Retrieve information about the given @a coin from the database.
+ *
+ * @param cls database connection plugin state
+ * @param session database session
+ * @param coin the coin that must be made known
+ * @return database transaction status, non-negative on success
+ */
+ enum GNUNET_DB_QueryStatus
+ (*get_known_coin) (void *cls,
+ struct TALER_EXCHANGEDB_Session *session,
+ const struct TALER_CoinSpendPublicKeyP *coin_pub,
+ struct TALER_CoinPublicInfo *coin_info);
/**
* Check if we have the specified deposit already in the database.
diff --git a/src/json/.gitignore b/src/json/.gitignore
new file mode 100644
index 000000000..d28843406
--- /dev/null
+++ b/src/json/.gitignore
@@ -0,0 +1 @@
+test_json_wire
diff --git a/src/json/Makefile.am b/src/json/Makefile.am
index 22173d0a0..2ac5df44b 100644
--- a/src/json/Makefile.am
+++ b/src/json/Makefile.am
@@ -25,10 +25,12 @@ libtalerjson_la_LIBADD = \
$(XLIB)
TESTS = \
- test_json
+ test_json \
+ test_json_wire
check_PROGRAMS= \
- test_json
+ test_json \
+ test_json_wire
test_json_SOURCES = \
test_json.c
@@ -38,3 +40,13 @@ test_json_LDADD = \
$(top_builddir)/src/util/libtalerutil.la \
-lgnunetutil \
-ljansson
+
+
+test_json_wire_SOURCES = \
+ test_json_wire.c
+test_json_wire_LDADD = \
+ $(top_builddir)/src/json/libtalerjson.la \
+ -lgnunetjson \
+ $(top_builddir)/src/util/libtalerutil.la \
+ -lgnunetutil \
+ -ljansson
diff --git a/src/json/test_json_wire.c b/src/json/test_json_wire.c
new file mode 100644
index 000000000..9e59dfa8a
--- /dev/null
+++ b/src/json/test_json_wire.c
@@ -0,0 +1,59 @@
+/*
+ This file is part of TALER
+ (C) 2015, 2016 GNUnet e.V. and Inria
+
+ 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, see <http://www.gnu.org/licenses/>
+*/
+
+/**
+ * @file json/test_json_wire.c
+ * @brief Tests for Taler-specific crypto logic
+ * @author Christian Grothoff <christian@grothoff.org>
+ */
+#include "platform.h"
+#include "taler_util.h"
+#include "taler_json_lib.h"
+
+
+int
+main(int argc,
+ const char *const argv[])
+{
+ struct TALER_MasterPublicKeyP master_pub;
+ struct GNUNET_CRYPTO_EddsaPrivateKey *priv;
+ struct TALER_MasterPrivateKeyP master_priv;
+ json_t *wire;
+ const char *payto = "payto://x-taler-bank/42";
+ char *p;
+
+ GNUNET_log_setup ("test-json-wire",
+ "WARNING",
+ NULL);
+ priv = GNUNET_CRYPTO_eddsa_key_create ();
+ master_priv.eddsa_priv = *priv;
+ GNUNET_free (priv);
+ GNUNET_CRYPTO_eddsa_key_get_public (&master_priv.eddsa_priv,
+ &master_pub.eddsa_pub);
+ wire = TALER_JSON_exchange_wire_signature_make (payto,
+ &master_priv);
+ p = TALER_JSON_wire_to_payto (wire);
+ GNUNET_assert (0 == strcmp (p, payto));
+ GNUNET_free (p);
+ GNUNET_assert (GNUNET_OK ==
+ TALER_JSON_exchange_wire_signature_check (wire,
+ &master_pub));
+ json_decref (wire);
+
+ return 0;
+}
+
+/* end of test_json_wire.c */