diff options
-rw-r--r-- | src/auditor/report-lib.c | 29 | ||||
-rw-r--r-- | src/auditor/report-lib.h | 5 | ||||
-rw-r--r-- | src/auditor/taler-auditor-exchange.c | 11 | ||||
-rw-r--r-- | src/auditor/taler-auditor-httpd_deposit-confirmation.c | 7 | ||||
-rw-r--r-- | src/auditor/taler-auditor-httpd_exchanges.c | 6 | ||||
-rw-r--r-- | src/auditor/taler-helper-auditor-aggregation.c | 6 | ||||
-rw-r--r-- | src/auditor/taler-helper-auditor-coins.c | 11 | ||||
-rw-r--r-- | src/auditor/taler-helper-auditor-deposits.c | 4 | ||||
-rw-r--r-- | src/auditor/taler-helper-auditor-reserves.c | 10 | ||||
-rw-r--r-- | src/auditor/taler-helper-auditor-wire.c | 27 | ||||
-rw-r--r-- | src/auditordb/plugin_auditordb_postgres.c | 433 | ||||
-rw-r--r-- | src/auditordb/test_auditordb.c | 57 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_keys.c | 7 | ||||
-rw-r--r-- | src/include/taler_auditordb_plugin.h | 140 | ||||
-rw-r--r-- | src/mhd/mhd_config.c | 13 | ||||
-rw-r--r-- | src/util/test_payto.c | 2 |
16 files changed, 211 insertions, 557 deletions
diff --git a/src/auditor/report-lib.c b/src/auditor/report-lib.c index 0ae1cc1f6..4addce9e2 100644 --- a/src/auditor/report-lib.c +++ b/src/auditor/report-lib.c @@ -47,11 +47,6 @@ const struct GNUNET_CONFIGURATION_Handle *TALER_ARL_cfg; struct TALER_AUDITORDB_Plugin *TALER_ARL_adb; /** - * Our session with the #TALER_ARL_adb. - */ -struct TALER_AUDITORDB_Session *TALER_ARL_asession; - -/** * Master public key of the exchange to audit. */ struct TALER_MasterPublicKeyP TALER_ARL_master_pub; @@ -310,8 +305,7 @@ transact (TALER_ARL_Analysis analysis, int ret; enum GNUNET_DB_QueryStatus qs; - ret = TALER_ARL_adb->start (TALER_ARL_adb->cls, - TALER_ARL_asession); + ret = TALER_ARL_adb->start (TALER_ARL_adb->cls); if (GNUNET_OK != ret) { GNUNET_break (0); @@ -340,13 +334,11 @@ transact (TALER_ARL_Analysis analysis, GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Exchange DB commit failed, rolling back transaction\n"); - TALER_ARL_adb->rollback (TALER_ARL_adb->cls, - TALER_ARL_asession); + TALER_ARL_adb->rollback (TALER_ARL_adb->cls); } else { - qs = TALER_ARL_adb->commit (TALER_ARL_adb->cls, - TALER_ARL_asession); + qs = TALER_ARL_adb->commit (TALER_ARL_adb->cls); if (0 > qs) { GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); @@ -359,8 +351,7 @@ transact (TALER_ARL_Analysis analysis, { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing failed (or no changes), rolling back transaction\n"); - TALER_ARL_adb->rollback (TALER_ARL_adb->cls, - TALER_ARL_asession); + TALER_ARL_adb->rollback (TALER_ARL_adb->cls); TALER_ARL_edb->rollback (TALER_ARL_edb->cls); } switch (qs) @@ -389,15 +380,15 @@ int TALER_ARL_setup_sessions_and_run (TALER_ARL_Analysis ana, void *ana_cls) { - if (GNUNET_OK != + if (GNUNET_SYSERR == TALER_ARL_edb->preflight (TALER_ARL_edb->cls)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to initialize exchange connection.\n"); return GNUNET_SYSERR; } - TALER_ARL_asession = TALER_ARL_adb->get_session (TALER_ARL_adb->cls); - if (NULL == TALER_ARL_asession) + if (GNUNET_SYSERR == + TALER_ARL_adb->preflight (TALER_ARL_adb->cls)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to initialize auditor session.\n"); @@ -804,11 +795,10 @@ TALER_ARL_init (const struct GNUNET_CONFIGURATION_Handle *c) return GNUNET_SYSERR; } { - struct TALER_AUDITORDB_Session *as; int found; - as = TALER_ARL_adb->get_session (TALER_ARL_adb->cls); - if (NULL == as) + if (GNUNET_SYSERR == + TALER_ARL_adb->preflight (TALER_ARL_adb->cls)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to start session with auditor database.\n"); @@ -817,7 +807,6 @@ TALER_ARL_init (const struct GNUNET_CONFIGURATION_Handle *c) } found = GNUNET_NO; (void) TALER_ARL_adb->list_exchanges (TALER_ARL_adb->cls, - as, &test_master_present, &found); if (GNUNET_NO == found) diff --git a/src/auditor/report-lib.h b/src/auditor/report-lib.h index d8d825914..7c01b1685 100644 --- a/src/auditor/report-lib.h +++ b/src/auditor/report-lib.h @@ -60,11 +60,6 @@ extern const struct GNUNET_CONFIGURATION_Handle *TALER_ARL_cfg; extern struct TALER_AUDITORDB_Plugin *TALER_ARL_adb; /** - * Our session with the #TALER_ARL_adb. - */ -extern struct TALER_AUDITORDB_Session *TALER_ARL_asession; - -/** * Master public key of the exchange to audit. */ extern struct TALER_MasterPublicKeyP TALER_ARL_master_pub; diff --git a/src/auditor/taler-auditor-exchange.c b/src/auditor/taler-auditor-exchange.c index b751ea9a4..04181ce3f 100644 --- a/src/auditor/taler-auditor-exchange.c +++ b/src/auditor/taler-auditor-exchange.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014, 2015, 2018, 2019 Taler Systems SA + 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 @@ -176,13 +176,12 @@ main (int argc, /* Update DB */ { enum GNUNET_DB_QueryStatus qs; - struct TALER_AUDITORDB_Session *session; - session = adb->get_session (adb->cls); - if (NULL == session) + if (GNUNET_SYSERR == + adb->preflight (adb->cls)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to initialize database session\n"); + "Failed to initialize database connection\n"); TALER_AUDITORDB_plugin_unload (adb); return EXIT_FAILURE; } @@ -190,13 +189,11 @@ main (int argc, if (remove_flag) { qs = adb->delete_exchange (adb->cls, - session, &master_public_key); } else { qs = adb->insert_exchange (adb->cls, - session, &master_public_key, exchange_url); } diff --git a/src/auditor/taler-auditor-httpd_deposit-confirmation.c b/src/auditor/taler-auditor-httpd_deposit-confirmation.c index f38e8ee71..c7a23d718 100644 --- a/src/auditor/taler-auditor-httpd_deposit-confirmation.c +++ b/src/auditor/taler-auditor-httpd_deposit-confirmation.c @@ -62,7 +62,6 @@ verify_and_execute_deposit_confirmation ( const struct TALER_AUDITORDB_DepositConfirmation *dc, const struct TALER_AUDITORDB_ExchangeSigningKey *es) { - struct TALER_AUDITORDB_Session *session; enum GNUNET_DB_QueryStatus qs; struct GNUNET_TIME_Absolute now; struct GNUNET_HashCode h; @@ -96,8 +95,8 @@ verify_and_execute_deposit_confirmation ( cached = GNUNET_CONTAINER_multihashmap_get (cache, &h); GNUNET_assert (0 == pthread_mutex_unlock (&lock)); - session = TAH_plugin->get_session (TAH_plugin->cls); - if (NULL == session) + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) { GNUNET_break (0); return TALER_MHD_reply_with_error (connection, @@ -126,7 +125,6 @@ verify_and_execute_deposit_confirmation ( /* execute transaction */ qs = TAH_plugin->insert_exchange_signkey (TAH_plugin->cls, - session, es); if (0 > qs) { @@ -216,7 +214,6 @@ verify_and_execute_deposit_confirmation ( /* execute transaction */ qs = TAH_plugin->insert_deposit_confirmation (TAH_plugin->cls, - session, dc); if (0 > qs) { diff --git a/src/auditor/taler-auditor-httpd_exchanges.c b/src/auditor/taler-auditor-httpd_exchanges.c index 7b54b6d49..f9a9e9e60 100644 --- a/src/auditor/taler-auditor-httpd_exchanges.c +++ b/src/auditor/taler-auditor-httpd_exchanges.c @@ -75,15 +75,14 @@ TAH_EXCHANGES_handler (struct TAH_RequestHandler *rh, size_t *upload_data_size) { json_t *ja; - struct TALER_AUDITORDB_Session *session; enum GNUNET_DB_QueryStatus qs; (void) rh; (void) connection_cls; (void) upload_data; (void) upload_data_size; - session = TAH_plugin->get_session (TAH_plugin->cls); - if (NULL == session) + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) { GNUNET_break (0); return TALER_MHD_reply_with_error (connection, @@ -94,7 +93,6 @@ TAH_EXCHANGES_handler (struct TAH_RequestHandler *rh, ja = json_array (); GNUNET_break (NULL != ja); qs = TAH_plugin->list_exchanges (TAH_plugin->cls, - session, &add_exchange, ja); if (0 > qs) diff --git a/src/auditor/taler-helper-auditor-aggregation.c b/src/auditor/taler-helper-auditor-aggregation.c index 3bc8c7701..468f66b44 100644 --- a/src/auditor/taler-helper-auditor-aggregation.c +++ b/src/auditor/taler-helper-auditor-aggregation.c @@ -1218,7 +1218,6 @@ analyze_aggregations (void *cls) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Analyzing aggregations\n"); qsp = TALER_ARL_adb->get_auditor_progress_aggregation (TALER_ARL_adb->cls, - TALER_ARL_asession, &TALER_ARL_master_pub, &ppa); if (0 > qsp) @@ -1243,7 +1242,6 @@ analyze_aggregations (void *cls) 0, sizeof (ac)); qsx = TALER_ARL_adb->get_wire_fee_summary (TALER_ARL_adb->cls, - TALER_ARL_asession, &TALER_ARL_master_pub, &total_aggregation_fee_income); if (0 > qsx) @@ -1282,13 +1280,11 @@ analyze_aggregations (void *cls) if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qsx) ac.qs = TALER_ARL_adb->insert_wire_fee_summary ( TALER_ARL_adb->cls, - TALER_ARL_asession, &TALER_ARL_master_pub, &total_aggregation_fee_income); else ac.qs = TALER_ARL_adb->update_wire_fee_summary ( TALER_ARL_adb->cls, - TALER_ARL_asession, &TALER_ARL_master_pub, &total_aggregation_fee_income); if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != ac.qs) @@ -1299,13 +1295,11 @@ analyze_aggregations (void *cls) if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsp) qs = TALER_ARL_adb->update_auditor_progress_aggregation ( TALER_ARL_adb->cls, - TALER_ARL_asession, &TALER_ARL_master_pub, &ppa); else qs = TALER_ARL_adb->insert_auditor_progress_aggregation ( TALER_ARL_adb->cls, - TALER_ARL_asession, &TALER_ARL_master_pub, &ppa); if (0 >= qs) diff --git a/src/auditor/taler-helper-auditor-coins.c b/src/auditor/taler-helper-auditor-coins.c index a2c8b8cee..ba9cf6d18 100644 --- a/src/auditor/taler-helper-auditor-coins.c +++ b/src/auditor/taler-helper-auditor-coins.c @@ -679,7 +679,6 @@ init_denomination (const struct GNUNET_HashCode *denom_hash, uint64_t rowid; qs = TALER_ARL_adb->get_denomination_balance (TALER_ARL_adb->cls, - TALER_ARL_asession, denom_hash, &ds->denom_balance, &ds->denom_loss, @@ -819,7 +818,6 @@ sync_denomination (void *cls, outstanding coins as revenue; and reduce cc->risk exposure. */ if (ds->in_db) qs = TALER_ARL_adb->del_denomination_balance (TALER_ARL_adb->cls, - TALER_ARL_asession, denom_hash); else qs = GNUNET_DB_STATUS_SUCCESS_ONE_RESULT; @@ -851,7 +849,6 @@ sync_denomination (void *cls, if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != (qs = TALER_ARL_adb->insert_historic_denom_revenue ( TALER_ARL_adb->cls, - TALER_ARL_asession, &TALER_ARL_master_pub, denom_hash, expire_deposit, @@ -905,7 +902,6 @@ sync_denomination (void *cls, } if (ds->in_db) qs = TALER_ARL_adb->update_denomination_balance (TALER_ARL_adb->cls, - TALER_ARL_asession, denom_hash, &ds->denom_balance, &ds->denom_loss, @@ -914,7 +910,6 @@ sync_denomination (void *cls, ds->num_issued); else qs = TALER_ARL_adb->insert_denomination_balance (TALER_ARL_adb->cls, - TALER_ARL_asession, denom_hash, &ds->denom_balance, &ds->denom_loss, @@ -2333,7 +2328,6 @@ analyze_coins (void *cls) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Analyzing coins\n"); qsp = TALER_ARL_adb->get_auditor_progress_coin (TALER_ARL_adb->cls, - TALER_ARL_asession, &TALER_ARL_master_pub, &ppc); if (0 > qsp) @@ -2363,7 +2357,6 @@ analyze_coins (void *cls) cc.denom_summaries = GNUNET_CONTAINER_multihashmap_create (256, GNUNET_NO); qsx = TALER_ARL_adb->get_balance_summary (TALER_ARL_adb->cls, - TALER_ARL_asession, &TALER_ARL_master_pub, &total_escrow_balance, &total_deposit_fee_income, @@ -2473,7 +2466,6 @@ analyze_coins (void *cls) } if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsx) qs = TALER_ARL_adb->update_balance_summary (TALER_ARL_adb->cls, - TALER_ARL_asession, &TALER_ARL_master_pub, &total_escrow_balance, &total_deposit_fee_income, @@ -2484,7 +2476,6 @@ analyze_coins (void *cls) &total_irregular_recoups); else qs = TALER_ARL_adb->insert_balance_summary (TALER_ARL_adb->cls, - TALER_ARL_asession, &TALER_ARL_master_pub, &total_escrow_balance, &total_deposit_fee_income, @@ -2501,12 +2492,10 @@ analyze_coins (void *cls) if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsp) qs = TALER_ARL_adb->update_auditor_progress_coin (TALER_ARL_adb->cls, - TALER_ARL_asession, &TALER_ARL_master_pub, &ppc); else qs = TALER_ARL_adb->insert_auditor_progress_coin (TALER_ARL_adb->cls, - TALER_ARL_asession, &TALER_ARL_master_pub, &ppc); if (0 >= qs) diff --git a/src/auditor/taler-helper-auditor-deposits.c b/src/auditor/taler-helper-auditor-deposits.c index 58b41fbc3..58f8226f4 100644 --- a/src/auditor/taler-helper-auditor-deposits.c +++ b/src/auditor/taler-helper-auditor-deposits.c @@ -188,7 +188,6 @@ analyze_deposit_confirmations (void *cls) ppdc.last_deposit_confirmation_serial_id = 0; qsp = TALER_ARL_adb->get_auditor_progress_deposit_confirmation ( TALER_ARL_adb->cls, - TALER_ARL_asession, &TALER_ARL_master_pub, &ppdc); if (0 > qsp) @@ -217,7 +216,6 @@ analyze_deposit_confirmations (void *cls) dcc.first_missed_coin_serial = UINT64_MAX; qsx = TALER_ARL_adb->get_deposit_confirmations ( TALER_ARL_adb->cls, - TALER_ARL_asession, &TALER_ARL_master_pub, ppdc.last_deposit_confirmation_serial_id, &test_dc, @@ -245,13 +243,11 @@ analyze_deposit_confirmations (void *cls) if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsp) qs = TALER_ARL_adb->update_auditor_progress_deposit_confirmation ( TALER_ARL_adb->cls, - TALER_ARL_asession, &TALER_ARL_master_pub, &ppdc); else qs = TALER_ARL_adb->insert_auditor_progress_deposit_confirmation ( TALER_ARL_adb->cls, - TALER_ARL_asession, &TALER_ARL_master_pub, &ppdc); if (0 >= qs) diff --git a/src/auditor/taler-helper-auditor-reserves.c b/src/auditor/taler-helper-auditor-reserves.c index 592663da6..aa9c241bb 100644 --- a/src/auditor/taler-helper-auditor-reserves.c +++ b/src/auditor/taler-helper-auditor-reserves.c @@ -317,7 +317,6 @@ load_auditor_reserve_summary (struct ReserveSummary *rs) uint64_t rowid; qs = TALER_ARL_adb->get_reserve_info (TALER_ARL_adb->cls, - TALER_ARL_asession, &rs->reserve_pub, &TALER_ARL_master_pub, &rowid, @@ -1255,7 +1254,6 @@ verify_reserve_balance (void *cls, TALER_B2S (&rs->reserve_pub), TALER_amount2s (&nbalance)); qs = TALER_ARL_adb->del_reserve_info (TALER_ARL_adb->cls, - TALER_ARL_asession, &rs->reserve_pub, &TALER_ARL_master_pub); if (0 >= qs) @@ -1282,7 +1280,6 @@ verify_reserve_balance (void *cls, TALER_amount2s (&nbalance)); if (rs->had_ri) qs = TALER_ARL_adb->update_reserve_info (TALER_ARL_adb->cls, - TALER_ARL_asession, &rs->reserve_pub, &TALER_ARL_master_pub, &nbalance, @@ -1290,7 +1287,6 @@ verify_reserve_balance (void *cls, rs->a_expiration_date); else qs = TALER_ARL_adb->insert_reserve_info (TALER_ARL_adb->cls, - TALER_ARL_asession, &rs->reserve_pub, &TALER_ARL_master_pub, &nbalance, @@ -1333,7 +1329,6 @@ analyze_reserves (void *cls) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Analyzing reserves\n"); qsp = TALER_ARL_adb->get_auditor_progress_reserve (TALER_ARL_adb->cls, - TALER_ARL_asession, &TALER_ARL_master_pub, &ppr); if (0 > qsp) @@ -1358,7 +1353,6 @@ analyze_reserves (void *cls) } rc.qs = GNUNET_DB_STATUS_SUCCESS_ONE_RESULT; qsx = TALER_ARL_adb->get_reserve_summary (TALER_ARL_adb->cls, - TALER_ARL_asession, &TALER_ARL_master_pub, &total_escrow_balance, &total_withdraw_fee_income); @@ -1427,7 +1421,6 @@ analyze_reserves (void *cls) if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qsx) { qs = TALER_ARL_adb->insert_reserve_summary (TALER_ARL_adb->cls, - TALER_ARL_asession, &TALER_ARL_master_pub, &total_escrow_balance, &total_withdraw_fee_income); @@ -1435,7 +1428,6 @@ analyze_reserves (void *cls) else { qs = TALER_ARL_adb->update_reserve_summary (TALER_ARL_adb->cls, - TALER_ARL_asession, &TALER_ARL_master_pub, &total_escrow_balance, &total_withdraw_fee_income); @@ -1447,12 +1439,10 @@ analyze_reserves (void *cls) } if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsp) qs = TALER_ARL_adb->update_auditor_progress_reserve (TALER_ARL_adb->cls, - TALER_ARL_asession, &TALER_ARL_master_pub, &ppr); else qs = TALER_ARL_adb->insert_auditor_progress_reserve (TALER_ARL_adb->cls, - TALER_ARL_asession, &TALER_ARL_master_pub, &ppr); if (0 >= qs) diff --git a/src/auditor/taler-helper-auditor-wire.c b/src/auditor/taler-helper-auditor-wire.c index 13ee27b70..2cd076ac9 100644 --- a/src/auditor/taler-helper-auditor-wire.c +++ b/src/auditor/taler-helper-auditor-wire.c @@ -663,8 +663,7 @@ commit (enum GNUNET_DB_QueryStatus qs) else GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Hard error, not recording progress\n"); - TALER_ARL_adb->rollback (TALER_ARL_adb->cls, - TALER_ARL_asession); + TALER_ARL_adb->rollback (TALER_ARL_adb->cls); TALER_ARL_edb->rollback (TALER_ARL_edb->cls); return qs; } @@ -691,7 +690,6 @@ commit (enum GNUNET_DB_QueryStatus qs) if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == wa->qsx) qs = TALER_ARL_adb->update_wire_auditor_account_progress ( TALER_ARL_adb->cls, - TALER_ARL_asession, &TALER_ARL_master_pub, wa->ai->section_name, &wa->pp, @@ -700,7 +698,6 @@ commit (enum GNUNET_DB_QueryStatus qs) else qs = TALER_ARL_adb->insert_wire_auditor_account_progress ( TALER_ARL_adb->cls, - TALER_ARL_asession, &TALER_ARL_master_pub, wa->ai->section_name, &wa->pp, @@ -719,12 +716,10 @@ commit (enum GNUNET_DB_QueryStatus qs) NULL); if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsx_gwap) qs = TALER_ARL_adb->update_wire_auditor_progress (TALER_ARL_adb->cls, - TALER_ARL_asession, &TALER_ARL_master_pub, &pp); else qs = TALER_ARL_adb->insert_wire_auditor_progress (TALER_ARL_adb->cls, - TALER_ARL_asession, &TALER_ARL_master_pub, &pp); if (0 >= qs) @@ -746,13 +741,11 @@ commit (enum GNUNET_DB_QueryStatus qs) GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Exchange DB commit failed, rolling back transaction\n"); - TALER_ARL_adb->rollback (TALER_ARL_adb->cls, - TALER_ARL_asession); + TALER_ARL_adb->rollback (TALER_ARL_adb->cls); } else { - qs = TALER_ARL_adb->commit (TALER_ARL_adb->cls, - TALER_ARL_asession); + qs = TALER_ARL_adb->commit (TALER_ARL_adb->cls); if (0 > qs) { GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); @@ -765,8 +758,7 @@ commit (enum GNUNET_DB_QueryStatus qs) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing failed, rolling back transaction\n"); - TALER_ARL_adb->rollback (TALER_ARL_adb->cls, - TALER_ARL_asession); + TALER_ARL_adb->rollback (TALER_ARL_adb->cls); TALER_ARL_edb->rollback (TALER_ARL_edb->cls); } return qs; @@ -1947,23 +1939,22 @@ reserve_closed_cb (void *cls, static enum GNUNET_DB_QueryStatus begin_transaction (void) { - if (GNUNET_OK != + if (GNUNET_SYSERR == TALER_ARL_edb->preflight (TALER_ARL_edb->cls)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to initialize exchange database connection.\n"); return GNUNET_DB_STATUS_HARD_ERROR; } - TALER_ARL_asession = TALER_ARL_adb->get_session (TALER_ARL_adb->cls); - if (NULL == TALER_ARL_asession) + if (GNUNET_SYSERR == + TALER_ARL_adb->preflight (TALER_ARL_adb->cls)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to initialize auditor database session.\n"); return GNUNET_DB_STATUS_HARD_ERROR; } if (GNUNET_OK != - TALER_ARL_adb->start (TALER_ARL_adb->cls, - TALER_ARL_asession)) + TALER_ARL_adb->start (TALER_ARL_adb->cls)) { GNUNET_break (0); return GNUNET_DB_STATUS_HARD_ERROR; @@ -1982,7 +1973,6 @@ begin_transaction (void) { wa->qsx = TALER_ARL_adb->get_wire_auditor_account_progress ( TALER_ARL_adb->cls, - TALER_ARL_asession, &TALER_ARL_master_pub, wa->ai->section_name, &wa->pp, @@ -1996,7 +1986,6 @@ begin_transaction (void) wa->start_pp = wa->pp; } qsx_gwap = TALER_ARL_adb->get_wire_auditor_progress (TALER_ARL_adb->cls, - TALER_ARL_asession, &TALER_ARL_master_pub, &pp); if (0 > qsx_gwap) diff --git a/src/auditordb/plugin_auditordb_postgres.c b/src/auditordb/plugin_auditordb_postgres.c index 151c93ad3..be221a8b7 100644 --- a/src/auditordb/plugin_auditordb_postgres.c +++ b/src/auditordb/plugin_auditordb_postgres.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014-2020 Taler Systems SA + 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 @@ -54,10 +54,12 @@ /** - * Handle for a database session (per-thread, for transactions). + * Type of the "cls" argument given to each of the functions in + * our API. */ -struct TALER_AUDITORDB_Session +struct PostgresClosure { + /** * Postgres connection handle. */ @@ -69,21 +71,6 @@ struct TALER_AUDITORDB_Session * ROLLBACK. */ const char *transaction_name; -}; - - -/** - * Type of the "cls" argument given to each of the functions in - * our API. - */ -struct PostgresClosure -{ - - /** - * Thread-local database connection. - * Contains a pointer to `PGconn` or NULL. - */ - pthread_key_t db_conn_threadlocal; /** * Our configuration. @@ -108,7 +95,7 @@ struct PostgresClosure * used when restarting the auditor * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure */ -static int +static enum GNUNET_GenericReturnValue postgres_drop_tables (void *cls, int drop_exchangelist) { @@ -133,7 +120,7 @@ postgres_drop_tables (void *cls, * @param cls the `struct PostgresClosure` with the plugin-specific state * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure */ -static int +static enum GNUNET_GenericReturnValue postgres_create_tables (void *cls) { struct PostgresClosure *pc = cls; @@ -152,39 +139,14 @@ postgres_create_tables (void *cls) /** - * Close thread-local database connection when a thread is destroyed. - * - * @param cls closure we get from pthreads (the db handle) - */ -static void -db_conn_destroy (void *cls) -{ - struct TALER_AUDITORDB_Session *session = cls; - struct GNUNET_PQ_Context *db_conn; - - if (NULL == session) - return; - db_conn = session->conn; - session->conn = NULL; - if (NULL != db_conn) - GNUNET_PQ_disconnect (db_conn); - GNUNET_free (session); -} - - -/** - * Get the thread-local database-handle. * Connect to the db if the connection does not exist yet. * - * @param cls the `struct PostgresClosure` with the plugin-specific state - * @return the database connection, or NULL on error + * @param[in,out] pg the plugin-specific state + * @return #GNUNET_OK on success */ -static struct TALER_AUDITORDB_Session * -postgres_get_session (void *cls) +static int +setup_connection (struct PostgresClosure *pg) { - struct PostgresClosure *pc = cls; - struct GNUNET_PQ_Context *db_conn; - struct TALER_AUDITORDB_Session *session; struct GNUNET_PQ_PreparedStatement ps[] = { /* used in #postgres_commit */ GNUNET_PQ_make_prepare ("do_commit", @@ -683,68 +645,70 @@ postgres_get_session (void *cls) 1), GNUNET_PQ_PREPARED_STATEMENT_END }; + struct GNUNET_PQ_Context *db_conn; - if (NULL != (session = pthread_getspecific (pc->db_conn_threadlocal))) + if (NULL != pg->conn) { - GNUNET_PQ_reconnect_if_down (session->conn); - return session; + GNUNET_PQ_reconnect_if_down (pg->conn); + return GNUNET_OK; } - db_conn = GNUNET_PQ_connect_with_cfg (pc->cfg, + db_conn = GNUNET_PQ_connect_with_cfg (pg->cfg, "auditordb-postgres", NULL, NULL, ps); if (NULL == db_conn) - return NULL; - session = GNUNET_new (struct TALER_AUDITORDB_Session); - session->conn = db_conn; - if (0 != pthread_setspecific (pc->db_conn_threadlocal, - session)) - { - GNUNET_break (0); - GNUNET_PQ_disconnect (db_conn); - GNUNET_free (session); - return NULL; - } - return session; + return GNUNET_SYSERR; + pg->conn = db_conn; + return GNUNET_OK; } /** * 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, rollback the previous transaction and output a warning. * * @param cls the `struct PostgresClosure` with the plugin-specific state - * @param session the database connection + * @return #GNUNET_OK on success, + * #GNUNET_NO if we rolled back an earlier transaction + * #GNUNET_SYSERR if we have no DB connection */ -static void -postgres_preflight (void *cls, - struct TALER_AUDITORDB_Session *session) +static enum GNUNET_GenericReturnValue +postgres_preflight (void *cls) { + struct PostgresClosure *pg = cls; struct GNUNET_PQ_ExecuteStatement es[] = { GNUNET_PQ_make_execute ("ROLLBACK"), GNUNET_PQ_EXECUTE_STATEMENT_END }; - (void) cls; - if (NULL == session->transaction_name) - return; /* all good */ + if (NULL == pg->conn) + { + if (GNUNET_OK != + setup_connection (pg)) + { + GNUNET_break (0); + return GNUNET_SYSERR; + } + } + if (NULL == pg->transaction_name) + return GNUNET_OK; /* all good */ if (GNUNET_OK == - GNUNET_PQ_exec_statements (session->conn, + GNUNET_PQ_exec_statements (pg->conn, es)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "BUG: Preflight check rolled back transaction `%s'!\n", - session->transaction_name); + pg->transaction_name); } else { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "BUG: Preflight check failed to rollback transaction `%s'!\n", - session->transaction_name); + pg->transaction_name); } - session->transaction_name = NULL; + pg->transaction_name = NULL; + return GNUNET_NO; } @@ -752,23 +716,20 @@ postgres_preflight (void *cls, * Start a transaction. * * @param cls the `struct PostgresClosure` with the plugin-specific state - * @param session the database connection * @return #GNUNET_OK on success */ -static int -postgres_start (void *cls, - struct TALER_AUDITORDB_Session *session) +static enum GNUNET_GenericReturnValue +postgres_start (void *cls) { + struct PostgresClosure *pg = cls; struct GNUNET_PQ_ExecuteStatement es[] = { GNUNET_PQ_make_execute ("START TRANSACTION ISOLATION LEVEL SERIALIZABLE"), GNUNET_PQ_EXECUTE_STATEMENT_END }; - postgres_preflight (cls, - session); - (void) cls; + postgres_preflight (cls); if (GNUNET_OK != - GNUNET_PQ_exec_statements (session->conn, + GNUNET_PQ_exec_statements (pg->conn, es)) { TALER_LOG_ERROR ("Failed to start transaction\n"); @@ -783,20 +744,18 @@ postgres_start (void *cls, * Roll back the current transaction of a database connection. * * @param cls the `struct PostgresClosure` with the plugin-specific state - * @param session the database connection */ static void -postgres_rollback (void *cls, - struct TALER_AUDITORDB_Session *session) +postgres_rollback (void *cls) { + struct PostgresClosure *pg = cls; struct GNUNET_PQ_ExecuteStatement es[] = { GNUNET_PQ_make_execute ("ROLLBACK"), GNUNET_PQ_EXECUTE_STATEMENT_END }; - (void) cls; GNUNET_break (GNUNET_OK == - GNUNET_PQ_exec_statements (session->conn, + GNUNET_PQ_exec_statements (pg->conn, es)); } @@ -805,19 +764,17 @@ postgres_rollback (void *cls, * Commit the current transaction of a database connection. * * @param cls the `struct PostgresClosure` with the plugin-specific state - * @param session the database connection * @return transaction status code */ enum GNUNET_DB_QueryStatus -postgres_commit (void *cls, - struct TALER_AUDITORDB_Session *session) +postgres_commit (void *cls) { + struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_end }; - (void) cls; - return GNUNET_PQ_eval_prepared_non_select (session->conn, + return GNUNET_PQ_eval_prepared_non_select (pg->conn, "do_commit", params); } @@ -834,7 +791,7 @@ postgres_commit (void *cls, static int postgres_gc (void *cls) { - struct PostgresClosure *pc = cls; + struct PostgresClosure *pg = cls; struct GNUNET_TIME_Absolute now; struct GNUNET_PQ_QueryParam params_time[] = { TALER_PQ_query_param_absolute_time (&now), @@ -852,7 +809,7 @@ postgres_gc (void *cls) }; now = GNUNET_TIME_absolute_get (); - conn = GNUNET_PQ_connect_with_cfg (pc->cfg, + conn = GNUNET_PQ_connect_with_cfg (pg->cfg, "auditordb-postgres", NULL, NULL, @@ -878,25 +835,23 @@ postgres_gc (void *cls) * Insert information about an exchange this auditor will be auditing. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to the database * @param master_pub master public key of the exchange * @param exchange_url public (base) URL of the API of the exchange * @return query result status */ static enum GNUNET_DB_QueryStatus postgres_insert_exchange (void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, const char *exchange_url) { + struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), GNUNET_PQ_query_param_string (exchange_url), GNUNET_PQ_query_param_end }; - (void) cls; - return GNUNET_PQ_eval_prepared_non_select (session->conn, + return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_insert_exchange", params); } @@ -908,22 +863,20 @@ postgres_insert_exchange (void *cls, * to this exchange! * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to the database * @param master_pub master public key of the exchange * @return query result status */ static enum GNUNET_DB_QueryStatus postgres_delete_exchange (void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub) { + struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), GNUNET_PQ_query_param_end }; - (void) cls; - return GNUNET_PQ_eval_prepared_non_select (session->conn, + return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_delete_exchange", params); } @@ -968,7 +921,6 @@ exchange_info_cb (void *cls, { struct ExchangeInfoContext *eic = cls; - (void) cls; for (unsigned int i = 0; i < num_results; i++) { struct TALER_MasterPublicKeyP master_pub; @@ -1001,17 +953,16 @@ exchange_info_cb (void *cls, * Obtain information about exchanges this auditor is auditing. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to the database * @param cb function to call with the results * @param cb_cls closure for @a cb * @return query result status */ static enum GNUNET_DB_QueryStatus postgres_list_exchanges (void *cls, - struct TALER_AUDITORDB_Session *session, TALER_AUDITORDB_ExchangeCallback cb, void *cb_cls) { + struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_end }; @@ -1021,8 +972,7 @@ postgres_list_exchanges (void *cls, }; enum GNUNET_DB_QueryStatus qs; - (void) cls; - qs = GNUNET_PQ_eval_prepared_multi_select (session->conn, + qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, "auditor_list_exchanges", params, &exchange_info_cb, @@ -1038,16 +988,15 @@ postgres_list_exchanges (void *cls, * Insert information about a signing key of the exchange. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to the database * @param sk signing key information to store * @return query result status */ static enum GNUNET_DB_QueryStatus postgres_insert_exchange_signkey ( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_AUDITORDB_ExchangeSigningKey *sk) { + struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (&sk->master_public_key), TALER_PQ_query_param_absolute_time (&sk->ep_start), @@ -1058,8 +1007,7 @@ postgres_insert_exchange_signkey ( GNUNET_PQ_query_param_end }; - (void) cls; - return GNUNET_PQ_eval_prepared_non_select (session->conn, + return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_insert_exchange_signkey", params); } @@ -1069,16 +1017,15 @@ postgres_insert_exchange_signkey ( * Insert information about a deposit confirmation into the database. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to the database * @param dc deposit confirmation information to store * @return query result status */ static enum GNUNET_DB_QueryStatus postgres_insert_deposit_confirmation ( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_AUDITORDB_DepositConfirmation *dc) { + struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (&dc->master_public_key), GNUNET_PQ_query_param_auto_from_type (&dc->h_contract_terms), @@ -1094,8 +1041,7 @@ postgres_insert_deposit_confirmation ( GNUNET_PQ_query_param_end }; - (void) cls; - return GNUNET_PQ_eval_prepared_non_select (session->conn, + return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_deposit_confirmation_insert", params); } @@ -1206,7 +1152,6 @@ deposit_confirmation_cb (void *cls, * Get information about deposit confirmations from the database. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to the database * @param master_public_key for which exchange do we want to get deposit confirmations * @param start_id row/serial ID where to start the iteration (0 from * the start, exclusive, i.e. serial_ids must start from 1) @@ -1217,7 +1162,6 @@ deposit_confirmation_cb (void *cls, static enum GNUNET_DB_QueryStatus postgres_get_deposit_confirmations ( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_public_key, uint64_t start_id, TALER_AUDITORDB_DepositConfirmationCallback cb, @@ -1237,7 +1181,7 @@ postgres_get_deposit_confirmations ( }; enum GNUNET_DB_QueryStatus qs; - qs = GNUNET_PQ_eval_prepared_multi_select (session->conn, + qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, "auditor_deposit_confirmation_select", params, &deposit_confirmation_cb, @@ -1254,7 +1198,6 @@ postgres_get_deposit_confirmations ( * data. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param ppr where is the auditor in processing * @return transaction status code @@ -1262,10 +1205,10 @@ postgres_get_deposit_confirmations ( static enum GNUNET_DB_QueryStatus postgres_insert_auditor_progress_reserve ( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_AUDITORDB_ProgressPointReserve *ppr) { + struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), GNUNET_PQ_query_param_uint64 (&ppr->last_reserve_in_serial_id), @@ -1275,8 +1218,7 @@ postgres_insert_auditor_progress_reserve ( GNUNET_PQ_query_param_end }; - (void) cls; - return GNUNET_PQ_eval_prepared_non_select (session->conn, + return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_progress_insert_reserve", params); } @@ -1287,7 +1229,6 @@ postgres_insert_auditor_progress_reserve ( * must be an existing record for the exchange. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param ppr where is the auditor in processing * @return transaction status code @@ -1295,10 +1236,10 @@ postgres_insert_auditor_progress_reserve ( static enum GNUNET_DB_QueryStatus postgres_update_auditor_progress_reserve ( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_AUDITORDB_ProgressPointReserve *ppr) { + struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_uint64 (&ppr->last_reserve_in_serial_id), GNUNET_PQ_query_param_uint64 (&ppr->last_reserve_out_serial_id), @@ -1308,8 +1249,7 @@ postgres_update_auditor_progress_reserve ( GNUNET_PQ_query_param_end }; - (void) cls; - return GNUNET_PQ_eval_prepared_non_select (session->conn, + return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_progress_update_reserve", params); } @@ -1319,7 +1259,6 @@ postgres_update_auditor_progress_reserve ( * Get information about the progress of the auditor. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param[out] ppr set to where the auditor is in processing * @return transaction status code @@ -1327,10 +1266,10 @@ postgres_update_auditor_progress_reserve ( static enum GNUNET_DB_QueryStatus postgres_get_auditor_progress_reserve ( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, struct TALER_AUDITORDB_ProgressPointReserve *ppr) { + struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), GNUNET_PQ_query_param_end @@ -1347,8 +1286,7 @@ postgres_get_auditor_progress_reserve ( GNUNET_PQ_result_spec_end }; - (void) cls; - return GNUNET_PQ_eval_prepared_singleton_select (session->conn, + return GNUNET_PQ_eval_prepared_singleton_select (pg->conn, "auditor_progress_select_reserve", params, rs); @@ -1360,7 +1298,6 @@ postgres_get_auditor_progress_reserve ( * data. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param ppa where is the auditor in processing * @return transaction status code @@ -1368,18 +1305,17 @@ postgres_get_auditor_progress_reserve ( static enum GNUNET_DB_QueryStatus postgres_insert_auditor_progress_aggregation ( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_AUDITORDB_ProgressPointAggregation *ppa) { + struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), GNUNET_PQ_query_param_uint64 (&ppa->last_wire_out_serial_id), GNUNET_PQ_query_param_end }; - (void) cls; - return GNUNET_PQ_eval_prepared_non_select (session->conn, + return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_progress_insert_aggregation", params); } @@ -1390,7 +1326,6 @@ postgres_insert_auditor_progress_aggregation ( * must be an existing record for the exchange. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param ppa where is the auditor in processing * @return transaction status code @@ -1398,18 +1333,17 @@ postgres_insert_auditor_progress_aggregation ( static enum GNUNET_DB_QueryStatus postgres_update_auditor_progress_aggregation ( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_AUDITORDB_ProgressPointAggregation *ppa) { + struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_uint64 (&ppa->last_wire_out_serial_id), GNUNET_PQ_query_param_auto_from_type (master_pub), GNUNET_PQ_query_param_end }; - (void) cls; - return GNUNET_PQ_eval_prepared_non_select (session->conn, + return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_progress_update_aggregation", params); } @@ -1419,7 +1353,6 @@ postgres_update_auditor_progress_aggregation ( * Get information about the progress of the auditor. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param[out] ppa set to where the auditor is in processing * @return transaction status code @@ -1427,10 +1360,10 @@ postgres_update_auditor_progress_aggregation ( static enum GNUNET_DB_QueryStatus postgres_get_auditor_progress_aggregation ( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, struct TALER_AUDITORDB_ProgressPointAggregation *ppa) { + struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), GNUNET_PQ_query_param_end @@ -1441,8 +1374,7 @@ postgres_get_auditor_progress_aggregation ( GNUNET_PQ_result_spec_end }; - (void) cls; - return GNUNET_PQ_eval_prepared_singleton_select (session->conn, + return GNUNET_PQ_eval_prepared_singleton_select (pg->conn, "auditor_progress_select_aggregation", params, rs); @@ -1454,7 +1386,6 @@ postgres_get_auditor_progress_aggregation ( * data. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param ppdc where is the auditor in processing * @return transaction status code @@ -1462,18 +1393,17 @@ postgres_get_auditor_progress_aggregation ( static enum GNUNET_DB_QueryStatus postgres_insert_auditor_progress_deposit_confirmation ( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_AUDITORDB_ProgressPointDepositConfirmation *ppdc) { + struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), GNUNET_PQ_query_param_uint64 (&ppdc->last_deposit_confirmation_serial_id), GNUNET_PQ_query_param_end }; - (void) cls; - return GNUNET_PQ_eval_prepared_non_select (session->conn, + return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_progress_insert_deposit_confirmation", params); } @@ -1484,7 +1414,6 @@ postgres_insert_auditor_progress_deposit_confirmation ( * must be an existing record for the exchange. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param ppdc where is the auditor in processing * @return transaction status code @@ -1492,18 +1421,17 @@ postgres_insert_auditor_progress_deposit_confirmation ( static enum GNUNET_DB_QueryStatus postgres_update_auditor_progress_deposit_confirmation ( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_AUDITORDB_ProgressPointDepositConfirmation *ppdc) { + struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_uint64 (&ppdc->last_deposit_confirmation_serial_id), GNUNET_PQ_query_param_auto_from_type (master_pub), GNUNET_PQ_query_param_end }; - (void) cls; - return GNUNET_PQ_eval_prepared_non_select (session->conn, + return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_progress_update_deposit_confirmation", params); } @@ -1513,7 +1441,6 @@ postgres_update_auditor_progress_deposit_confirmation ( * Get information about the progress of the auditor. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param[out] ppdc set to where the auditor is in processing * @return transaction status code @@ -1521,10 +1448,10 @@ postgres_update_auditor_progress_deposit_confirmation ( static enum GNUNET_DB_QueryStatus postgres_get_auditor_progress_deposit_confirmation ( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, struct TALER_AUDITORDB_ProgressPointDepositConfirmation *ppdc) { + struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), GNUNET_PQ_query_param_end @@ -1535,8 +1462,7 @@ postgres_get_auditor_progress_deposit_confirmation ( GNUNET_PQ_result_spec_end }; - (void) cls; - return GNUNET_PQ_eval_prepared_singleton_select (session->conn, + return GNUNET_PQ_eval_prepared_singleton_select (pg->conn, "auditor_progress_select_deposit_confirmation", params, rs); @@ -1548,7 +1474,6 @@ postgres_get_auditor_progress_deposit_confirmation ( * data. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param ppc where is the auditor in processing * @return transaction status code @@ -1556,10 +1481,10 @@ postgres_get_auditor_progress_deposit_confirmation ( static enum GNUNET_DB_QueryStatus postgres_insert_auditor_progress_coin ( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_AUDITORDB_ProgressPointCoin *ppc) { + struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), GNUNET_PQ_query_param_uint64 (&ppc->last_withdraw_serial_id), @@ -1571,8 +1496,7 @@ postgres_insert_auditor_progress_coin ( GNUNET_PQ_query_param_end }; - (void) cls; - return GNUNET_PQ_eval_prepared_non_select (session->conn, + return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_progress_insert_coin", params); } @@ -1583,7 +1507,6 @@ postgres_insert_auditor_progress_coin ( * must be an existing record for the exchange. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param ppc where is the auditor in processing * @return transaction status code @@ -1591,10 +1514,10 @@ postgres_insert_auditor_progress_coin ( static enum GNUNET_DB_QueryStatus postgres_update_auditor_progress_coin ( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_AUDITORDB_ProgressPointCoin *ppc) { + struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_uint64 (&ppc->last_withdraw_serial_id), GNUNET_PQ_query_param_uint64 (&ppc->last_deposit_serial_id), @@ -1606,8 +1529,7 @@ postgres_update_auditor_progress_coin ( GNUNET_PQ_query_param_end }; - (void) cls; - return GNUNET_PQ_eval_prepared_non_select (session->conn, + return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_progress_update_coin", params); } @@ -1617,7 +1539,6 @@ postgres_update_auditor_progress_coin ( * Get information about the progress of the auditor. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param[out] ppc set to where the auditor is in processing * @return transaction status code @@ -1625,10 +1546,10 @@ postgres_update_auditor_progress_coin ( static enum GNUNET_DB_QueryStatus postgres_get_auditor_progress_coin ( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, struct TALER_AUDITORDB_ProgressPointCoin *ppc) { + struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), GNUNET_PQ_query_param_end @@ -1649,8 +1570,7 @@ postgres_get_auditor_progress_coin ( GNUNET_PQ_result_spec_end }; - (void) cls; - return GNUNET_PQ_eval_prepared_singleton_select (session->conn, + return GNUNET_PQ_eval_prepared_singleton_select (pg->conn, "auditor_progress_select_coin", params, rs); @@ -1662,7 +1582,6 @@ postgres_get_auditor_progress_coin ( * data. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param account_name name of the wire account we are auditing * @param pp how far are we in the auditor's tables @@ -1673,13 +1592,13 @@ postgres_get_auditor_progress_coin ( static enum GNUNET_DB_QueryStatus postgres_insert_wire_auditor_account_progress ( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, const char *account_name, const struct TALER_AUDITORDB_WireAccountProgressPoint *pp, uint64_t in_wire_off, uint64_t out_wire_off) { + struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), GNUNET_PQ_query_param_string (account_name), @@ -1690,8 +1609,7 @@ postgres_insert_wire_auditor_account_progress ( GNUNET_PQ_query_param_end }; - (void) cls; - return GNUNET_PQ_eval_prepared_non_select (session->conn, + return GNUNET_PQ_eval_prepared_non_select (pg->conn, "wire_auditor_account_progress_insert", params); } @@ -1702,7 +1620,6 @@ postgres_insert_wire_auditor_account_progress ( * must be an existing record for the exchange. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param account_name name of the wire account we are auditing * @param pp where is the auditor in processing @@ -1713,13 +1630,13 @@ postgres_insert_wire_auditor_account_progress ( static enum GNUNET_DB_QueryStatus postgres_update_wire_auditor_account_progress ( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, const char *account_name, const struct TALER_AUDITORDB_WireAccountProgressPoint *pp, uint64_t in_wire_off, uint64_t out_wire_off) { + struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_uint64 (&pp->last_reserve_in_serial_id), GNUNET_PQ_query_param_uint64 (&pp->last_wire_out_serial_id), @@ -1730,8 +1647,7 @@ postgres_update_wire_auditor_account_progress ( GNUNET_PQ_query_param_end }; - (void) cls; - return GNUNET_PQ_eval_prepared_non_select (session->conn, + return GNUNET_PQ_eval_prepared_non_select (pg->conn, "wire_auditor_account_progress_update", params); } @@ -1741,7 +1657,6 @@ postgres_update_wire_auditor_account_progress ( * Get information about the progress of the auditor. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param account_name name of the wire account we are auditing * @param[out] pp where is the auditor in processing @@ -1752,13 +1667,13 @@ postgres_update_wire_auditor_account_progress ( static enum GNUNET_DB_QueryStatus postgres_get_wire_auditor_account_progress ( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, const char *account_name, struct TALER_AUDITORDB_WireAccountProgressPoint *pp, uint64_t *in_wire_off, uint64_t *out_wire_off) { + struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), GNUNET_PQ_query_param_string (account_name), @@ -1776,8 +1691,7 @@ postgres_get_wire_auditor_account_progress ( GNUNET_PQ_result_spec_end }; - (void) cls; - return GNUNET_PQ_eval_prepared_singleton_select (session->conn, + return GNUNET_PQ_eval_prepared_singleton_select (pg->conn, "wire_auditor_account_progress_select", params, rs); @@ -1789,7 +1703,6 @@ postgres_get_wire_auditor_account_progress ( * data. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param pp where is the auditor in processing * @return transaction status code @@ -1797,10 +1710,10 @@ postgres_get_wire_auditor_account_progress ( static enum GNUNET_DB_QueryStatus postgres_insert_wire_auditor_progress ( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_AUDITORDB_WireProgressPoint *pp) { + struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), TALER_PQ_query_param_absolute_time (&pp->last_timestamp), @@ -1808,8 +1721,7 @@ postgres_insert_wire_auditor_progress ( GNUNET_PQ_query_param_end }; - (void) cls; - return GNUNET_PQ_eval_prepared_non_select (session->conn, + return GNUNET_PQ_eval_prepared_non_select (pg->conn, "wire_auditor_progress_insert", params); } @@ -1820,7 +1732,6 @@ postgres_insert_wire_auditor_progress ( * must be an existing record for the exchange. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param pp where is the auditor in processing * @return transaction status code @@ -1828,10 +1739,10 @@ postgres_insert_wire_auditor_progress ( static enum GNUNET_DB_QueryStatus postgres_update_wire_auditor_progress ( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_AUDITORDB_WireProgressPoint *pp) { + struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { TALER_PQ_query_param_absolute_time (&pp->last_timestamp), GNUNET_PQ_query_param_uint64 (&pp->last_reserve_close_uuid), @@ -1839,8 +1750,7 @@ postgres_update_wire_auditor_progress ( GNUNET_PQ_query_param_end }; - (void) cls; - return GNUNET_PQ_eval_prepared_non_select (session->conn, + return GNUNET_PQ_eval_prepared_non_select (pg->conn, "wire_auditor_progress_update", params); } @@ -1850,7 +1760,6 @@ postgres_update_wire_auditor_progress ( * Get information about the progress of the auditor. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param[out] pp set to where the auditor is in processing * @return transaction status code @@ -1858,10 +1767,10 @@ postgres_update_wire_auditor_progress ( static enum GNUNET_DB_QueryStatus postgres_get_wire_auditor_progress ( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, struct TALER_AUDITORDB_WireProgressPoint *pp) { + struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), GNUNET_PQ_query_param_end @@ -1874,8 +1783,7 @@ postgres_get_wire_auditor_progress ( GNUNET_PQ_result_spec_end }; - (void) cls; - return GNUNET_PQ_eval_prepared_singleton_select (session->conn, + return GNUNET_PQ_eval_prepared_singleton_select (pg->conn, "wire_auditor_progress_select", params, rs); @@ -1887,7 +1795,6 @@ postgres_get_wire_auditor_progress ( * existing record for the reserve. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param reserve_pub public key of the reserve * @param master_pub master public key of the exchange * @param reserve_balance amount stored in the reserve @@ -1899,7 +1806,6 @@ postgres_get_wire_auditor_progress ( */ static enum GNUNET_DB_QueryStatus postgres_insert_reserve_info (void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_ReservePublicKeyP *reserve_pub, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_Amount *reserve_balance, @@ -1907,6 +1813,7 @@ postgres_insert_reserve_info (void *cls, struct GNUNET_TIME_Absolute expiration_date, const char *origin_account) { + struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (reserve_pub), GNUNET_PQ_query_param_auto_from_type (master_pub), @@ -1917,12 +1824,11 @@ postgres_insert_reserve_info (void *cls, GNUNET_PQ_query_param_end }; - (void) cls; GNUNET_assert (GNUNET_YES == TALER_amount_cmp_currency (reserve_balance, withdraw_fee_balance)); - return GNUNET_PQ_eval_prepared_non_select (session->conn, + return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_reserves_insert", params); } @@ -1933,7 +1839,6 @@ postgres_insert_reserve_info (void *cls, * existing record, which must already exist. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param reserve_pub public key of the reserve * @param master_pub master public key of the exchange * @param reserve_balance amount stored in the reserve @@ -1944,13 +1849,13 @@ postgres_insert_reserve_info (void *cls, */ static enum GNUNET_DB_QueryStatus postgres_update_reserve_info (void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_ReservePublicKeyP *reserve_pub, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_Amount *reserve_balance, const struct TALER_Amount *withdraw_fee_balance, struct GNUNET_TIME_Absolute expiration_date) { + struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { TALER_PQ_query_param_amount (reserve_balance), TALER_PQ_query_param_amount (withdraw_fee_balance), @@ -1960,12 +1865,11 @@ postgres_update_reserve_info (void *cls, GNUNET_PQ_query_param_end }; - (void) cls; GNUNET_assert (GNUNET_YES == TALER_amount_cmp_currency (reserve_balance, withdraw_fee_balance)); - return GNUNET_PQ_eval_prepared_non_select (session->conn, + return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_reserves_update", params); } @@ -1975,25 +1879,23 @@ postgres_update_reserve_info (void *cls, * Delete information about a reserve. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param reserve_pub public key of the reserve * @param master_pub master public key of the exchange * @return transaction status code */ static enum GNUNET_DB_QueryStatus postgres_del_reserve_info (void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_ReservePublicKeyP *reserve_pub, const struct TALER_MasterPublicKeyP *master_pub) { + struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (reserve_pub), GNUNET_PQ_query_param_auto_from_type (master_pub), GNUNET_PQ_query_param_end }; - (void) cls; - return GNUNET_PQ_eval_prepared_non_select (session->conn, + return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_reserves_delete", params); } @@ -2003,7 +1905,6 @@ postgres_del_reserve_info (void *cls, * Get information about a reserve. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param reserve_pub public key of the reserve * @param master_pub master public key of the exchange * @param[out] rowid which row did we get the information from @@ -2016,7 +1917,6 @@ postgres_del_reserve_info (void *cls, */ static enum GNUNET_DB_QueryStatus postgres_get_reserve_info (void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_ReservePublicKeyP *reserve_pub, const struct TALER_MasterPublicKeyP *master_pub, uint64_t *rowid, @@ -2040,8 +1940,7 @@ postgres_get_reserve_info (void *cls, GNUNET_PQ_result_spec_end }; - (void) cls; - return GNUNET_PQ_eval_prepared_singleton_select (session->conn, + return GNUNET_PQ_eval_prepared_singleton_select (pg->conn, "auditor_reserves_select", params, rs); @@ -2053,7 +1952,6 @@ postgres_get_reserve_info (void *cls, * existing record for the @a master_pub. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master public key of the exchange * @param reserve_balance amount stored in the reserve * @param withdraw_fee_balance amount the exchange gained in withdraw fees @@ -2063,11 +1961,11 @@ postgres_get_reserve_info (void *cls, static enum GNUNET_DB_QueryStatus postgres_insert_reserve_summary ( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_Amount *reserve_balance, const struct TALER_Amount *withdraw_fee_balance) { + struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), TALER_PQ_query_param_amount (reserve_balance), @@ -2075,12 +1973,11 @@ postgres_insert_reserve_summary ( GNUNET_PQ_query_param_end }; - (void) cls; GNUNET_assert (GNUNET_YES == TALER_amount_cmp_currency (reserve_balance, withdraw_fee_balance)); - return GNUNET_PQ_eval_prepared_non_select (session->conn, + return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_reserve_balance_insert", params); } @@ -2091,7 +1988,6 @@ postgres_insert_reserve_summary ( * existing record, which must already exist. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master public key of the exchange * @param reserve_balance amount stored in the reserve * @param withdraw_fee_balance amount the exchange gained in withdraw fees @@ -2101,11 +1997,11 @@ postgres_insert_reserve_summary ( static enum GNUNET_DB_QueryStatus postgres_update_reserve_summary ( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_Amount *reserve_balance, const struct TALER_Amount *withdraw_fee_balance) { + struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { TALER_PQ_query_param_amount (reserve_balance), TALER_PQ_query_param_amount (withdraw_fee_balance), @@ -2113,8 +2009,7 @@ postgres_update_reserve_summary ( GNUNET_PQ_query_param_end }; - (void) cls; - return GNUNET_PQ_eval_prepared_non_select (session->conn, + return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_reserve_balance_update", params); } @@ -2124,7 +2019,6 @@ postgres_update_reserve_summary ( * Get summary information about all reserves. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master public key of the exchange * @param[out] reserve_balance amount stored in the reserve * @param[out] withdraw_fee_balance amount the exchange gained in withdraw fees @@ -2133,7 +2027,6 @@ postgres_update_reserve_summary ( */ static enum GNUNET_DB_QueryStatus postgres_get_reserve_summary (void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, struct TALER_Amount *reserve_balance, struct TALER_Amount *withdraw_fee_balance) @@ -2150,8 +2043,7 @@ postgres_get_reserve_summary (void *cls, GNUNET_PQ_result_spec_end }; - (void) cls; - return GNUNET_PQ_eval_prepared_singleton_select (session->conn, + return GNUNET_PQ_eval_prepared_singleton_select (pg->conn, "auditor_reserve_balance_select", params, rs); @@ -2163,7 +2055,6 @@ postgres_get_reserve_summary (void *cls, * existing record for the same @a master_pub. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master public key of the exchange * @param wire_fee_balance amount the exchange gained in wire fees * @return transaction status code @@ -2171,18 +2062,17 @@ postgres_get_reserve_summary (void *cls, static enum GNUNET_DB_QueryStatus postgres_insert_wire_fee_summary ( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_Amount *wire_fee_balance) { + struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), TALER_PQ_query_param_amount (wire_fee_balance), GNUNET_PQ_query_param_end }; - (void) cls; - return GNUNET_PQ_eval_prepared_non_select (session->conn, + return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_wire_fee_balance_insert", params); } @@ -2193,7 +2083,6 @@ postgres_insert_wire_fee_summary ( * existing record, which must already exist. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master public key of the exchange * @param wire_fee_balance amount the exchange gained in wire fees * @return transaction status code @@ -2201,18 +2090,17 @@ postgres_insert_wire_fee_summary ( static enum GNUNET_DB_QueryStatus postgres_update_wire_fee_summary ( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_Amount *wire_fee_balance) { + struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { TALER_PQ_query_param_amount (wire_fee_balance), GNUNET_PQ_query_param_auto_from_type (master_pub), GNUNET_PQ_query_param_end }; - (void) cls; - return GNUNET_PQ_eval_prepared_non_select (session->conn, + return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_wire_fee_balance_update", params); } @@ -2222,14 +2110,12 @@ postgres_update_wire_fee_summary ( * Get summary information about an exchanges wire fee balance. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master public key of the exchange * @param[out] wire_fee_balance set amount the exchange gained in wire fees * @return transaction status code */ static enum GNUNET_DB_QueryStatus postgres_get_wire_fee_summary (void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, struct TALER_Amount *wire_fee_balance) { @@ -2244,8 +2130,7 @@ postgres_get_wire_fee_summary (void *cls, GNUNET_PQ_result_spec_end }; - (void) cls; - return GNUNET_PQ_eval_prepared_singleton_select (session->conn, + return GNUNET_PQ_eval_prepared_singleton_select (pg->conn, "auditor_wire_fee_balance_select", params, rs); @@ -2257,7 +2142,6 @@ postgres_get_wire_fee_summary (void *cls, * must not be an existing record for the denomination key. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param denom_pub_hash hash of the denomination public key * @param denom_balance value of coins outstanding with this denomination key * @param denom_loss value of coins redeemed that were not outstanding (effectively, negative @a denom_balance) @@ -2269,7 +2153,6 @@ postgres_get_wire_fee_summary (void *cls, static enum GNUNET_DB_QueryStatus postgres_insert_denomination_balance ( void *cls, - struct TALER_AUDITORDB_Session *session, const struct GNUNET_HashCode *denom_pub_hash, const struct TALER_Amount *denom_balance, const struct TALER_Amount *denom_loss, @@ -2277,6 +2160,7 @@ postgres_insert_denomination_balance ( const struct TALER_Amount *recoup_loss, uint64_t num_issued) { + struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (denom_pub_hash), TALER_PQ_query_param_amount (denom_balance), @@ -2287,8 +2171,7 @@ postgres_insert_denomination_balance ( GNUNET_PQ_query_param_end }; - (void) cls; - return GNUNET_PQ_eval_prepared_non_select (session->conn, + return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_denomination_pending_insert", params); } @@ -2299,7 +2182,6 @@ postgres_insert_denomination_balance ( * must be an existing record for the denomination key. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param denom_pub_hash hash of the denomination public key * @param denom_balance value of coins outstanding with this denomination key * @param denom_loss value of coins redeemed that were not outstanding (effectively, negative @a denom_balance) @@ -2311,7 +2193,6 @@ postgres_insert_denomination_balance ( static enum GNUNET_DB_QueryStatus postgres_update_denomination_balance ( void *cls, - struct TALER_AUDITORDB_Session *session, const struct GNUNET_HashCode *denom_pub_hash, const struct TALER_Amount *denom_balance, const struct TALER_Amount *denom_loss, @@ -2319,6 +2200,7 @@ postgres_update_denomination_balance ( const struct TALER_Amount *recoup_loss, uint64_t num_issued) { + struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { TALER_PQ_query_param_amount (denom_balance), TALER_PQ_query_param_amount (denom_loss), @@ -2329,8 +2211,7 @@ postgres_update_denomination_balance ( GNUNET_PQ_query_param_end }; - (void) cls; - return GNUNET_PQ_eval_prepared_non_select (session->conn, + return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_denomination_pending_update", params); } @@ -2340,7 +2221,6 @@ postgres_update_denomination_balance ( * Get information about a denomination key's balances. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param denom_pub_hash hash of the denomination public key * @param[out] denom_balance value of coins outstanding with this denomination key * @param[out] denom_risk value of coins issued with this denomination key @@ -2351,7 +2231,6 @@ postgres_update_denomination_balance ( */ static enum GNUNET_DB_QueryStatus postgres_get_denomination_balance (void *cls, - struct TALER_AUDITORDB_Session *session, const struct GNUNET_HashCode *denom_pub_hash, struct TALER_Amount *denom_balance, struct TALER_Amount *denom_loss, @@ -2373,8 +2252,7 @@ postgres_get_denomination_balance (void *cls, GNUNET_PQ_result_spec_end }; - (void) cls; - return GNUNET_PQ_eval_prepared_singleton_select (session->conn, + return GNUNET_PQ_eval_prepared_singleton_select (pg->conn, "auditor_denomination_pending_select", params, rs); @@ -2386,7 +2264,6 @@ postgres_get_denomination_balance (void *cls, * must not be an existing record for the exchange. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param denom_balance value of coins outstanding with this denomination key * @param deposit_fee_balance total deposit fees collected for this DK @@ -2400,7 +2277,6 @@ postgres_get_denomination_balance (void *cls, static enum GNUNET_DB_QueryStatus postgres_insert_balance_summary ( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_Amount *denom_balance, const struct TALER_Amount *deposit_fee_balance, @@ -2410,6 +2286,7 @@ postgres_insert_balance_summary ( const struct TALER_Amount *loss, const struct TALER_Amount *irregular_recoup) { + struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), TALER_PQ_query_param_amount (denom_balance), @@ -2422,7 +2299,6 @@ postgres_insert_balance_summary ( GNUNET_PQ_query_param_end }; - (void) cls; GNUNET_assert (GNUNET_YES == TALER_amount_cmp_currency (denom_balance, deposit_fee_balance)); @@ -2434,7 +2310,7 @@ postgres_insert_balance_summary ( TALER_amount_cmp_currency (denom_balance, refund_fee_balance)); - return GNUNET_PQ_eval_prepared_non_select (session->conn, + return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_balance_summary_insert", params); } @@ -2445,7 +2321,6 @@ postgres_insert_balance_summary ( * must be an existing record for the exchange. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param denom_balance value of coins outstanding with this denomination key * @param deposit_fee_balance total deposit fees collected for this DK @@ -2459,7 +2334,6 @@ postgres_insert_balance_summary ( static enum GNUNET_DB_QueryStatus postgres_update_balance_summary ( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_Amount *denom_balance, const struct TALER_Amount *deposit_fee_balance, @@ -2469,6 +2343,7 @@ postgres_update_balance_summary ( const struct TALER_Amount *loss, const struct TALER_Amount *irregular_recoup) { + struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { TALER_PQ_query_param_amount (denom_balance), TALER_PQ_query_param_amount (deposit_fee_balance), @@ -2481,8 +2356,7 @@ postgres_update_balance_summary ( GNUNET_PQ_query_param_end }; - (void) cls; - return GNUNET_PQ_eval_prepared_non_select (session->conn, + return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_balance_summary_update", params); } @@ -2492,7 +2366,6 @@ postgres_update_balance_summary ( * Get information about an exchange's denomination balances. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param[out] denom_balance value of coins outstanding with this denomination key * @param[out] deposit_fee_balance total deposit fees collected for this DK @@ -2505,7 +2378,6 @@ postgres_update_balance_summary ( */ static enum GNUNET_DB_QueryStatus postgres_get_balance_summary (void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, struct TALER_Amount *denom_balance, struct TALER_Amount *deposit_fee_balance, @@ -2531,7 +2403,7 @@ postgres_get_balance_summary (void *cls, GNUNET_PQ_result_spec_end }; - return GNUNET_PQ_eval_prepared_singleton_select (session->conn, + return GNUNET_PQ_eval_prepared_singleton_select (pg->conn, "auditor_balance_summary_select", params, rs); @@ -2543,7 +2415,6 @@ postgres_get_balance_summary (void *cls, * revenue about a denomination key. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param denom_pub_hash hash of the denomination key * @param revenue_timestamp when did this profit get realized @@ -2556,13 +2427,13 @@ postgres_get_balance_summary (void *cls, static enum GNUNET_DB_QueryStatus postgres_insert_historic_denom_revenue ( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, const struct GNUNET_HashCode *denom_pub_hash, struct GNUNET_TIME_Absolute revenue_timestamp, const struct TALER_Amount *revenue_balance, const struct TALER_Amount *loss_balance) { + struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), GNUNET_PQ_query_param_auto_from_type (denom_pub_hash), @@ -2572,8 +2443,7 @@ postgres_insert_historic_denom_revenue ( GNUNET_PQ_query_param_end }; - (void) cls; - return GNUNET_PQ_eval_prepared_non_select (session->conn, + return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_historic_denomination_revenue_insert", params); } @@ -2665,7 +2535,6 @@ historic_denom_revenue_cb (void *cls, * of the given @a master_pub. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param cb function to call with the results * @param cb_cls closure for @a cb @@ -2674,7 +2543,6 @@ historic_denom_revenue_cb (void *cls, static enum GNUNET_DB_QueryStatus postgres_select_historic_denom_revenue ( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, TALER_AUDITORDB_HistoricDenominationRevenueDataCallback cb, void *cb_cls) @@ -2691,7 +2559,7 @@ postgres_select_historic_denom_revenue ( }; enum GNUNET_DB_QueryStatus qs; - qs = GNUNET_PQ_eval_prepared_multi_select (session->conn, + qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, "auditor_historic_denomination_revenue_select", params, &historic_denom_revenue_cb, @@ -2706,7 +2574,6 @@ postgres_select_historic_denom_revenue ( * Insert information about an exchange's historic revenue from reserves. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param start_time beginning of aggregated time interval * @param end_time end of aggregated time interval @@ -2716,12 +2583,12 @@ postgres_select_historic_denom_revenue ( static enum GNUNET_DB_QueryStatus postgres_insert_historic_reserve_revenue ( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, struct GNUNET_TIME_Absolute start_time, struct GNUNET_TIME_Absolute end_time, const struct TALER_Amount *reserve_profits) { + struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), TALER_PQ_query_param_absolute_time (&start_time), @@ -2730,8 +2597,7 @@ postgres_insert_historic_reserve_revenue ( GNUNET_PQ_query_param_end }; - (void) cls; - return GNUNET_PQ_eval_prepared_non_select (session->conn, + return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_historic_reserve_summary_insert", params); } @@ -2817,7 +2683,6 @@ historic_reserve_revenue_cb (void *cls, * Return information about an exchange's historic revenue from reserves. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param cb function to call with results * @param cb_cls closure for @a cb @@ -2826,7 +2691,6 @@ historic_reserve_revenue_cb (void *cls, static enum GNUNET_DB_QueryStatus postgres_select_historic_reserve_revenue ( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, TALER_AUDITORDB_HistoricReserveRevenueDataCallback cb, void *cb_cls) @@ -2843,7 +2707,7 @@ postgres_select_historic_reserve_revenue ( .pg = pg }; - qs = GNUNET_PQ_eval_prepared_multi_select (session->conn, + qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, "auditor_historic_reserve_summary_select", params, &historic_reserve_revenue_cb, @@ -2859,7 +2723,6 @@ postgres_select_historic_reserve_revenue ( * account balance. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param balance what the bank account balance of the exchange should show * @return transaction status code @@ -2867,18 +2730,17 @@ postgres_select_historic_reserve_revenue ( static enum GNUNET_DB_QueryStatus postgres_insert_predicted_result ( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_Amount *balance) { + struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), TALER_PQ_query_param_amount (balance), GNUNET_PQ_query_param_end }; - (void) cls; - return GNUNET_PQ_eval_prepared_non_select (session->conn, + return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_predicted_result_insert", params); } @@ -2889,7 +2751,6 @@ postgres_insert_predicted_result ( * must be an existing record for the exchange. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param balance what the bank account balance of the exchange should show * @return transaction status code @@ -2897,18 +2758,17 @@ postgres_insert_predicted_result ( static enum GNUNET_DB_QueryStatus postgres_update_predicted_result ( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_Amount *balance) { + struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { TALER_PQ_query_param_amount (balance), GNUNET_PQ_query_param_auto_from_type (master_pub), GNUNET_PQ_query_param_end }; - (void) cls; - return GNUNET_PQ_eval_prepared_non_select (session->conn, + return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_predicted_result_update", params); } @@ -2918,14 +2778,12 @@ postgres_update_predicted_result ( * Get an exchange's predicted balance. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param[out] balance expected bank account balance of the exchange * @return transaction status code */ static enum GNUNET_DB_QueryStatus postgres_get_predicted_balance (void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, struct TALER_Amount *balance) { @@ -2940,7 +2798,7 @@ postgres_get_predicted_balance (void *cls, GNUNET_PQ_result_spec_end }; - return GNUNET_PQ_eval_prepared_singleton_select (session->conn, + return GNUNET_PQ_eval_prepared_singleton_select (pg->conn, "auditor_predicted_result_select", params, rs); @@ -2962,13 +2820,6 @@ libtaler_plugin_auditordb_postgres_init (void *cls) pg = GNUNET_new (struct PostgresClosure); pg->cfg = cfg; - if (0 != pthread_key_create (&pg->db_conn_threadlocal, - &db_conn_destroy)) - { - TALER_LOG_ERROR ("Cannot create pthread key.\n"); - GNUNET_free (pg); - return NULL; - } if (GNUNET_OK != TALER_config_get_currency (cfg, &pg->currency)) @@ -2978,7 +2829,7 @@ libtaler_plugin_auditordb_postgres_init (void *cls) } plugin = GNUNET_new (struct TALER_AUDITORDB_Plugin); plugin->cls = pg; - plugin->get_session = &postgres_get_session; + plugin->preflight = &postgres_preflight; plugin->drop_tables = &postgres_drop_tables; plugin->create_tables = &postgres_create_tables; plugin->start = &postgres_start; @@ -3075,6 +2926,8 @@ libtaler_plugin_auditordb_postgres_done (void *cls) struct TALER_AUDITORDB_Plugin *plugin = cls; struct PostgresClosure *pg = plugin->cls; + if (NULL != pg->conn) + GNUNET_PQ_disconnect (pg->conn); GNUNET_free (pg->currency); GNUNET_free (pg); GNUNET_free (plugin); diff --git a/src/auditordb/test_auditordb.c b/src/auditordb/test_auditordb.c index 69328ee48..237d8ec83 100644 --- a/src/auditordb/test_auditordb.c +++ b/src/auditordb/test_auditordb.c @@ -73,7 +73,6 @@ static void run (void *cls) { struct GNUNET_CONFIGURATION_Handle *cfg = cls; - struct TALER_AUDITORDB_Session *session; uint64_t rowid; GNUNET_log (GNUNET_ERROR_TYPE_INFO, @@ -94,16 +93,15 @@ run (void *cls) result = 77; goto unload; } - if (NULL == - (session = plugin->get_session (plugin->cls))) + if (GNUNET_SYSERR == + plugin->preflight (plugin->cls)) { result = 77; goto drop; } FAILIF (GNUNET_OK != - plugin->start (plugin->cls, - session)); + plugin->start (plugin->cls)); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "initializing\n"); @@ -164,7 +162,6 @@ run (void *cls) "Test: auditor_insert_exchange\n"); FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->insert_exchange (plugin->cls, - session, &master_pub, "https://exchange/")); @@ -187,7 +184,6 @@ run (void *cls) FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->insert_auditor_progress_coin (plugin->cls, - session, &master_pub, &ppc)); GNUNET_log (GNUNET_ERROR_TYPE_INFO, @@ -200,7 +196,6 @@ run (void *cls) FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->update_auditor_progress_coin (plugin->cls, - session, &master_pub, &ppc)); @@ -209,7 +204,6 @@ run (void *cls) FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->get_auditor_progress_coin (plugin->cls, - session, &master_pub, &ppc2)); FAILIF ( (ppc.last_deposit_serial_id != ppc2.last_deposit_serial_id) || @@ -233,7 +227,6 @@ run (void *cls) FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->insert_reserve_info (plugin->cls, - session, &reserve_pub, &master_pub, &reserve_balance, @@ -246,7 +239,6 @@ run (void *cls) FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->update_reserve_info (plugin->cls, - session, &reserve_pub, &master_pub, &reserve_balance, @@ -260,7 +252,6 @@ run (void *cls) FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->get_reserve_info (plugin->cls, - session, &reserve_pub, &master_pub, &rowid, @@ -281,7 +272,6 @@ run (void *cls) FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->insert_reserve_summary (plugin->cls, - session, &master_pub, &withdraw_fee_balance, &reserve_balance)); @@ -291,7 +281,6 @@ run (void *cls) FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->update_reserve_summary (plugin->cls, - session, &master_pub, &reserve_balance, &withdraw_fee_balance)); @@ -304,7 +293,6 @@ run (void *cls) FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->get_reserve_summary (plugin->cls, - session, &master_pub, &reserve_balance2, &withdraw_fee_balance2)); @@ -362,7 +350,6 @@ run (void *cls) FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->insert_denomination_balance (plugin->cls, - session, &denom_pub_hash, &denom_balance, &denom_loss, @@ -380,7 +367,6 @@ run (void *cls) FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->update_denomination_balance (plugin->cls, - session, &denom_pub_hash, &denom_balance, &denom_loss, @@ -392,7 +378,6 @@ run (void *cls) FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->get_denomination_balance (plugin->cls, - session, &denom_pub_hash, &denom_balance2, &denom_loss2, @@ -411,7 +396,6 @@ run (void *cls) FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->insert_balance_summary (plugin->cls, - session, &master_pub, &refund_fee_balance, &melt_fee_balance, @@ -426,7 +410,6 @@ run (void *cls) FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->update_balance_summary (plugin->cls, - session, &master_pub, &denom_balance, &deposit_fee_balance, @@ -449,7 +432,6 @@ run (void *cls) FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->get_balance_summary (plugin->cls, - session, &master_pub, &denom_balance2, &deposit_fee_balance2, @@ -480,7 +462,6 @@ run (void *cls) FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->insert_historic_denom_revenue (plugin->cls, - session, &master_pub, &denom_pub_hash, past, @@ -489,7 +470,6 @@ run (void *cls) FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->insert_historic_denom_revenue (plugin->cls, - session, &master_pub, &rnd_hash, now, @@ -534,7 +514,6 @@ run (void *cls) FAILIF (0 >= plugin->select_historic_denom_revenue (plugin->cls, - session, &master_pub, & select_historic_denom_revenue_result, @@ -550,7 +529,6 @@ run (void *cls) FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->insert_historic_reserve_revenue (plugin->cls, - session, &master_pub, past, future, @@ -558,7 +536,6 @@ run (void *cls) FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->insert_historic_reserve_revenue (plugin->cls, - session, &master_pub, now, future, @@ -598,7 +575,6 @@ run (void *cls) FAILIF (0 >= plugin->select_historic_reserve_revenue (plugin->cls, - session, &master_pub, select_historic_reserve_revenue_result, NULL)); @@ -608,7 +584,6 @@ run (void *cls) FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->insert_predicted_result (plugin->cls, - session, &master_pub, &rbalance)); @@ -621,18 +596,15 @@ run (void *cls) FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->update_predicted_result (plugin->cls, - session, &master_pub, &rbalance)); FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->insert_wire_fee_summary (plugin->cls, - session, &master_pub, &rbalance)); FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->update_wire_fee_summary (plugin->cls, - session, &master_pub, &reserve_profits)); { @@ -640,7 +612,6 @@ run (void *cls) FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->get_wire_fee_summary (plugin->cls, - session, &master_pub, &rprof)); FAILIF (0 != @@ -648,34 +619,29 @@ run (void *cls) &reserve_profits)); } FAILIF (0 > - plugin->commit (plugin->cls, - session)); + plugin->commit (plugin->cls)); FAILIF (GNUNET_OK != - plugin->start (plugin->cls, - session)); + plugin->start (plugin->cls)); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Test: get_predicted_balance\n"); FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->get_predicted_balance (plugin->cls, - session, &master_pub, &rbalance2)); FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->del_reserve_info (plugin->cls, - session, &reserve_pub, &master_pub)); FAILIF (0 != TALER_amount_cmp (&rbalance2, &rbalance)); - plugin->rollback (plugin->cls, - session); + plugin->rollback (plugin->cls); #if GC_IMPLEMENTED FAILIF (GNUNET_OK != @@ -685,22 +651,17 @@ run (void *cls) result = 0; drop: - if (NULL != session) { - plugin->rollback (plugin->cls, - session); + plugin->rollback (plugin->cls); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Test: auditor_delete_exchange\n"); GNUNET_break (GNUNET_OK == - plugin->start (plugin->cls, - session)); + plugin->start (plugin->cls)); GNUNET_break (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == plugin->delete_exchange (plugin->cls, - session, &master_pub)); GNUNET_break (0 <= - plugin->commit (plugin->cls, - session)); + plugin->commit (plugin->cls)); } GNUNET_break (GNUNET_OK == plugin->drop_tables (plugin->cls, diff --git a/src/exchange/taler-exchange-httpd_keys.c b/src/exchange/taler-exchange-httpd_keys.c index f37aafbd1..3b5616345 100644 --- a/src/exchange/taler-exchange-httpd_keys.c +++ b/src/exchange/taler-exchange-httpd_keys.c @@ -344,9 +344,7 @@ static struct TEH_KeyStateHandle *key_state; /** * Counter incremented whenever we have a reason to re-build the keys because - * something external changed (in another thread). The counter is manipulated - * using an atomic update, and thus to ensure that threads notice when it - * changes, the variable MUST be volatile. See #TEH_keys_get_state() and + * something external changed (in another thread). See #TEH_keys_get_state() and * #TEH_keys_update_states() for uses of this variable. */ static uint64_t key_generation; @@ -1721,8 +1719,7 @@ build_key_state (struct HelperState *hs, void TEH_keys_update_states () { - __sync_fetch_and_add (&key_generation, - 1); + key_generation++; TEH_resume_keys_requests (false); } diff --git a/src/include/taler_auditordb_plugin.h b/src/include/taler_auditordb_plugin.h index 405a90ed5..7733009b7 100644 --- a/src/include/taler_auditordb_plugin.h +++ b/src/include/taler_auditordb_plugin.h @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014-2018 Taler Systems SA + 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 @@ -357,12 +357,6 @@ typedef int /** - * Handle for one session with the database. - */ -struct TALER_AUDITORDB_Session; - - -/** * @brief The plugin API, returned from the plugin's "init" function. * The argument given to "init" is simply a configuration handle. * @@ -384,14 +378,16 @@ struct TALER_AUDITORDB_Plugin char *library_name; /** - * Get the thread-local database-handle. - * Connect to the db if the connection does not exist yet. + * Fully connect to the db if the connection does not exist yet + * and check that there is no transaction currently running. * * @param cls the @e cls of this struct with the plugin-specific state - * @param the database connection, or NULL on error + * @return #GNUNET_OK on success + * #GNUNET_NO if we rolled back an earlier transaction + * #GNUNET_SYSERR if we have no DB connection */ - struct TALER_AUDITORDB_Session * - (*get_session) (void *cls); + enum GNUNET_GenericReturnValue + (*preflight)(void *cls); /** @@ -405,9 +401,9 @@ struct TALER_AUDITORDB_Plugin * used when restarting the auditor * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure */ - int - (*drop_tables) (void *cls, - int drop_exchangelist); + enum GNUNET_GenericReturnValue + (*drop_tables)(void *cls, + int drop_exchangelist); /** @@ -416,43 +412,37 @@ struct TALER_AUDITORDB_Plugin * @param cls the @e cls of this struct with the plugin-specific state * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure */ - int - (*create_tables) (void *cls); + enum GNUNET_GenericReturnValue + (*create_tables)(void *cls); /** * Start a transaction. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @return #GNUNET_OK on success */ - int - (*start) (void *cls, - struct TALER_AUDITORDB_Session *session); + enum GNUNET_GenericReturnValue + (*start)(void *cls); /** * Commit a transaction. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @return transaction status code */ enum GNUNET_DB_QueryStatus - (*commit)(void *cls, - struct TALER_AUDITORDB_Session *session); + (*commit)(void *cls); /** * Abort/rollback a transaction. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use */ void - (*rollback) (void *cls, - struct TALER_AUDITORDB_Session *session); + (*rollback) (void *cls); /** @@ -471,14 +461,12 @@ struct TALER_AUDITORDB_Plugin * Insert information about an exchange this auditor will be auditing. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to the database * @param master_pub master public key of the exchange * @param exchange_url public (base) URL of the API of the exchange * @return query result status */ enum GNUNET_DB_QueryStatus (*insert_exchange)(void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, const char *exchange_url); @@ -489,13 +477,11 @@ struct TALER_AUDITORDB_Plugin * to this exchange! * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to the database * @param master_pub master public key of the exchange * @return query result status */ enum GNUNET_DB_QueryStatus (*delete_exchange)(void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub); @@ -503,14 +489,12 @@ struct TALER_AUDITORDB_Plugin * Obtain information about exchanges this auditor is auditing. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to the database * @param cb function to call with the results * @param cb_cls closure for @a cb * @return query result status */ enum GNUNET_DB_QueryStatus (*list_exchanges)(void *cls, - struct TALER_AUDITORDB_Session *session, TALER_AUDITORDB_ExchangeCallback cb, void *cb_cls); @@ -518,14 +502,12 @@ struct TALER_AUDITORDB_Plugin * Insert information about a signing key of the exchange. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to the database * @param sk signing key information to store * @return query result status */ enum GNUNET_DB_QueryStatus (*insert_exchange_signkey)( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_AUDITORDB_ExchangeSigningKey *sk); @@ -533,14 +515,12 @@ struct TALER_AUDITORDB_Plugin * Insert information about a deposit confirmation into the database. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to the database * @param dc deposit confirmation information to store * @return query result status */ enum GNUNET_DB_QueryStatus (*insert_deposit_confirmation)( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_AUDITORDB_DepositConfirmation *dc); @@ -548,7 +528,6 @@ struct TALER_AUDITORDB_Plugin * Get information about deposit confirmations from the database. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to the database * @param master_public_key for which exchange do we want to get deposit confirmations * @param start_id row/serial ID where to start the iteration (0 from * the start, exclusive, i.e. serial_ids must start from 1) @@ -559,7 +538,6 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus (*get_deposit_confirmations)( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_public_key, uint64_t start_id, TALER_AUDITORDB_DepositConfirmationCallback cb, @@ -571,7 +549,6 @@ struct TALER_AUDITORDB_Plugin * data. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param ppc where is the auditor in processing * @return transaction status code @@ -579,7 +556,6 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus (*insert_auditor_progress_coin)( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_AUDITORDB_ProgressPointCoin *ppc); @@ -589,7 +565,6 @@ struct TALER_AUDITORDB_Plugin * must be an existing record for the exchange. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param ppc where is the auditor in processing * @return transaction status code @@ -597,7 +572,6 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus (*update_auditor_progress_coin)( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_AUDITORDB_ProgressPointCoin *ppc); @@ -606,14 +580,12 @@ struct TALER_AUDITORDB_Plugin * Get information about the progress of the auditor. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param[out] ppc set to where the auditor is in processing * @return transaction status code */ enum GNUNET_DB_QueryStatus (*get_auditor_progress_coin)(void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, struct TALER_AUDITORDB_ProgressPointCoin *ppc); @@ -622,7 +594,6 @@ struct TALER_AUDITORDB_Plugin * data. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param ppr where is the auditor in processing * @return transaction status code @@ -630,7 +601,6 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus (*insert_auditor_progress_reserve)( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_AUDITORDB_ProgressPointReserve *ppr); @@ -640,7 +610,6 @@ struct TALER_AUDITORDB_Plugin * must be an existing record for the exchange. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param ppr where is the auditor in processing * @return transaction status code @@ -648,7 +617,6 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus (*update_auditor_progress_reserve)( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_AUDITORDB_ProgressPointReserve *ppr); @@ -657,7 +625,6 @@ struct TALER_AUDITORDB_Plugin * Get information about the progress of the auditor. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param[out] ppr set to where the auditor is in processing * @return transaction status code @@ -665,7 +632,6 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus (*get_auditor_progress_reserve)( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, struct TALER_AUDITORDB_ProgressPointReserve *ppr); @@ -674,7 +640,6 @@ struct TALER_AUDITORDB_Plugin * data. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param ppdc where is the auditor in processing * @return transaction status code @@ -682,7 +647,6 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus (*insert_auditor_progress_deposit_confirmation)( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_AUDITORDB_ProgressPointDepositConfirmation *ppdc); @@ -692,7 +656,6 @@ struct TALER_AUDITORDB_Plugin * must be an existing record for the exchange. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param ppdc where is the auditor in processing * @return transaction status code @@ -700,7 +663,6 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus (*update_auditor_progress_deposit_confirmation)( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_AUDITORDB_ProgressPointDepositConfirmation *ppdc); @@ -709,7 +671,6 @@ struct TALER_AUDITORDB_Plugin * Get information about the progress of the auditor. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param[out] ppdc set to where the auditor is in processing * @return transaction status code @@ -717,7 +678,6 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus (*get_auditor_progress_deposit_confirmation)( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, struct TALER_AUDITORDB_ProgressPointDepositConfirmation *ppdc); @@ -727,7 +687,6 @@ struct TALER_AUDITORDB_Plugin * data. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param ppa where is the auditor in processing * @return transaction status code @@ -735,7 +694,6 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus (*insert_auditor_progress_aggregation)( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_AUDITORDB_ProgressPointAggregation *ppa); @@ -745,7 +703,6 @@ struct TALER_AUDITORDB_Plugin * must be an existing record for the exchange. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param ppa where is the auditor in processing * @return transaction status code @@ -753,7 +710,6 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus (*update_auditor_progress_aggregation)( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_AUDITORDB_ProgressPointAggregation *ppa); @@ -762,7 +718,6 @@ struct TALER_AUDITORDB_Plugin * Get information about the progress of the auditor. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param[out] ppa set to where the auditor is in processing * @return transaction status code @@ -770,7 +725,6 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus (*get_auditor_progress_aggregation)( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, struct TALER_AUDITORDB_ProgressPointAggregation *ppa); @@ -780,7 +734,6 @@ struct TALER_AUDITORDB_Plugin * data. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param account_name name of the wire account we are auditing * @param pp where is the auditor in processing @@ -791,7 +744,6 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus (*insert_wire_auditor_account_progress)( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, const char *account_name, const struct TALER_AUDITORDB_WireAccountProgressPoint *pp, @@ -804,7 +756,6 @@ struct TALER_AUDITORDB_Plugin * must be an existing record for the exchange. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param account_name name of the wire account we are auditing * @param pp where is the auditor in processing @@ -815,7 +766,6 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus (*update_wire_auditor_account_progress)( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, const char *account_name, const struct TALER_AUDITORDB_WireAccountProgressPoint *pp, @@ -827,7 +777,6 @@ struct TALER_AUDITORDB_Plugin * Get information about the progress of the wire auditor. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param account_name name of the wire account we are auditing * @param[out] pp where is the auditor in processing @@ -838,7 +787,6 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus (*get_wire_auditor_account_progress)( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, const char *account_name, struct TALER_AUDITORDB_WireAccountProgressPoint *pp, @@ -851,7 +799,6 @@ struct TALER_AUDITORDB_Plugin * data. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param account_name name of the wire account we are auditing * @param pp where is the auditor in processing @@ -860,7 +807,6 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus (*insert_wire_auditor_progress)( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_AUDITORDB_WireProgressPoint *pp); @@ -870,7 +816,6 @@ struct TALER_AUDITORDB_Plugin * must be an existing record for the exchange. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param account_name name of the wire account we are auditing * @param pp where is the auditor in processing @@ -879,7 +824,6 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus (*update_wire_auditor_progress)( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_AUDITORDB_WireProgressPoint *pp); @@ -888,7 +832,6 @@ struct TALER_AUDITORDB_Plugin * Get information about the progress of the wire auditor. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param account_name name of the wire account we are auditing * @param[out] pp set to where the auditor is in processing @@ -896,7 +839,6 @@ struct TALER_AUDITORDB_Plugin */ enum GNUNET_DB_QueryStatus (*get_wire_auditor_progress)(void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, struct TALER_AUDITORDB_WireProgressPoint *pp); @@ -906,7 +848,6 @@ struct TALER_AUDITORDB_Plugin * existing record for the reserve. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param reserve_pub public key of the reserve * @param master_pub master public key of the exchange * @param reserve_balance amount stored in the reserve @@ -918,7 +859,6 @@ struct TALER_AUDITORDB_Plugin */ enum GNUNET_DB_QueryStatus (*insert_reserve_info)(void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_ReservePublicKeyP *reserve_pub, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_Amount *reserve_balance, @@ -932,7 +872,6 @@ struct TALER_AUDITORDB_Plugin * existing record, which must already exist. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param reserve_pub public key of the reserve * @param master_pub master public key of the exchange * @param reserve_balance amount stored in the reserve @@ -943,7 +882,6 @@ struct TALER_AUDITORDB_Plugin */ enum GNUNET_DB_QueryStatus (*update_reserve_info)(void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_ReservePublicKeyP *reserve_pub, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_Amount *reserve_balance, @@ -955,7 +893,6 @@ struct TALER_AUDITORDB_Plugin * Get information about a reserve. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param reserve_pub public key of the reserve * @param master_pub master public key of the exchange * @param[out] rowid which row did we get the information from @@ -968,7 +905,6 @@ struct TALER_AUDITORDB_Plugin */ enum GNUNET_DB_QueryStatus (*get_reserve_info)(void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_ReservePublicKeyP *reserve_pub, const struct TALER_MasterPublicKeyP *master_pub, uint64_t *rowid, @@ -982,14 +918,12 @@ struct TALER_AUDITORDB_Plugin * Delete information about a reserve. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param reserve_pub public key of the reserve * @param master_pub master public key of the exchange * @return transaction status code */ enum GNUNET_DB_QueryStatus (*del_reserve_info)(void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_ReservePublicKeyP *reserve_pub, const struct TALER_MasterPublicKeyP *master_pub); @@ -999,7 +933,6 @@ struct TALER_AUDITORDB_Plugin * existing record for the @a master_pub. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master public key of the exchange * @param reserve_balance amount stored in the reserve * @param withdraw_fee_balance amount the exchange gained in withdraw fees @@ -1008,7 +941,6 @@ struct TALER_AUDITORDB_Plugin */ enum GNUNET_DB_QueryStatus (*insert_reserve_summary)(void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_Amount *reserve_balance, const struct TALER_Amount *withdraw_fee_balance); @@ -1019,7 +951,6 @@ struct TALER_AUDITORDB_Plugin * existing record, which must already exist. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master public key of the exchange * @param reserve_balance amount stored in the reserve * @param withdraw_fee_balance amount the exchange gained in withdraw fees @@ -1028,7 +959,6 @@ struct TALER_AUDITORDB_Plugin */ enum GNUNET_DB_QueryStatus (*update_reserve_summary)(void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_Amount *reserve_balance, const struct TALER_Amount *withdraw_fee_balance); @@ -1038,7 +968,6 @@ struct TALER_AUDITORDB_Plugin * Get summary information about all reserves. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master public key of the exchange * @param[out] reserve_balance amount stored in the reserve * @param[out] withdraw_fee_balance amount the exchange gained in withdraw fees @@ -1047,7 +976,6 @@ struct TALER_AUDITORDB_Plugin */ enum GNUNET_DB_QueryStatus (*get_reserve_summary)(void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, struct TALER_Amount *reserve_balance, struct TALER_Amount *withdraw_fee_balance); @@ -1058,14 +986,12 @@ struct TALER_AUDITORDB_Plugin * existing record for the same @a master_pub. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master public key of the exchange * @param wire_fee_balance amount the exchange gained in wire fees * @return transaction status code */ enum GNUNET_DB_QueryStatus (*insert_wire_fee_summary)(void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_Amount *wire_fee_balance); @@ -1075,14 +1001,12 @@ struct TALER_AUDITORDB_Plugin * existing record, which must already exist. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master public key of the exchange * @param wire_fee_balance amount the exchange gained in wire fees * @return transaction status code */ enum GNUNET_DB_QueryStatus (*update_wire_fee_summary)(void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_Amount *wire_fee_balance); @@ -1091,14 +1015,12 @@ struct TALER_AUDITORDB_Plugin * Get summary information about an exchanges wire fee balance. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master public key of the exchange * @param[out] wire_fee_balance set amount the exchange gained in wire fees * @return transaction status code */ enum GNUNET_DB_QueryStatus (*get_wire_fee_summary)(void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, struct TALER_Amount *wire_fee_balance); @@ -1108,7 +1030,6 @@ struct TALER_AUDITORDB_Plugin * must not be an existing record for the denomination key. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param denom_pub_hash hash of the denomination public key * @param denom_balance value of coins outstanding with this denomination key * @param denom_loss value of coins redeemed that were not outstanding (effectively, negative @a denom_balance) @@ -1119,7 +1040,6 @@ struct TALER_AUDITORDB_Plugin */ enum GNUNET_DB_QueryStatus (*insert_denomination_balance)(void *cls, - struct TALER_AUDITORDB_Session *session, const struct GNUNET_HashCode *denom_pub_hash, const struct TALER_Amount *denom_balance, const struct TALER_Amount *denom_loss, @@ -1133,7 +1053,6 @@ struct TALER_AUDITORDB_Plugin * must be an existing record for the denomination key. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param denom_pub_hash hash of the denomination public key * @param denom_balance value of coins outstanding with this denomination key * @param denom_loss value of coins redeemed that were not outstanding (effectively, negative @a denom_balance) @@ -1144,7 +1063,6 @@ struct TALER_AUDITORDB_Plugin */ enum GNUNET_DB_QueryStatus (*update_denomination_balance)(void *cls, - struct TALER_AUDITORDB_Session *session, const struct GNUNET_HashCode *denom_pub_hash, const struct TALER_Amount *denom_balance, const struct TALER_Amount *denom_loss, @@ -1157,7 +1075,6 @@ struct TALER_AUDITORDB_Plugin * Get information about a denomination key's balances. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param denom_pub_hash hash of the denomination public key * @param[out] denom_balance value of coins outstanding with this denomination key * @param[out] denom_loss value of coins redeemed that were not outstanding (effectively, negative @a denom_balance) @@ -1168,7 +1085,6 @@ struct TALER_AUDITORDB_Plugin */ enum GNUNET_DB_QueryStatus (*get_denomination_balance)(void *cls, - struct TALER_AUDITORDB_Session *session, const struct GNUNET_HashCode *denom_pub_hash, struct TALER_Amount *denom_balance, struct TALER_Amount *denom_loss, @@ -1181,13 +1097,11 @@ struct TALER_AUDITORDB_Plugin * Delete information about a denomination key's balances. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param denom_pub_hash hash of the denomination public key * @return transaction status code */ enum GNUNET_DB_QueryStatus (*del_denomination_balance)(void *cls, - struct TALER_AUDITORDB_Session *session, const struct GNUNET_HashCode *denom_pub_hash); @@ -1196,7 +1110,6 @@ struct TALER_AUDITORDB_Plugin * must not be an existing record for the exchange. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param denom_balance value of coins outstanding with this denomination key * @param deposit_fee_balance total deposit fees collected for this DK @@ -1210,7 +1123,6 @@ struct TALER_AUDITORDB_Plugin */ enum GNUNET_DB_QueryStatus (*insert_balance_summary)(void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_Amount *denom_balance, const struct TALER_Amount *deposit_fee_balance, @@ -1226,7 +1138,6 @@ struct TALER_AUDITORDB_Plugin * must be an existing record for the exchange. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param denom_balance value of coins outstanding with this denomination key * @param deposit_fee_balance total deposit fees collected for this DK @@ -1240,7 +1151,6 @@ struct TALER_AUDITORDB_Plugin */ enum GNUNET_DB_QueryStatus (*update_balance_summary)(void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_Amount *denom_balance, const struct TALER_Amount *deposit_fee_balance, @@ -1255,7 +1165,6 @@ struct TALER_AUDITORDB_Plugin * Get information about an exchange's denomination balances. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param[out] denom_balance value of coins outstanding with this denomination key * @param[out] deposit_fee_balance total deposit fees collected for this DK @@ -1269,7 +1178,6 @@ struct TALER_AUDITORDB_Plugin */ enum GNUNET_DB_QueryStatus (*get_balance_summary)(void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, struct TALER_Amount *denom_balance, struct TALER_Amount *deposit_fee_balance, @@ -1285,7 +1193,6 @@ struct TALER_AUDITORDB_Plugin * revenue about a denomination key. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param denom_pub_hash hash of the denomination key * @param revenue_timestamp when did this profit get realized @@ -1298,7 +1205,6 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus (*insert_historic_denom_revenue)( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, const struct GNUNET_HashCode *denom_pub_hash, struct GNUNET_TIME_Absolute revenue_timestamp, @@ -1311,7 +1217,6 @@ struct TALER_AUDITORDB_Plugin * of the given @a master_pub. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param cb function to call with the results * @param cb_cls closure for @a cb @@ -1320,7 +1225,6 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus (*select_historic_denom_revenue)( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, TALER_AUDITORDB_HistoricDenominationRevenueDataCallback cb, void *cb_cls); @@ -1330,7 +1234,6 @@ struct TALER_AUDITORDB_Plugin * Insert information about an exchange's historic revenue from reserves. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param start_time beginning of aggregated time interval * @param end_time end of aggregated time interval @@ -1340,7 +1243,6 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus (*insert_historic_reserve_revenue)( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, struct GNUNET_TIME_Absolute start_time, struct GNUNET_TIME_Absolute end_time, @@ -1351,7 +1253,6 @@ struct TALER_AUDITORDB_Plugin * Return information about an exchange's historic revenue from reserves. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param cb function to call with results * @param cb_cls closure for @a cb @@ -1360,7 +1261,6 @@ struct TALER_AUDITORDB_Plugin enum GNUNET_DB_QueryStatus (*select_historic_reserve_revenue)( void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, TALER_AUDITORDB_HistoricReserveRevenueDataCallback cb, void *cb_cls); @@ -1371,14 +1271,12 @@ struct TALER_AUDITORDB_Plugin * account balance. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param balance what the bank account balance of the exchange should show * @return transaction status code */ enum GNUNET_DB_QueryStatus (*insert_predicted_result)(void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_Amount *balance); @@ -1388,14 +1286,12 @@ struct TALER_AUDITORDB_Plugin * must be an existing record for the exchange. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param balance what the bank account balance of the exchange should show * @return transaction status code */ enum GNUNET_DB_QueryStatus (*update_predicted_result)(void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_Amount *balance); @@ -1404,14 +1300,12 @@ struct TALER_AUDITORDB_Plugin * Get an exchange's predicted balance. * * @param cls the @e cls of this struct with the plugin-specific state - * @param session connection to use * @param master_pub master key of the exchange * @param[out] balance expected bank account balance of the exchange * @return transaction status code */ enum GNUNET_DB_QueryStatus (*get_predicted_balance)(void *cls, - struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, struct TALER_Amount *balance); diff --git a/src/mhd/mhd_config.c b/src/mhd/mhd_config.c index d6e1a25cf..0e9f2e088 100644 --- a/src/mhd/mhd_config.c +++ b/src/mhd/mhd_config.c @@ -255,6 +255,7 @@ TALER_MHD_open_unix_path (const char *unix_path, GNUNET_free (un); return -1; } + if (GNUNET_OK != GNUNET_NETWORK_socket_bind (nh, (void *) un, @@ -446,6 +447,18 @@ TALER_MHD_bind (const struct GNUNET_CONFIGURATION_Handle *cfg, freeaddrinfo (res); return -1; } + { + const int on = 1; + + if (GNUNET_OK != + GNUNET_NETWORK_socket_setsockopt (nh, + SOL_SOCKET, + SO_REUSEPORT, + &on, + sizeof(on))) + GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, + "setsockopt"); + } if (GNUNET_OK != GNUNET_NETWORK_socket_bind (nh, res->ai_addr, diff --git a/src/util/test_payto.c b/src/util/test_payto.c index 321e998b7..5de0bf355 100644 --- a/src/util/test_payto.c +++ b/src/util/test_payto.c @@ -46,6 +46,8 @@ main (int argc, GNUNET_log_setup ("test-payto", "WARNING", NULL); + GNUNET_assert (NULL == + TALER_iban_validate ("FR1420041010050500013M02606")); r = TALER_xtalerbank_account_from_payto ( "payto://x-taler-bank/localhost:1080/alice"); CHECK ("alice", |