diff options
Diffstat (limited to 'src/exchangedb')
-rw-r--r-- | src/exchangedb/Makefile.am | 3 | ||||
-rw-r--r-- | src/exchangedb/exchangedb_plugin.c | 2 | ||||
-rw-r--r-- | src/exchangedb/pg_batch_ensure_coin_known.c | 93 | ||||
-rw-r--r-- | src/exchangedb/pg_begin_revolving_shard.c | 16 | ||||
-rw-r--r-- | src/exchangedb/pg_begin_shard.c | 14 | ||||
-rw-r--r-- | src/exchangedb/pg_inject_auditor_triggers.c | 1 | ||||
-rw-r--r-- | src/exchangedb/pg_iterate_reserve_close_info.c | 2 | ||||
-rw-r--r-- | src/exchangedb/pg_lookup_completed_legitimization.c | 4 | ||||
-rw-r--r-- | src/exchangedb/pg_preflight.c | 11 | ||||
-rw-r--r-- | src/exchangedb/pg_reserves_in_insert.c | 16 | ||||
-rw-r--r-- | src/exchangedb/pg_select_reserve_closed_above_serial_id.c | 2 | ||||
-rw-r--r-- | src/exchangedb/plugin_exchangedb_postgres.c | 5 |
12 files changed, 78 insertions, 91 deletions
diff --git a/src/exchangedb/Makefile.am b/src/exchangedb/Makefile.am index d51768f46..e25e09c78 100644 --- a/src/exchangedb/Makefile.am +++ b/src/exchangedb/Makefile.am @@ -101,7 +101,8 @@ libtaler_plugin_exchangedb_postgres_la_SOURCES = \ plugin_exchangedb_common.c plugin_exchangedb_common.h \ pg_setup_wire_target.h pg_setup_wire_target.c \ pg_compute_shard.h pg_compute_shard.c \ - plugin_exchangedb_postgres.c pg_helper.h \ + plugin_exchangedb_postgres.c plugin_exchangedb_postgres.h \ + pg_helper.h \ pg_reserves_update.h pg_reserves_update.c \ pg_select_aggregation_amounts_for_kyc_check.h pg_select_aggregation_amounts_for_kyc_check.c \ pg_lookup_wire_fee_by_time.h pg_lookup_wire_fee_by_time.c \ diff --git a/src/exchangedb/exchangedb_plugin.c b/src/exchangedb/exchangedb_plugin.c index 5dc41d988..68a916b4e 100644 --- a/src/exchangedb/exchangedb_plugin.c +++ b/src/exchangedb/exchangedb_plugin.c @@ -20,7 +20,7 @@ * @author Sree Harsha Totakura <sreeharsha@totakura.in> */ #include "platform.h" -#include "taler_exchangedb_plugin.h" +#include "taler_exchangedb_lib.h" #include <ltdl.h> diff --git a/src/exchangedb/pg_batch_ensure_coin_known.c b/src/exchangedb/pg_batch_ensure_coin_known.c index aca2732c6..fdf3852b2 100644 --- a/src/exchangedb/pg_batch_ensure_coin_known.c +++ b/src/exchangedb/pg_batch_ensure_coin_known.c @@ -38,16 +38,6 @@ insert1 (struct PostgresClosure *pg, enum GNUNET_DB_QueryStatus qs; bool is_denom_pub_hash_null = false; bool is_age_hash_null = false; - PREPARE (pg, - "batch1_known_coin", - "SELECT" - " existed1 AS existed" - ",known_coin_id1 AS known_coin_id" - ",denom_pub_hash1 AS denom_hash" - ",age_commitment_hash1 AS h_age_commitment" - " FROM exchange_do_batch1_known_coin" - " ($1, $2, $3, $4);" - ); struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (&coin[0].coin_pub), GNUNET_PQ_query_param_auto_from_type (&coin[0].denom_pub_hash), @@ -71,6 +61,16 @@ insert1 (struct PostgresClosure *pg, GNUNET_PQ_result_spec_end }; + PREPARE (pg, + "batch1_known_coin", + "SELECT" + " existed1 AS existed" + ",known_coin_id1 AS known_coin_id" + ",denom_pub_hash1 AS denom_hash" + ",age_commitment_hash1 AS h_age_commitment" + " FROM exchange_do_batch1_known_coin" + " ($1, $2, $3, $4);" + ); qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn, "batch1_known_coin", params, @@ -140,21 +140,6 @@ insert2 (struct PostgresClosure *pg, enum GNUNET_DB_QueryStatus qs; bool is_denom_pub_hash_null[2] = {false, false}; bool is_age_hash_null[2] = {false, false}; - - PREPARE (pg, - "batch2_known_coin", - "SELECT" - " existed1 AS existed" - ",known_coin_id1 AS known_coin_id" - ",denom_pub_hash1 AS denom_hash" - ",age_commitment_hash1 AS h_age_commitment" - ",existed2 AS existed2" - ",known_coin_id2 AS known_coin_id2" - ",denom_pub_hash2 AS denom_hash2" - ",age_commitment_hash2 AS h_age_commitment2" - " FROM exchange_do_batch2_known_coin" - " ($1, $2, $3, $4, $5, $6, $7, $8);" - ); struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (&coin[0].coin_pub), GNUNET_PQ_query_param_auto_from_type (&coin[0].denom_pub_hash), @@ -195,6 +180,20 @@ insert2 (struct PostgresClosure *pg, GNUNET_PQ_result_spec_end }; + PREPARE (pg, + "batch2_known_coin", + "SELECT" + " existed1 AS existed" + ",known_coin_id1 AS known_coin_id" + ",denom_pub_hash1 AS denom_hash" + ",age_commitment_hash1 AS h_age_commitment" + ",existed2 AS existed2" + ",known_coin_id2 AS known_coin_id2" + ",denom_pub_hash2 AS denom_hash2" + ",age_commitment_hash2 AS h_age_commitment2" + " FROM exchange_do_batch2_known_coin" + " ($1, $2, $3, $4, $5, $6, $7, $8);" + ); qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn, "batch2_known_coin", params, @@ -259,28 +258,6 @@ insert4 (struct PostgresClosure *pg, enum GNUNET_DB_QueryStatus qs; bool is_denom_pub_hash_null[4] = {false, false, false, false}; bool is_age_hash_null[4] = {false, false, false, false}; - PREPARE (pg, - "batch4_known_coin", - "SELECT" - " existed1 AS existed" - ",known_coin_id1 AS known_coin_id" - ",denom_pub_hash1 AS denom_hash" - ",age_commitment_hash1 AS h_age_commitment" - ",existed2 AS existed2" - ",known_coin_id2 AS known_coin_id2" - ",denom_pub_hash2 AS denom_hash2" - ",age_commitment_hash2 AS h_age_commitment2" - ",existed3 AS existed3" - ",known_coin_id3 AS known_coin_id3" - ",denom_pub_hash3 AS denom_hash3" - ",age_commitment_hash3 AS h_age_commitment3" - ",existed4 AS existed4" - ",known_coin_id4 AS known_coin_id4" - ",denom_pub_hash4 AS denom_hash4" - ",age_commitment_hash4 AS h_age_commitment4" - " FROM exchange_do_batch2_known_coin" - " ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16);" - ); struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (&coin[0].coin_pub), GNUNET_PQ_query_param_auto_from_type (&coin[0].denom_pub_hash), @@ -355,6 +332,28 @@ insert4 (struct PostgresClosure *pg, GNUNET_PQ_result_spec_end }; + PREPARE (pg, + "batch4_known_coin", + "SELECT" + " existed1 AS existed" + ",known_coin_id1 AS known_coin_id" + ",denom_pub_hash1 AS denom_hash" + ",age_commitment_hash1 AS h_age_commitment" + ",existed2 AS existed2" + ",known_coin_id2 AS known_coin_id2" + ",denom_pub_hash2 AS denom_hash2" + ",age_commitment_hash2 AS h_age_commitment2" + ",existed3 AS existed3" + ",known_coin_id3 AS known_coin_id3" + ",denom_pub_hash3 AS denom_hash3" + ",age_commitment_hash3 AS h_age_commitment3" + ",existed4 AS existed4" + ",known_coin_id4 AS known_coin_id4" + ",denom_pub_hash4 AS denom_hash4" + ",age_commitment_hash4 AS h_age_commitment4" + " FROM exchange_do_batch2_known_coin" + " ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16);" + ); qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn, "batch4_known_coin", params, diff --git a/src/exchangedb/pg_begin_revolving_shard.c b/src/exchangedb/pg_begin_revolving_shard.c index 86cdf80fd..8d0b31a2d 100644 --- a/src/exchangedb/pg_begin_revolving_shard.c +++ b/src/exchangedb/pg_begin_revolving_shard.c @@ -164,7 +164,7 @@ TEH_PG_begin_revolving_shard (void *cls, end_row), GNUNET_PQ_result_spec_end }; - /* Used in #postgres_begin_revolving_shard() */ + PREPARE (pg, "get_open_revolving_shard", "SELECT" @@ -194,9 +194,9 @@ TEH_PG_begin_revolving_shard (void *cls, return qs; case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: { - enum GNUNET_DB_QueryStatus qs; + enum GNUNET_DB_QueryStatus qsz; struct GNUNET_TIME_Timestamp now; - struct GNUNET_PQ_QueryParam params[] = { + struct GNUNET_PQ_QueryParam iparams[] = { GNUNET_PQ_query_param_string (job_name), GNUNET_PQ_query_param_timestamp (&now), GNUNET_PQ_query_param_uint32 (start_row), @@ -205,8 +205,6 @@ TEH_PG_begin_revolving_shard (void *cls, }; now = GNUNET_TIME_timestamp_get (); - - /* Used in #postgres_begin_revolving_shard() */ PREPARE (pg, "reclaim_revolving_shard", "UPDATE revolving_work_shards" @@ -215,10 +213,10 @@ TEH_PG_begin_revolving_shard (void *cls, " WHERE job_name=$1" " AND start_row=$3" " AND end_row=$4"); - qs = GNUNET_PQ_eval_prepared_non_select (pg->conn, - "reclaim_revolving_shard", - params); - switch (qs) + qsz = GNUNET_PQ_eval_prepared_non_select (pg->conn, + "reclaim_revolving_shard", + iparams); + switch (qsz) { case GNUNET_DB_STATUS_HARD_ERROR: GNUNET_break (0); diff --git a/src/exchangedb/pg_begin_shard.c b/src/exchangedb/pg_begin_shard.c index 48e077990..214198534 100644 --- a/src/exchangedb/pg_begin_shard.c +++ b/src/exchangedb/pg_begin_shard.c @@ -94,9 +94,9 @@ TEH_PG_begin_shard (void *cls, continue; case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: { - enum GNUNET_DB_QueryStatus qs; + enum GNUNET_DB_QueryStatus qsz; struct GNUNET_TIME_Absolute now; - struct GNUNET_PQ_QueryParam params[] = { + struct GNUNET_PQ_QueryParam iparams[] = { GNUNET_PQ_query_param_string (job_name), GNUNET_PQ_query_param_absolute_time (&now), GNUNET_PQ_query_param_uint64 (start_row), @@ -112,15 +112,15 @@ TEH_PG_begin_shard (void *cls, " WHERE job_name=$1" " AND start_row=$3" " AND end_row=$4"); - qs = GNUNET_PQ_eval_prepared_non_select (pg->conn, - "reclaim_shard", - params); - switch (qs) + qsz = GNUNET_PQ_eval_prepared_non_select (pg->conn, + "reclaim_shard", + iparams); + switch (qsz) { case GNUNET_DB_STATUS_HARD_ERROR: GNUNET_break (0); TEH_PG_rollback (pg); - return qs; + return qsz; case GNUNET_DB_STATUS_SOFT_ERROR: GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Serialization error on claiming open shard\n"); diff --git a/src/exchangedb/pg_inject_auditor_triggers.c b/src/exchangedb/pg_inject_auditor_triggers.c index 562a1a22c..3b27908c9 100644 --- a/src/exchangedb/pg_inject_auditor_triggers.c +++ b/src/exchangedb/pg_inject_auditor_triggers.c @@ -24,6 +24,7 @@ #include "taler_pq_lib.h" #include "pg_gc.h" #include "pg_helper.h" +#include "pg_inject_auditor_triggers.h" /** diff --git a/src/exchangedb/pg_iterate_reserve_close_info.c b/src/exchangedb/pg_iterate_reserve_close_info.c index ff0a813c3..6b4e72d69 100644 --- a/src/exchangedb/pg_iterate_reserve_close_info.c +++ b/src/exchangedb/pg_iterate_reserve_close_info.c @@ -22,7 +22,7 @@ #include "taler_error_codes.h" #include "taler_dbevents.h" #include "taler_pq_lib.h" -#include "pg_insert_reserve_open_deposit.h" +#include "pg_iterate_reserve_close_info.h" #include "pg_helper.h" /** diff --git a/src/exchangedb/pg_lookup_completed_legitimization.c b/src/exchangedb/pg_lookup_completed_legitimization.c index 35647c847..3a500dc32 100644 --- a/src/exchangedb/pg_lookup_completed_legitimization.c +++ b/src/exchangedb/pg_lookup_completed_legitimization.c @@ -14,7 +14,7 @@ TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ /** - * @file exchangedb/pg_lookup_pending_legitimization.c + * @file exchangedb/pg_lookup_completed_legitimization.c * @brief Implementation of the lookup_pending_legitimization function for Postgres * @author Christian Grothoff */ @@ -22,7 +22,7 @@ #include "taler_error_codes.h" #include "taler_dbevents.h" #include "taler_pq_lib.h" -#include "pg_lookup_pending_legitimization.h" +#include "pg_lookup_completed_legitimization.h" #include "pg_helper.h" diff --git a/src/exchangedb/pg_preflight.c b/src/exchangedb/pg_preflight.c index 4533c9a97..c30a9651e 100644 --- a/src/exchangedb/pg_preflight.c +++ b/src/exchangedb/pg_preflight.c @@ -24,16 +24,7 @@ #include "taler_pq_lib.h" #include "pg_preflight.h" #include "pg_helper.h" - - -/** - * Connect to the database if the connection does not exist yet. - * - * @param pg the plugin-specific state - * @return #GNUNET_OK on success - */ -enum GNUNET_GenericReturnValue -TEH_PG_internal_setup (struct PostgresClosure *pg); +#include "plugin_exchangedb_postgres.h" enum GNUNET_GenericReturnValue diff --git a/src/exchangedb/pg_reserves_in_insert.c b/src/exchangedb/pg_reserves_in_insert.c index 21734942a..95e488771 100644 --- a/src/exchangedb/pg_reserves_in_insert.c +++ b/src/exchangedb/pg_reserves_in_insert.c @@ -327,18 +327,18 @@ TEH_PG_reserves_in_insert ( &duplicate), GNUNET_PQ_result_spec_end }; - enum GNUNET_DB_QueryStatus qs; + enum GNUNET_DB_QueryStatus qsi; - qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn, - "reserves_update", - params, - rs); - if (qs < 0) + qsi = GNUNET_PQ_eval_prepared_singleton_select (pg->conn, + "reserves_update", + params, + rs); + if (qsi < 0) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to update reserves (%d)\n", - qs); - results[i] = qs; + qsi); + results[i] = qsi; goto finished; } results[i] = duplicate diff --git a/src/exchangedb/pg_select_reserve_closed_above_serial_id.c b/src/exchangedb/pg_select_reserve_closed_above_serial_id.c index d24d6a600..9f239fe40 100644 --- a/src/exchangedb/pg_select_reserve_closed_above_serial_id.c +++ b/src/exchangedb/pg_select_reserve_closed_above_serial_id.c @@ -22,7 +22,7 @@ #include "taler_error_codes.h" #include "taler_dbevents.h" #include "taler_pq_lib.h" -#include "pg_get_reserve_history.h" +#include "pg_select_reserve_closed_above_serial_id.h" #include "plugin_exchangedb_common.h" #include "pg_helper.h" diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c index 8de6f4626..c13a7d193 100644 --- a/src/exchangedb/plugin_exchangedb_postgres.c +++ b/src/exchangedb/plugin_exchangedb_postgres.c @@ -225,13 +225,10 @@ #include "pg_test_aml_officer.h" #include "pg_lookup_aml_officer.h" #include "pg_trigger_aml_process.h" -// #include "pg_select_justification_for_missing_wire.h" #include "pg_lookup_kyc_requirement_by_row.h" -// #include "pg_select_aml_history.h" -// #include "pg_select_aml_process.h" -// #include "pg_select_aml_threshold.h" #include "pg_insert_aml_decision.h" #include "pg_batch_ensure_coin_known.h" +#include "plugin_exchangedb_postgres.h" /** * Set to 1 to enable Postgres auto_explain module. This will |