diff --git a/src/exchange/taler-exchange-httpd_extensions.c b/src/exchange/taler-exchange-httpd_extensions.c
index 98092bd09..5da270622 100644
--- a/src/exchange/taler-exchange-httpd_extensions.c
+++ b/src/exchange/taler-exchange-httpd_extensions.c
@@ -33,7 +33,6 @@
*/
static struct GNUNET_DB_EventHandler *extensions_eh;
-
/**
* Function called whenever another exchange process has updated
* the extensions data in the database.
@@ -48,24 +47,65 @@ extension_update_event_cb (void *cls,
size_t extra_size)
{
(void) cls;
- (void) extra;
- (void) extra_size;
+ enum TALER_Extension_Type type;
+
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Received /management/extensions update event\n");
+ "Received extensions update event\n");
+
+ if (sizeof(enum TALER_Extension_Type) != extra_size)
+ {
+ GNUNET_break (0);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Oops, incorrect size of extra for TALER_Extension_type\n");
+ return;
+ }
+
+ type = *(enum TALER_Extension_Type *) extra;
+ if (type <0 || type >= TALER_Extension_Max)
+ {
+ GNUNET_break (0);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Oops, incorrect type for TALER_Extension_type\n");
+ return;
+ }
+
+ {
+ char *config;
+ enum GNUNET_DB_QueryStatus qs;
+
+ qs = TEH_plugin->get_extension_config (TEH_plugin->cls,
+ TEH_extensions[type].name,
+ &config);
+
+ if (qs < 0)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Couldn't get extension config\n");
+ return;
+ }
+
+ /*
+ * TODO:
+ * - parse string as json
+ * - update global config
+ */
+
+ }
+
}
enum GNUNET_GenericReturnValue
TEH_extensions_init ()
{
- struct GNUNET_DB_EventHeaderP es = {
- .size = htons (sizeof (es)),
+ struct GNUNET_DB_EventHeaderP ev = {
+ .size = htons (sizeof (ev)),
.type = htons (TALER_DBEVENT_EXCHANGE_EXTENSIONS_UPDATED),
};
extensions_eh = TEH_plugin->event_listen (TEH_plugin->cls,
GNUNET_TIME_UNIT_FOREVER_REL,
- &es,
+ &ev,
&extension_update_event_cb,
NULL);
if (NULL == extensions_eh)
@@ -89,22 +129,4 @@ TEH_extensions_done ()
}
-void
-TEH_extensions_update_state (void)
-{
- /* TODO */
-#if 0
- struct GNUNET_DB_EventHeaderP es = {
- .size = htons (sizeof (es)),
- .type = htons (TALER_DBEVENT_EXCHANGE_WIRE_UPDATED),
- };
-
- TEH_plugin->event_notify (TEH_plugin->cls,
- &es,
- NULL,
- 0);
-#endif
-}
-
-
/* end of taler-exchange-httpd_extensions.c */
diff --git a/src/exchange/taler-exchange-httpd_extensions.h b/src/exchange/taler-exchange-httpd_extensions.h
index 3c86e2662..4659b653e 100644
--- a/src/exchange/taler-exchange-httpd_extensions.h
+++ b/src/exchange/taler-exchange-httpd_extensions.h
@@ -40,12 +40,4 @@ TEH_extensions_init (void);
void
TEH_extensions_done (void);
-/**
- * Something changed in the database. Rebuild the extension state metadata.
- * This function should be called if the exchange learns about a new signature
- * from our master key.
- */
-void
-TEH_extensions_update_state (void);
-
#endif
diff --git a/src/exchange/taler-exchange-httpd_management_extensions.c b/src/exchange/taler-exchange-httpd_management_extensions.c
index 522c317c1..3d86c2d57 100644
--- a/src/exchange/taler-exchange-httpd_management_extensions.c
+++ b/src/exchange/taler-exchange-httpd_management_extensions.c
@@ -29,6 +29,7 @@
#include "taler-exchange-httpd_management.h"
#include "taler-exchange-httpd_responses.h"
#include "taler_extensions.h"
+#include "taler_dbevents.h"
struct Extension
@@ -95,7 +96,7 @@ set_extensions (void *cls,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_GENERIC_JSON_INVALID,
"convert configuration to string");
- return GNUNET_DB_STATUS_SOFT_ERROR; /* FIXME: right error? */
+ return GNUNET_DB_STATUS_HARD_ERROR;
}
qs = TEH_plugin->set_extension_config (
@@ -115,6 +116,19 @@ set_extensions (void *cls,
"save extension configuration");
}
+ /* success, trigger event */
+ {
+ enum TALER_Extension_Type *type = &sec->extensions[i].type;
+ struct GNUNET_DB_EventHeaderP ev = {
+ .size = htons (sizeof (ev)),
+ .type = htons (TALER_DBEVENT_EXCHANGE_EXTENSIONS_UPDATED)
+ };
+ TEH_plugin->event_notify (TEH_plugin->cls,
+ &ev,
+ type,
+ sizeof(*type));
+ }
+
}
return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT; /* only 'success', so >=0, matters here */
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c
index deb0fda32..268279f3a 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -1,18 +1,18 @@
/*
- This file is part of TALER
- Copyright (C) 2014--2021 Taler Systems SA
+ This file is part of TALER
+ Copyright (C) 2014--2021 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 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.
+ 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
-*/
+ You should have received a copy of the GNU General Public License along with
+ TALER; see the file COPYING. If not, see
+ */
/**
* @file plugin_exchangedb_postgres.c
@@ -211,7 +211,7 @@ prepare_statements (struct PostgresClosure *pg)
enum GNUNET_GenericReturnValue ret;
struct GNUNET_PQ_PreparedStatement ps[] = {
/* Used in #postgres_insert_denomination_info() and
- #postgres_add_denomination_key() */
+ #postgres_add_denomination_key() */
GNUNET_PQ_make_prepare (
"denomination_insert",
"INSERT INTO denominations "
@@ -222,8 +222,8 @@ prepare_statements (struct PostgresClosure *pg)
",expire_withdraw"
",expire_deposit"
",expire_legal"
- ",coin_val" /* value of this denom */
- ",coin_frac" /* fractional value of this denom */
+ ",coin_val" /* value of this denom */
+ ",coin_frac" /* fractional value of this denom */
",fee_withdraw_val"
",fee_withdraw_frac"
",fee_deposit_val"
@@ -245,8 +245,8 @@ prepare_statements (struct PostgresClosure *pg)
",expire_withdraw"
",expire_deposit"
",expire_legal"
- ",coin_val" /* value of this denom */
- ",coin_frac" /* fractional value of this denom */
+ ",coin_val" /* value of this denom */
+ ",coin_frac" /* fractional value of this denom */
",fee_withdraw_val"
",fee_withdraw_frac"
",fee_deposit_val"
@@ -268,8 +268,8 @@ prepare_statements (struct PostgresClosure *pg)
",expire_withdraw"
",expire_deposit"
",expire_legal"
- ",coin_val" /* value of this denom */
- ",coin_frac" /* fractional value of this denom */
+ ",coin_val" /* value of this denom */
+ ",coin_frac" /* fractional value of this denom */
",fee_withdraw_val"
",fee_withdraw_frac"
",fee_deposit_val"
@@ -332,8 +332,8 @@ prepare_statements (struct PostgresClosure *pg)
",expire_withdraw"
",expire_deposit"
",expire_legal"
- ",coin_val" /* value of this denom */
- ",coin_frac" /* fractional value of this denom */
+ ",coin_val" /* value of this denom */
+ ",coin_frac" /* fractional value of this denom */
",fee_withdraw_val"
",fee_withdraw_frac"
",fee_deposit_val"
@@ -766,7 +766,7 @@ prepare_statements (struct PostgresClosure *pg)
See also:
https://stackoverflow.com/questions/34708509/how-to-use-returning-with-on-conflict-in-postgresql/37543015#37543015
- */
+ */
GNUNET_PQ_make_prepare (
"insert_known_coin",
"WITH dd"
@@ -3413,11 +3413,11 @@ dominations_cb_helper (void *cls,
/**
-* Function called to invoke @a cb on every known denomination key (revoked
-* and non-revoked) that has been signed by the master key. Runs in its own
-* read-only transaction.
-*
-*
+ * Function called to invoke @a cb on every known denomination key (revoked
+ * and non-revoked) that has been signed by the master key. Runs in its own
+ * read-only transaction.
+ *
+ *
* @param cls the @e cls of this struct with the plugin-specific state
* @param cb function to call on each denomination key
* @param cb_cls closure for @a cb
@@ -3617,7 +3617,7 @@ auditors_cb_helper (void *cls,
/**
* Function called to invoke @a cb on every active auditor. Disabled
* auditors are skipped. Runs in its own read-only transaction.
- *
+ *
* @param cls the @e cls of this struct with the plugin-specific state
* @param cb function to call on each active auditor
* @param cb_cls closure for @a cb
@@ -4927,7 +4927,7 @@ add_bank_to_exchange (void *cls,
tail = append_rh (rhc);
tail->type = TALER_EXCHANGEDB_RO_BANK_TO_EXCHANGE;
tail->details.bank = bt;
- } /* end of 'while (0 < rows)' */
+ } /* end of 'while (0 < rows)' */
}
@@ -5052,7 +5052,7 @@ add_recoup (void *cls,
tail = append_rh (rhc);
tail->type = TALER_EXCHANGEDB_RO_RECOUP_COIN;
tail->details.recoup = recoup;
- } /* end of 'while (0 < rows)' */
+ } /* end of 'while (0 < rows)' */
}
@@ -5112,7 +5112,7 @@ add_exchange_to_bank (void *cls,
tail = append_rh (rhc);
tail->type = TALER_EXCHANGEDB_RO_EXCHANGE_TO_BANK;
tail->details.closing = closing;
- } /* end of 'while (0 < rows)' */
+ } /* end of 'while (0 < rows)' */
}
@@ -6279,7 +6279,7 @@ postgres_get_refresh_reveal (void *cls,
case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
goto cleanup;
case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
- default: /* can have more than one result */
+ default: /* can have more than one result */
break;
}
switch (grctx.qs)
@@ -6288,7 +6288,7 @@ postgres_get_refresh_reveal (void *cls,
case GNUNET_DB_STATUS_SOFT_ERROR:
goto cleanup;
case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
- case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: /* should be impossible */
+ case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: /* should be impossible */
break;
}
@@ -11415,7 +11415,8 @@ postgres_delete_shard_locks (void *cls)
/**
* Function called to save the configuration of an extension
- * (age-restriction, peer2peer, ...)
+ * (age-restriction, peer2peer, ...). After succesfull storage of the
+ * configuration it triggers the corresponding event.
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param extension_name the name of the extension
diff --git a/src/include/taler_crypto_lib.h b/src/include/taler_crypto_lib.h
index 4ffee54c9..88afb091e 100644
--- a/src/include/taler_crypto_lib.h
+++ b/src/include/taler_crypto_lib.h
@@ -23,6 +23,7 @@
#define TALER_CRYPTO_LIB_H
#include
+#include "taler_extensions.h"
#include "taler_error_codes.h"
#include
@@ -280,26 +281,6 @@ struct TALER_MasterSignatureP
struct GNUNET_CRYPTO_EddsaSignature eddsa_signature;
};
-/*
- * @brief Type of a list of age groups, represented as bit mask.
- *
- * The bits set in the mask mark the edges at the beginning of a next age
- * group. F.e. for the age groups
- * 0-7, 8-9, 10-11, 12-14, 14-15, 16-17, 18-21, 21-*
- * the following bits are set:
- *
- * 31 24 16 8 0
- * | | | | |
- * oooooooo oo1oo1o1 o1o1o1o1 ooooooo1
- *
- * A value of 0 means that the exchange does not support the extension for
- * age-restriction.
- */
-struct TALER_AgeMask
-{
- uint32_t mask;
-};
-
/**
* @brief Age restriction commitment of a coin.
*/
diff --git a/src/include/taler_extensions.h b/src/include/taler_extensions.h
index b6d5c826c..019c63be9 100644
--- a/src/include/taler_extensions.h
+++ b/src/include/taler_extensions.h
@@ -50,16 +50,30 @@ struct TALER_Extension
void *config;
};
-/*
- * TALER Peer2Peer Extension
- * FIXME oec
- */
-
-
/*
* TALER Age Restriction Extension
*/
+/*
+ * @brief Type of a list of age groups, represented as bit mask.
+ *
+ * The bits set in the mask mark the edges at the beginning of a next age
+ * group. F.e. for the age groups
+ * 0-7, 8-9, 10-11, 12-14, 14-15, 16-17, 18-21, 21-*
+ * the following bits are set:
+ *
+ * 31 24 16 8 0
+ * | | | | |
+ * oooooooo oo1oo1o1 o1o1o1o1 ooooooo1
+ *
+ * A value of 0 means that the exchange does not support the extension for
+ * age-restriction.
+ */
+struct TALER_AgeMask
+{
+ uint32_t mask;
+};
+
#define TALER_EXTENSION_SECTION_AGE_RESTRICTION (TALER_EXTENSION_SECTION_PREFIX \
"age_restriction")
@@ -90,4 +104,11 @@ TALER_parse_age_group_string (char *groups,
enum TALER_Extension_ReturnValue
TALER_get_age_mask (const struct GNUNET_CONFIGURATION_Handle *cfg,
struct TALER_AgeMask *mask);
+
+
+/*
+ * TALER Peer2Peer Extension
+ * TODO oec
+ */
+
#endif