diff options
author | Christian Grothoff <christian@grothoff.org> | 2020-03-05 23:02:38 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2020-03-05 23:02:38 +0100 |
commit | a49bfef2fb3f0ab1f662fe53cb6c72f0587827f9 (patch) | |
tree | 420f7a4901e36461400abbf5a78f305ff6f4adb7 /src | |
parent | 7dd52a08923ccbacd737d4ed719651306744edad (diff) |
rename for consistency
Diffstat (limited to 'src')
-rw-r--r-- | src/auditor/taler-auditor.c | 38 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_withdraw.c | 6 | ||||
-rw-r--r-- | src/exchangedb/plugin_exchangedb_postgres.c | 88 | ||||
-rw-r--r-- | src/exchangedb/test_exchangedb.c | 28 | ||||
-rw-r--r-- | src/include/taler_exchangedb_plugin.h | 92 | ||||
-rw-r--r-- | src/include/taler_util.h | 16 |
6 files changed, 144 insertions, 124 deletions
diff --git a/src/auditor/taler-auditor.c b/src/auditor/taler-auditor.c index add807f5e..7f76b235c 100644 --- a/src/auditor/taler-auditor.c +++ b/src/auditor/taler-auditor.c @@ -1641,9 +1641,9 @@ verify_reserve_balance (void *cls, ret = GNUNET_OK; reserve.pub = rs->reserve_pub; - qs = edb->reserve_get (edb->cls, - esession, - &reserve); + qs = edb->reserves_get (edb->cls, + esession, + &reserve); if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) { char *diag; @@ -1956,11 +1956,11 @@ analyze_reserves (void *cls) GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); return qs; } - qs = edb->select_reserves_out_above_serial_id (edb->cls, - esession, - ppr.last_reserve_out_serial_id, - &handle_reserve_out, - &rc); + qs = edb->select_withdrawals_above_serial_id (edb->cls, + esession, + ppr.last_reserve_out_serial_id, + &handle_reserve_out, + &rc); if (qs < 0) { GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); @@ -4712,12 +4712,12 @@ analyze_coins (void *cls) /* process withdrawals */ if (0 > - (qs = edb->select_reserves_out_above_serial_id (edb->cls, - esession, - ppc. - last_withdraw_serial_id, - &withdraw_cb, - &cc)) ) + (qs = edb->select_withdrawals_above_serial_id (edb->cls, + esession, + ppc. + last_withdraw_serial_id, + &withdraw_cb, + &cc)) ) { GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); return qs; @@ -4741,11 +4741,11 @@ analyze_coins (void *cls) /* process refreshs */ if (0 > - (qs = edb->select_refreshs_above_serial_id (edb->cls, - esession, - ppc.last_melt_serial_id, - &refresh_session_cb, - &cc))) + (qs = edb->select_refreshes_above_serial_id (edb->cls, + esession, + ppc.last_melt_serial_id, + &refresh_session_cb, + &cc))) { GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); return qs; diff --git a/src/exchange/taler-exchange-httpd_withdraw.c b/src/exchange/taler-exchange-httpd_withdraw.c index c8ca4822f..f766a3498 100644 --- a/src/exchange/taler-exchange-httpd_withdraw.c +++ b/src/exchange/taler-exchange-httpd_withdraw.c @@ -234,9 +234,9 @@ withdraw_transaction (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Trying to withdraw from reserve: %s\n", TALER_B2S (&r.pub)); - qs = TEH_plugin->reserve_get (TEH_plugin->cls, - session, - &r); + qs = TEH_plugin->reserves_get (TEH_plugin->cls, + session, + &r); if (0 > qs) { if (GNUNET_DB_STATUS_HARD_ERROR == qs) diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c index 67ba8de99..cc990d7de 100644 --- a/src/exchangedb/plugin_exchangedb_postgres.c +++ b/src/exchangedb/plugin_exchangedb_postgres.c @@ -341,8 +341,8 @@ postgres_get_session (void *cls) " FROM denomination_revocations" " WHERE denom_pub_hash=$1;", 1), - /* Used in #postgres_reserve_get() */ - GNUNET_PQ_make_prepare ("reserve_get", + /* Used in #postgres_reserves_get() */ + GNUNET_PQ_make_prepare ("reserves_get", "SELECT" " current_balance_val" ",current_balance_frac" @@ -525,7 +525,7 @@ postgres_get_session (void *cls) " WHERE reserve_pub=$1" " FOR UPDATE", 1), - /* Used in #postgres_select_reserves_out_above_serial_id() */ + /* Used in #postgres_select_withdrawals_above_serial_id() */ GNUNET_PQ_make_prepare ("audit_get_reserves_out_incr", "SELECT" " h_blind_ev" @@ -628,7 +628,7 @@ postgres_get_session (void *cls) " FROM refresh_commitments" " WHERE rc=$1;", 1), - /* Used in #postgres_select_refreshs_above_serial_id() to fetch + /* Used in #postgres_select_refreshes_above_serial_id() to fetch refresh session with id '\geq' the given parameter */ GNUNET_PQ_make_prepare ("audit_get_refresh_commitments_incr", "SELECT" @@ -906,7 +906,8 @@ postgres_get_session (void *cls) " done=FALSE" " ORDER BY wire_deadline ASC" " LIMIT " - TALER_EXCHANGEDB_MATCHING_DEPOSITS_LIMIT_STR ";", + TALER_QUOTE ( + TALER_EXCHANGEDB_MATCHING_DEPOSITS_LIMIT) ";", 2), /* Used in #postgres_mark_deposit_tiny() */ GNUNET_PQ_make_prepare ("mark_deposit_tiny", @@ -1687,7 +1688,7 @@ struct DenomIteratorContext /** * Function to call with the results. */ - TALER_EXCHANGEDB_DenominationInfoIterator cb; + TALER_EXCHANGEDB_DenominationCallback cb; /** * Closure to pass to @e cb @@ -1781,7 +1782,7 @@ domination_cb_helper (void *cls, */ static enum GNUNET_DB_QueryStatus postgres_iterate_denomination_info (void *cls, - TALER_EXCHANGEDB_DenominationInfoIterator cb, + TALER_EXCHANGEDB_DenominationCallback cb, void *cb_cls) { struct PostgresClosure *pc = cls; @@ -1813,9 +1814,9 @@ postgres_iterate_denomination_info (void *cls, * @return transaction status */ static enum GNUNET_DB_QueryStatus -postgres_reserve_get (void *cls, - struct TALER_EXCHANGEDB_Session *session, - struct TALER_EXCHANGEDB_Reserve *reserve) +postgres_reserves_get (void *cls, + struct TALER_EXCHANGEDB_Session *session, + struct TALER_EXCHANGEDB_Reserve *reserve) { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { @@ -1830,7 +1831,7 @@ postgres_reserve_get (void *cls, }; return GNUNET_PQ_eval_prepared_singleton_select (session->conn, - "reserve_get", + "reserves_get", params, rs); } @@ -1897,9 +1898,9 @@ postgres_reserves_in_insert (void *cls, struct GNUNET_TIME_Absolute expiry; reserve.pub = *reserve_pub; - reserve_exists = postgres_reserve_get (cls, - session, - &reserve); + reserve_exists = postgres_reserves_get (cls, + session, + &reserve); if (0 > reserve_exists) { GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == reserve_exists); @@ -2141,9 +2142,9 @@ postgres_insert_withdraw_info (void *cls, /* update reserve balance */ reserve.pub = collectable->reserve_pub; if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - (qs = postgres_reserve_get (cls, - session, - &reserve))) + (qs = postgres_reserves_get (cls, + session, + &reserve))) { /* Should have been checked before we got here... */ GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); @@ -4664,7 +4665,8 @@ postgres_wire_lookup_deposit_wtid (void *cls, TALER_CoinSpendPublicKeyP *coin_pub, const struct TALER_MerchantPublicKeyP *merchant_pub, - TALER_EXCHANGEDB_TrackTransactionCallback cb, + TALER_EXCHANGEDB_WireTransferByCoinCallback + cb, void *cb_cls) { struct PostgresClosure *pg = cls; @@ -5086,9 +5088,9 @@ postgres_insert_reserve_closed (void *cls, /* update reserve balance */ reserve.pub = *reserve_pub; if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - (qs = postgres_reserve_get (cls, - session, - &reserve))) + (qs = postgres_reserves_get (cls, + session, + &reserve))) { /* Existence should have been checked before we got here... */ GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); @@ -5658,13 +5660,13 @@ refreshs_serial_helper_cb (void *cls, * @return transaction status code */ static enum GNUNET_DB_QueryStatus -postgres_select_refreshs_above_serial_id (void *cls, - struct TALER_EXCHANGEDB_Session * - session, - uint64_t serial_id, - TALER_EXCHANGEDB_RefreshesCallback - cb, - void *cb_cls) +postgres_select_refreshes_above_serial_id (void *cls, + struct TALER_EXCHANGEDB_Session * + session, + uint64_t serial_id, + TALER_EXCHANGEDB_RefreshesCallback + cb, + void *cb_cls) { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { @@ -6120,13 +6122,13 @@ reserves_out_serial_helper_cb (void *cls, * @return transaction status code */ static enum GNUNET_DB_QueryStatus -postgres_select_reserves_out_above_serial_id (void *cls, - struct TALER_EXCHANGEDB_Session * - session, - uint64_t serial_id, - TALER_EXCHANGEDB_WithdrawCallback - cb, - void *cb_cls) +postgres_select_withdrawals_above_serial_id (void *cls, + struct TALER_EXCHANGEDB_Session * + session, + uint64_t serial_id, + TALER_EXCHANGEDB_WithdrawCallback + cb, + void *cb_cls) { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { @@ -6830,9 +6832,9 @@ postgres_insert_recoup_request (void *cls, /* Update reserve balance */ reserve.pub = *reserve_pub; - qs = postgres_reserve_get (cls, - session, - &reserve); + qs = postgres_reserves_get (cls, + session, + &reserve); if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) { GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); @@ -7281,7 +7283,7 @@ libtaler_plugin_exchangedb_postgres_init (void *cls) plugin->insert_denomination_info = &postgres_insert_denomination_info; plugin->get_denomination_info = &postgres_get_denomination_info; plugin->iterate_denomination_info = &postgres_iterate_denomination_info; - plugin->reserve_get = &postgres_reserve_get; + plugin->reserves_get = &postgres_reserves_get; plugin->reserves_in_insert = &postgres_reserves_in_insert; plugin->get_latest_reserve_in_reference = &postgres_get_latest_reserve_in_reference; @@ -7326,16 +7328,16 @@ libtaler_plugin_exchangedb_postgres_init (void *cls) plugin->gc = &postgres_gc; plugin->select_deposits_above_serial_id = &postgres_select_deposits_above_serial_id; - plugin->select_refreshs_above_serial_id - = &postgres_select_refreshs_above_serial_id; + plugin->select_refreshes_above_serial_id + = &postgres_select_refreshes_above_serial_id; plugin->select_refunds_above_serial_id = &postgres_select_refunds_above_serial_id; plugin->select_reserves_in_above_serial_id = &postgres_select_reserves_in_above_serial_id; plugin->select_reserves_in_above_serial_id_by_account = &postgres_select_reserves_in_above_serial_id_by_account; - plugin->select_reserves_out_above_serial_id - = &postgres_select_reserves_out_above_serial_id; + plugin->select_withdrawals_above_serial_id + = &postgres_select_withdrawals_above_serial_id; plugin->select_wire_out_above_serial_id = &postgres_select_wire_out_above_serial_id; plugin->select_wire_out_above_serial_id_by_account diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c index 26955d0f0..92a3c1b02 100644 --- a/src/exchangedb/test_exchangedb.c +++ b/src/exchangedb/test_exchangedb.c @@ -163,9 +163,9 @@ check_reserve (struct TALER_EXCHANGEDB_Session *session, reserve.pub = *pub; FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - plugin->reserve_get (plugin->cls, - session, - &reserve)); + plugin->reserves_get (plugin->cls, + session, + &reserve)); FAILIF (value != reserve.balance.value); FAILIF (fraction != reserve.balance.fraction); FAILIF (0 != strcmp (currency, reserve.balance.currency)); @@ -572,14 +572,14 @@ test_melting (struct TALER_EXCHANGEDB_Session *session) GNUNET_memcmp (&refresh_session.coin.denom_pub_hash, &ret_refresh_session.session.coin.denom_pub_hash)); - /* test 'select_refreshs_above_serial_id' */ + /* test 'select_refreshes_above_serial_id' */ auditor_row_cnt = 0; FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - plugin->select_refreshs_above_serial_id (plugin->cls, - session, - 0, - &audit_refresh_session_cb, - NULL)); + plugin->select_refreshes_above_serial_id (plugin->cls, + session, + 0, + &audit_refresh_session_cb, + NULL)); FAILIF (1 != auditor_row_cnt); new_dkp = GNUNET_new_array (MELT_NEW_COINS, @@ -1776,11 +1776,11 @@ run (void *cls) &audit_reserve_in_cb, NULL)); FAILIF (0 >= - plugin->select_reserves_out_above_serial_id (plugin->cls, - session, - 0, - &audit_reserve_out_cb, - NULL)); + plugin->select_withdrawals_above_serial_id (plugin->cls, + session, + 0, + &audit_reserve_out_cb, + NULL)); FAILIF (3 != auditor_row_cnt); /* Tests for deposits */ diff --git a/src/include/taler_exchangedb_plugin.h b/src/include/taler_exchangedb_plugin.h index 15be4a303..bb07d476d 100644 --- a/src/include/taler_exchangedb_plugin.h +++ b/src/include/taler_exchangedb_plugin.h @@ -379,7 +379,7 @@ struct TALER_EXCHANGEDB_RecoupRefreshListEntry struct TALER_CoinSpendSignatureP coin_sig; /** - * Public key of the old coin that the refresh'ed coin was paid back to. + * Public key of the old coin that the refreshed coin was paid back to. */ struct TALER_CoinSpendPublicKeyP old_coin_pub; @@ -1276,16 +1276,17 @@ typedef void * when we expect it to be done (if @a wtid was NULL) */ typedef void -(*TALER_EXCHANGEDB_TrackTransactionCallback)(void *cls, - const struct - TALER_WireTransferIdentifierRawP * - wtid, - const struct - TALER_Amount *coin_contribution, - const struct - TALER_Amount *coin_fee, - struct GNUNET_TIME_Absolute - execution_time); +(*TALER_EXCHANGEDB_WireTransferByCoinCallback)(void *cls, + const struct + TALER_WireTransferIdentifierRawP + * + wtid, + const struct + TALER_Amount *coin_contribution, + const struct + TALER_Amount *coin_fee, + struct GNUNET_TIME_Absolute + execution_time); /** @@ -1547,13 +1548,12 @@ typedef void * @param issue detailed information about the denomination (value, expiration times, fees) */ typedef void -(*TALER_EXCHANGEDB_DenominationInfoIterator)(void *cls, - const struct - TALER_DenominationPublicKey * - denom_pub, - const struct - TALER_EXCHANGEDB_DenominationKeyInformationP - *issue); +(*TALER_EXCHANGEDB_DenominationCallback)(void *cls, + const struct + TALER_DenominationPublicKey *denom_pub, + const struct + TALER_EXCHANGEDB_DenominationKeyInformationP + *issue); /** @@ -1575,7 +1575,7 @@ struct TALER_EXCHANGEDB_Plugin char *library_name; /** - * Get the thread-local database-handle. + * Get the thread-local (!) database-handle. * Connect to the db if the connection does not exist yet. * * @param cls the @e cls of this struct with the plugin-specific state @@ -1705,7 +1705,7 @@ struct TALER_EXCHANGEDB_Plugin */ enum GNUNET_DB_QueryStatus (*iterate_denomination_info)(void *cls, - TALER_EXCHANGEDB_DenominationInfoIterator cb, + TALER_EXCHANGEDB_DenominationCallback cb, void *cb_cls); /** @@ -1719,9 +1719,9 @@ struct TALER_EXCHANGEDB_Plugin * @return transaction status */ enum GNUNET_DB_QueryStatus - (*reserve_get)(void *cls, - struct TALER_EXCHANGEDB_Session *session, - struct TALER_EXCHANGEDB_Reserve *reserve); + (*reserves_get)(void *cls, + struct TALER_EXCHANGEDB_Session *session, + struct TALER_EXCHANGEDB_Reserve *reserve); /** @@ -1750,6 +1750,7 @@ struct TALER_EXCHANGEDB_Plugin /** * Obtain the most recent @a wire_reference that was inserted via @e reserves_in_insert. + * Used by the wirewatch process when resuming. * * @param cls the @e cls of this struct with the plugin-specific state * @param session the database connection handle @@ -1766,8 +1767,9 @@ struct TALER_EXCHANGEDB_Plugin /** - * Locate the response for a /withdraw request under the - * key of the hash of the blinded message. + * Locate the response for a withdraw request under the + * key of the hash of the blinded message. Used to ensure + * idempotency of the request. * * @param cls the @e cls of this struct with the plugin-specific state * @param session database connection to use @@ -1785,8 +1787,8 @@ struct TALER_EXCHANGEDB_Plugin /** - * Store collectable bit coin under the corresponding - * hash of the blinded message. + * Store collectable coin under the corresponding hash of the blinded + * message. * * @param cls the @e cls of this struct with the plugin-specific state * @param session database connection to use @@ -1933,6 +1935,7 @@ struct TALER_EXCHANGEDB_Plugin struct TALER_EXCHANGEDB_Session *session, const struct TALER_EXCHANGEDB_Refund *refund); + /** * Select refunds by @a coin_pub, @a merchant_pub and @a h_contract. * @@ -1956,9 +1959,9 @@ struct TALER_EXCHANGEDB_Plugin /** - * Mark a deposit as tiny, thereby declaring that it cannot be - * executed by itself and should no longer be returned by - * @e iterate_ready_deposits() + * Mark a deposit as tiny, thereby declaring that it cannot be executed by + * itself (only included in a larger aggregation) and should no longer be + * returned by @e iterate_ready_deposits() * * @param cls the @e cls of this struct with the plugin-specific state * @param session connection to the database @@ -2037,7 +2040,6 @@ struct TALER_EXCHANGEDB_Plugin * "tiny" threshold beyond which we never trigger a wire transaction! */ #define TALER_EXCHANGEDB_MATCHING_DEPOSITS_LIMIT 10000 -#define TALER_EXCHANGEDB_MATCHING_DEPOSITS_LIMIT_STR "10000" /** * Obtain information about other pending deposits for the same @@ -2067,7 +2069,7 @@ struct TALER_EXCHANGEDB_Plugin /** - * Store new refresh melt commitment data. + * Store new melt commitment data. * * @param cls the @e cls of this struct with the plugin-specific state * @param session database handle to use @@ -2081,7 +2083,7 @@ struct TALER_EXCHANGEDB_Plugin /** - * Lookup refresh melt commitment data under the given @a rc. + * Lookup melt commitment data under the given @a rc. * * @param cls the @e cls of this struct with the plugin-specific state * @param session database handle to use @@ -2256,7 +2258,7 @@ struct TALER_EXCHANGEDB_Plugin const struct TALER_CoinSpendPublicKeyP *coin_pub, const struct TALER_MerchantPublicKeyP *merchant_pub, - TALER_EXCHANGEDB_TrackTransactionCallback cb, + TALER_EXCHANGEDB_WireTransferByCoinCallback cb, void *cb_cls); @@ -2500,11 +2502,11 @@ struct TALER_EXCHANGEDB_Plugin * @return transaction status code */ enum GNUNET_DB_QueryStatus - (*select_refreshs_above_serial_id)(void *cls, - struct TALER_EXCHANGEDB_Session *session, - uint64_t serial_id, - TALER_EXCHANGEDB_RefreshesCallback cb, - void *cb_cls); + (*select_refreshes_above_serial_id)(void *cls, + struct TALER_EXCHANGEDB_Session *session, + uint64_t serial_id, + TALER_EXCHANGEDB_RefreshesCallback cb, + void *cb_cls); /** @@ -2580,12 +2582,12 @@ struct TALER_EXCHANGEDB_Plugin * @return transaction status code */ enum GNUNET_DB_QueryStatus - (*select_reserves_out_above_serial_id)(void *cls, - struct TALER_EXCHANGEDB_Session * - session, - uint64_t serial_id, - TALER_EXCHANGEDB_WithdrawCallback cb, - void *cb_cls); + (*select_withdrawals_above_serial_id)(void *cls, + struct TALER_EXCHANGEDB_Session * + session, + uint64_t serial_id, + TALER_EXCHANGEDB_WithdrawCallback cb, + void *cb_cls); /** * Function called to select outgoing wire transfers the exchange diff --git a/src/include/taler_util.h b/src/include/taler_util.h index 71000e8e9..cf44f0238 100644 --- a/src/include/taler_util.h +++ b/src/include/taler_util.h @@ -26,6 +26,22 @@ #include "taler_amount_lib.h" #include "taler_crypto_lib.h" +/** + * Stringify operator. + * + * @param a some expression to stringify. Must NOT be a macro. + * @return same expression as a constant string. + */ +#define TALER_S(a) #a + +/** + * Stringify operator. + * + * @param a some expression to stringify. Can be a macro. + * @return macro-expanded expression as a constant string. + */ +#define TALER_QUOTE(a) TALER_S (a) + /* Define logging functions */ #define TALER_LOG_DEBUG(...) \ |