diff options
Diffstat (limited to 'src/exchange-tools/taler-exchange-dbinit.c')
-rw-r--r-- | src/exchange-tools/taler-exchange-dbinit.c | 53 |
1 files changed, 48 insertions, 5 deletions
diff --git a/src/exchange-tools/taler-exchange-dbinit.c b/src/exchange-tools/taler-exchange-dbinit.c index acc37be8d..41ff2ab24 100644 --- a/src/exchange-tools/taler-exchange-dbinit.c +++ b/src/exchange-tools/taler-exchange-dbinit.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014-2021 Taler Systems SA + Copyright (C) 2014-2024 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 @@ -30,6 +30,11 @@ static int global_ret; /** + * -a option: inject auditor triggers + */ +static int inject_auditor; + +/** * -r option: do full DB reset */ static int reset_db; @@ -44,6 +49,15 @@ static int clear_shards; */ static int gc_db; +/** + * -P option: setup a partitioned database + */ +static uint32_t num_partitions; + +/** + * -f option: force partitions to be created when there is only one + */ +static int force_create_partitions; /** * Main function that will be run. @@ -64,6 +78,7 @@ run (void *cls, (void) cls; (void) args; (void) cfgfile; + if (NULL == (plugin = TALER_EXCHANGEDB_plugin_load (cfg))) { @@ -74,18 +89,22 @@ run (void *cls, } if (reset_db) { - if (GNUNET_OK != plugin->drop_tables (plugin->cls)) + if (GNUNET_OK != + plugin->drop_tables (plugin->cls)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not drop tables as requested. Either database was not yet initialized, or permission denied. Consult the logs. Will still try to create new tables.\n"); } } if (GNUNET_OK != - plugin->create_tables (plugin->cls)) + plugin->create_tables (plugin->cls, + force_create_partitions || num_partitions > 0, + num_partitions)) { fprintf (stderr, "Failed to initialize database.\n"); TALER_EXCHANGEDB_plugin_unload (plugin); + plugin = NULL; global_ret = EXIT_NOPERMISSION; return; } @@ -97,13 +116,14 @@ run (void *cls, fprintf (stderr, "Failed to prepare database.\n"); TALER_EXCHANGEDB_plugin_unload (plugin); + plugin = NULL; global_ret = EXIT_NOPERMISSION; return; } if (clear_shards) { - if (0 > - plugin->delete_revolving_shards (plugin->cls)) + if (GNUNET_OK != + plugin->delete_shard_locks (plugin->cls)) { fprintf (stderr, "Clearing revolving shards failed!\n"); @@ -118,7 +138,17 @@ run (void *cls, } } } + if (inject_auditor) + { + if (GNUNET_SYSERR == plugin->inject_auditor_triggers (plugin->cls)) + { + fprintf (stderr, + "Injecting auditor triggers failed!\n"); + global_ret = EXIT_FAILURE; + } + } TALER_EXCHANGEDB_plugin_unload (plugin); + plugin = NULL; } @@ -135,6 +165,10 @@ main (int argc, char *const *argv) { const struct GNUNET_GETOPT_CommandLineOption options[] = { + GNUNET_GETOPT_option_flag ('a', + "inject-auditor", + "inject auditor triggers", + &inject_auditor), GNUNET_GETOPT_option_flag ('g', "gc", "garbage collect database", @@ -147,6 +181,15 @@ main (int argc, "shardunlock", "unlock all revolving shard locks (use after system crash or shard size change while services are not running)", &clear_shards), + GNUNET_GETOPT_option_uint ('P', + "partition", + "NUMBER", + "Setup a partitioned database where each table which can be partitioned holds NUMBER partitions on a single DB node", + &num_partitions), + GNUNET_GETOPT_option_flag ('f', + "force", + "Force partitions to be created if there is only one partition", + &force_create_partitions), GNUNET_GETOPT_OPTION_END }; enum GNUNET_GenericReturnValue ret; |