challenger

OAuth 2.0-based authentication service that validates user can receive messages at a certain address
Log | Files | Refs | Submodules | README | LICENSE

commit 702f06d3b550775bb0df0f7511db74f7f53bc82b
parent af1b8347716ad87c912728d3bdeeef7f51f223da
Author: Christian Grothoff <grothoff@gnunet.org>
Date:   Thu,  9 Jul 2026 21:45:35 +0200

remove redundant db stuff

Diffstat:
Msrc/challenger/challenger-admin.c | 5+++--
Msrc/challengerdb/challenger-0003.sql | 10++++++++++
Msrc/challengerdb/gc.c | 3+--
Msrc/challengerdb/preflight.c | 12+++++-------
Msrc/include/challenger-database/preflight.h | 3+--
5 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/src/challenger/challenger-admin.c b/src/challenger/challenger-admin.c @@ -140,8 +140,9 @@ run (void *cls, global_ret = EXIT_FAILURE; goto cleanup; case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: - GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, - "Client deleted\n"); + if (! be_quiet) + fprintf (stdout, + "Client deleted\n"); break; } goto cleanup; diff --git a/src/challengerdb/challenger-0003.sql b/src/challengerdb/challenger-0003.sql @@ -25,4 +25,14 @@ SET search_path TO challenger; ALTER TABLE validations ALTER COLUMN code_challenge_method SET NOT NULL; +CREATE INDEX IF NOT EXISTS tokens_by_expiration + ON tokens(token_expiration_time); +COMMENT ON INDEX tokens_by_expiration + IS 'for gc by expiration'; + +-- These indices were redundant, columns are already UNIQUE +DROP INDEX clients_serial; +DROP INDEX validations_serial; + + COMMIT; diff --git a/src/challengerdb/gc.c b/src/challengerdb/gc.c @@ -35,7 +35,7 @@ CHALLENGERDB_gc (struct CHALLENGERDB_PostgresContext *pg, }; enum GNUNET_DB_QueryStatus qs; - GNUNET_PQ_reconnect_if_down (pg->conn); + CHALLENGERDB_preflight (pg); PREPARE (pg, "gc_validations", "DELETE FROM validations" @@ -44,7 +44,6 @@ CHALLENGERDB_gc (struct CHALLENGERDB_PostgresContext *pg, "gc_tokens", "DELETE FROM tokens" " WHERE token_expiration_time < $1;"); - CHALLENGERDB_preflight (pg); qs = GNUNET_PQ_eval_prepared_non_select (pg->conn, "gc_validations", params); diff --git a/src/challengerdb/preflight.c b/src/challengerdb/preflight.c @@ -37,20 +37,18 @@ CHALLENGERDB_preflight (struct CHALLENGERDB_PostgresContext *pg) GNUNET_PQ_reconnect_if_down (pg->conn); return GNUNET_OK; /* all good */ } - if (GNUNET_OK == + if (GNUNET_OK != GNUNET_PQ_exec_statements (pg->conn, es)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "BUG: Preflight check rolled back transaction `%s'!\n", - pg->transaction_name); - } - else - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "BUG: Preflight check failed to rollback transaction `%s'!\n", pg->transaction_name); + return GNUNET_SYSERR; } + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "BUG: Preflight check rolled back transaction `%s'!\n", + pg->transaction_name); pg->transaction_name = NULL; return GNUNET_NO; } diff --git a/src/include/challenger-database/preflight.h b/src/include/challenger-database/preflight.h @@ -26,8 +26,7 @@ /** * Do a pre-flight check that we are not in an uncommitted transaction. - * If we are, try to commit the previous transaction and output a warning. - * Does not return anything, as we will continue regardless of the outcome. + * If we are, rolls back the previous transaction and outputs a warning. * * @param cls the `struct PostgresClosure` with the plugin-specific state * @return #GNUNET_OK if everything is fine