exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

commit 19c0c00419fd7d771bff6e775b448e4a0005615d
parent b375ae8cb9c94ac156799f7757bbe2a32a59c94f
Author: Florian Dold <florian@dold.me>
Date:   Wed, 11 Dec 2024 18:20:07 +0100

make AML program timeout configurable

Diffstat:
Msrc/exchangedb/exchangedb.conf | 7+++++--
Msrc/exchangedb/exchangedb_aml.c | 12++----------
Msrc/exchangedb/plugin_exchangedb_postgres.c | 42++++++++++++++++++++++++------------------
Msrc/include/taler_exchangedb_plugin.h | 4++++
4 files changed, 35 insertions(+), 30 deletions(-)

diff --git a/src/exchangedb/exchangedb.conf b/src/exchangedb/exchangedb.conf @@ -23,4 +23,7 @@ AGGREGATOR_SHIFT = 1 s # How many concurrent purses may be opened by a reserve # if the reserve is paid for a year? -DEFAULT_PURSE_LIMIT = 1 -\ No newline at end of file +DEFAULT_PURSE_LIMIT = 1 + +# How long are AML programs allowed to run? +MAX_AML_PROGRAM_RUNTIME = 60 s +\ No newline at end of file diff --git a/src/exchangedb/exchangedb_aml.c b/src/exchangedb/exchangedb_aml.c @@ -32,14 +32,6 @@ */ #define MAX_DEPTH 16 -/** - * How long do we allow an AML program to run for at most? - * If an AML program runs longer, we kill it and mark it as - * failed. - */ -#define MAX_AML_PROGRAM_RUNTIME GNUNET_TIME_UNIT_MINUTES - - enum GNUNET_DB_QueryStatus TALER_EXCHANGEDB_persist_aml_program_result ( struct TALER_EXCHANGEDB_Plugin *plugin, @@ -475,7 +467,7 @@ run_measure (struct TALER_EXCHANGEDB_RuleUpdater *ru, qs = ru->plugin->set_aml_lock ( ru->plugin->cls, &ru->account, - GNUNET_TIME_relative_multiply (MAX_AML_PROGRAM_RUNTIME, + GNUNET_TIME_relative_multiply (ru->plugin->max_aml_program_runtime, 2), &xlock); if (GNUNET_TIME_absolute_is_future (xlock)) @@ -514,7 +506,7 @@ run_measure (struct TALER_EXCHANGEDB_RuleUpdater *ru, m->prog_name); GNUNET_assert (NULL == ru->t); ru->t = GNUNET_SCHEDULER_add_delayed ( - MAX_AML_PROGRAM_RUNTIME, + ru->plugin->max_aml_program_runtime, &aml_program_timeout, ru); ru->amlh = TALER_KYCLOGIC_run_aml_program3 ( diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c @@ -283,6 +283,7 @@ libtaler_plugin_exchangedb_postgres_init (void *cls) unsigned long long dpl; pg = GNUNET_new (struct PostgresClosure); + plugin = GNUNET_new (struct TALER_EXCHANGEDB_Plugin); pg->cfg = cfg; if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, @@ -293,8 +294,7 @@ libtaler_plugin_exchangedb_postgres_init (void *cls) GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "exchangedb-postgres", "SQL_DIR"); - GNUNET_free (pg); - return NULL; + goto fail; } if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, @@ -305,9 +305,7 @@ libtaler_plugin_exchangedb_postgres_init (void *cls) GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "exchange", "BASE_URL"); - GNUNET_free (pg->sql_dir); - GNUNET_free (pg); - return NULL; + goto fail; } if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_time (cfg, @@ -318,10 +316,18 @@ libtaler_plugin_exchangedb_postgres_init (void *cls) GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "exchangedb", "IDLE_RESERVE_EXPIRATION_TIME"); - GNUNET_free (pg->exchange_url); - GNUNET_free (pg->sql_dir); - GNUNET_free (pg); - return NULL; + goto fail; + } + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_time (cfg, + "exchangedb", + "MAX_AML_PROGRAM_RUNTIME", + &plugin->max_aml_program_runtime)) + { + GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, + "exchangedb", + "MAX_AML_PROGRAM_RUNTIME"); + goto fail; } if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_time (cfg, @@ -332,10 +338,7 @@ libtaler_plugin_exchangedb_postgres_init (void *cls) GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "exchangedb", "LEGAL_RESERVE_EXPIRATION_TIME"); - GNUNET_free (pg->exchange_url); - GNUNET_free (pg->sql_dir); - GNUNET_free (pg); - return NULL; + goto fail; } if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_time (cfg, @@ -368,12 +371,8 @@ libtaler_plugin_exchangedb_postgres_init (void *cls) "exchange", &pg->currency)) { - GNUNET_free (pg->exchange_url); - GNUNET_free (pg->sql_dir); - GNUNET_free (pg); - return NULL; + goto fail; } - plugin = GNUNET_new (struct TALER_EXCHANGEDB_Plugin); plugin->cls = pg; plugin->do_reserve_open = &TEH_PG_do_reserve_open; @@ -779,6 +778,13 @@ libtaler_plugin_exchangedb_postgres_init (void *cls) = &TEH_PG_set_aml_lock; return plugin; + +fail: + GNUNET_free (pg->exchange_url); + GNUNET_free (pg->sql_dir); + GNUNET_free (pg); + GNUNET_free (plugin); + return NULL; } diff --git a/src/include/taler_exchangedb_plugin.h b/src/include/taler_exchangedb_plugin.h @@ -3688,6 +3688,10 @@ struct TALER_EXCHANGEDB_Plugin */ char *library_name; + /** + * How long are AML programs allowed to run? + */ + struct GNUNET_TIME_Relative max_aml_program_runtime; /** * Drop the Taler tables. This should only be used in testcases.