diff options
author | Cedric Zwahlen <cedric.zwahlen@students.bfh.ch> | 2024-04-07 15:27:50 +0200 |
---|---|---|
committer | Cedric Zwahlen <cedric.zwahlen@students.bfh.ch> | 2024-04-19 20:47:31 +0200 |
commit | 99a2d0029ee19a164ae9a22036220cd4e91a9268 (patch) | |
tree | 907c48c1e7aec0544e9b5519d84e632c8561c0f9 | |
parent | 36fddaa1e9c4741a742b086d3c7ff660e486e23a (diff) | |
download | exchange-99a2d0029ee19a164ae9a22036220cd4e91a9268.tar.gz exchange-99a2d0029ee19a164ae9a22036220cd4e91a9268.tar.bz2 exchange-99a2d0029ee19a164ae9a22036220cd4e91a9268.zip |
Fix and Improve CRUD files
10 files changed, 33 insertions, 30 deletions
diff --git a/src/auditor/taler-auditor-httpd.c b/src/auditor/taler-auditor-httpd.c index a7315094d..774cb2a8b 100644 --- a/src/auditor/taler-auditor-httpd.c +++ b/src/auditor/taler-auditor-httpd.c @@ -315,6 +315,22 @@ handle_mhd_request (void *cls, NULL, 0, &TAH_ROW_INCONSISTENCY_handler_delete, MHD_HTTP_OK }, + { "/reserve-balance-insufficient-inconsistency", MHD_HTTP_METHOD_GET, + "application/json", + NULL, 0, + &TAH_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_handler_get, + MHD_HTTP_OK }, + { "/reserve-balance-insufficient-inconsistency", MHD_HTTP_METHOD_PUT, + "application/json", + NULL, 0, + &TAH_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_handler_put, + MHD_HTTP_OK }, + { "/reserve-balance-insufficient-inconsistency", MHD_HTTP_METHOD_DELETE, + "application/json", + NULL, 0, + &TAH_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_handler_delete, + MHD_HTTP_OK }, + { "/config", MHD_HTTP_METHOD_GET, "application/json", NULL, 0, &handle_config, MHD_HTTP_OK }, diff --git a/src/auditor/taler-auditor-httpd_amount-arithmetic-inconsistency-get.c b/src/auditor/taler-auditor-httpd_amount-arithmetic-inconsistency-get.c index e61b4298d..ee9e709e3 100644 --- a/src/auditor/taler-auditor-httpd_amount-arithmetic-inconsistency-get.c +++ b/src/auditor/taler-auditor-httpd_amount-arithmetic-inconsistency-get.c @@ -32,7 +32,6 @@ add_amount_arithmetic_inconsistency (void *cls, json_t *list = cls; json_t *obj; - printf ("checkpoint pg_3\n"); obj = GNUNET_JSON_PACK ( @@ -46,7 +45,6 @@ add_amount_arithmetic_inconsistency (void *cls, json_array_append_new (list, obj)); - printf ("checkpoint pg_4\n"); return GNUNET_OK; } @@ -133,7 +131,6 @@ TAH_AMOUNT_ARITHMETIC_INCONSISTENCY_handler_get (struct TAH_RequestHandler *rh, } } - printf ("checkpoint httpd\n"); qs = TAH_plugin->get_amount_arithmetic_inconsistency ( TAH_plugin->cls, diff --git a/src/auditor/taler-auditor-httpd_reserve-balance-insufficient-inconsistency-del.c b/src/auditor/taler-auditor-httpd_reserve-balance-insufficient-inconsistency-del.c index 1f018cac9..f9fcd5e11 100644 --- a/src/auditor/taler-auditor-httpd_reserve-balance-insufficient-inconsistency-del.c +++ b/src/auditor/taler-auditor-httpd_reserve-balance-insufficient-inconsistency-del.c @@ -65,7 +65,7 @@ TAH_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_handler_delete (struct TAH_plugin->cls, row_id); - if (0 > qs) + if (0 == qs) { // goes in here if there was an error with the transaction GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); @@ -86,5 +86,4 @@ TAH_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_handler_delete (struct GNUNET_JSON_pack_string ("status", "RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_OK")); - return res; } diff --git a/src/auditor/taler-auditor-httpd_reserve-balance-insufficient-inconsistency-get.c b/src/auditor/taler-auditor-httpd_reserve-balance-insufficient-inconsistency-get.c index 40ec4c9fe..799d47a87 100644 --- a/src/auditor/taler-auditor-httpd_reserve-balance-insufficient-inconsistency-get.c +++ b/src/auditor/taler-auditor-httpd_reserve-balance-insufficient-inconsistency-get.c @@ -51,7 +51,7 @@ process_reserve_balance_insufficient_inconsistency (void *cls, // GNUNET_JSON_pack_... ("", &dc->), // TALER_JSON_pack_... ("", &dc->), - + GNUNET_JSON_pack_uint64 ("row_id", serial_id), GNUNET_JSON_pack_data_auto ("reserve_pub", &dc->reserve_pub), GNUNET_JSON_pack_bool ("inconsistency_gain", dc->inconsistency_gain), TALER_JSON_pack_amount ("inconsistency_amount", &dc->inconsistency_amount) diff --git a/src/auditor/taler-auditor-httpd_reserve-balance-insufficient-inconsistency-put.c b/src/auditor/taler-auditor-httpd_reserve-balance-insufficient-inconsistency-put.c index 47d664b1a..139753658 100644 --- a/src/auditor/taler-auditor-httpd_reserve-balance-insufficient-inconsistency-put.c +++ b/src/auditor/taler-auditor-httpd_reserve-balance-insufficient-inconsistency-put.c @@ -75,7 +75,7 @@ process_inconsistency ( MHD_RESULT -TAH_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_PUT_handler ( +TAH_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_handler_put ( struct TAH_RequestHandler *rh, struct MHD_Connection *connection, void **connection_cls, diff --git a/src/auditor/taler-auditor-httpd_reserve-balance-insufficient-inconsistency-put.h b/src/auditor/taler-auditor-httpd_reserve-balance-insufficient-inconsistency-put.h index b633a1cd0..eeead65d9 100644 --- a/src/auditor/taler-auditor-httpd_reserve-balance-insufficient-inconsistency-put.h +++ b/src/auditor/taler-auditor-httpd_reserve-balance-insufficient-inconsistency-put.h @@ -15,8 +15,8 @@ */ -#ifndef SRC_TALER_AUDITOR_HTTPD_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_GET_H -#define SRC_TALER_AUDITOR_HTTPD_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_GET_H +#ifndef SRC_TALER_AUDITOR_HTTPD_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_PUT_H +#define SRC_TALER_AUDITOR_HTTPD_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_PUT_H #include <gnunet/gnunet_util_lib.h> #include <microhttpd.h> @@ -26,13 +26,13 @@ * Initialize subsystem. */ void -TEAH_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_GET_init (void); +TEAH_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_PUT_init (void); /** * Shut down subsystem. */ void -TEAH_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_GET_done (void); +TEAH_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_PUT_done (void); /** * Handle a "/reserve-balance-insufficient-inconsistency" request. @@ -45,7 +45,7 @@ TEAH_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_GET_done (void); * @return MHD result code */ MHD_RESULT -TAH_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_handler_get (struct +TAH_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_handler_put (struct TAH_RequestHandler * rh, struct @@ -61,4 +61,4 @@ TAH_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_handler_get (struct args[]); -#endif // SRC_TALER_AUDITOR_HTTPD_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_GET_H +#endif // SRC_TALER_AUDITOR_HTTPD_RESERVE_BALANCE_INSUFFICIENT_INCONSISTENCY_PUT_H diff --git a/src/auditor/taler-auditor-httpd_row-inconsistency-put.c b/src/auditor/taler-auditor-httpd_row-inconsistency-put.c index 87f7f1ee9..b8544eb90 100644 --- a/src/auditor/taler-auditor-httpd_row-inconsistency-put.c +++ b/src/auditor/taler-auditor-httpd_row-inconsistency-put.c @@ -11,7 +11,7 @@ #include "taler_json_lib.h" #include "taler_mhd_lib.h" #include "taler-auditor-httpd.h" -#include "taler-auditor-httpd_coin-inconsistency-put.h" +#include "taler-auditor-httpd_row-inconsistency-put.h" /** diff --git a/src/auditordb/0002-auditor_reserve_balance_insufficient_inconsistency.sql b/src/auditordb/0002-auditor_reserve_balance_insufficient_inconsistency.sql index bbc0c8118..7b9900442 100644 --- a/src/auditordb/0002-auditor_reserve_balance_insufficient_inconsistency.sql +++ b/src/auditordb/0002-auditor_reserve_balance_insufficient_inconsistency.sql @@ -18,7 +18,7 @@ SET search_path TO auditor; CREATE TABLE IF NOT EXISTS auditor_reserve_balance_insufficient_inconsistency
(
row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE PRIMARY KEY,
- reserve_pub BYTEA,
+ reserve_pub BYTEA NOT NULL CHECK (LENGTH(reserve_pub)=32),
inconsistency_gain BOOLEAN,
inconsistency_amount taler_amount
);
diff --git a/src/auditordb/pg_get_amount_arithmetic_inconsistency.c b/src/auditordb/pg_get_amount_arithmetic_inconsistency.c index 6d01a3eb0..c768f43ac 100644 --- a/src/auditordb/pg_get_amount_arithmetic_inconsistency.c +++ b/src/auditordb/pg_get_amount_arithmetic_inconsistency.c @@ -89,8 +89,6 @@ amount_arithmetic_inconsistency_cb (void *cls, dcc->qs = i + 1; - printf ("checkpoint pg_2\n"); - rval = dcc->cb (dcc->cb_cls, serial_id, &dc); @@ -109,7 +107,7 @@ TAH_PG_get_amount_arithmetic_inconsistency ( TALER_AUDITORDB_AmountArithmeticInconsistencyCallback cb, void *cb_cls) { - printf ("checkpoint pg_0\n"); + struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { @@ -124,8 +122,6 @@ TAH_PG_get_amount_arithmetic_inconsistency ( }; enum GNUNET_DB_QueryStatus qs; - printf ("checkpoint pg_1\n"); - PREPARE (pg, "auditor_amount_arithmetic_inconsistency_select", "SELECT" @@ -143,7 +139,6 @@ TAH_PG_get_amount_arithmetic_inconsistency ( &amount_arithmetic_inconsistency_cb, &dcc); - printf ("checkpoint pg_5\n"); if (qs > 0) return dcc.qs; diff --git a/src/auditordb/pg_get_reserve_balance_insufficient_inconsistency.c b/src/auditordb/pg_get_reserve_balance_insufficient_inconsistency.c index 688b855d3..250af182d 100644 --- a/src/auditordb/pg_get_reserve_balance_insufficient_inconsistency.c +++ b/src/auditordb/pg_get_reserve_balance_insufficient_inconsistency.c @@ -67,8 +67,7 @@ reserve_balance_insufficient_inconsistency_cb (void *cls, GNUNET_PQ_result_spec_uint64 ("row_id", &serial_id), GNUNET_PQ_result_spec_auto_from_type ("reserve_pub", &dc.reserve_pub), - GNUNET_PQ_result_spec_bool ("inconsistency_gain", - &dc.inconsistency_gain), + GNUNET_PQ_result_spec_bool ("inconsistency_gain", &dc.inconsistency_gain), TALER_PQ_RESULT_SPEC_AMOUNT ("inconsistency_amount", &dc.inconsistency_amount), @@ -110,7 +109,7 @@ TAH_PG_get_reserve_balance_insufficient_inconsistency ( struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_uint64 (&start_id), - GNUNET_PQ_query_param_bool (return_suppressed), + // GNUNET_PQ_query_param_bool (return_suppressed), GNUNET_PQ_query_param_end }; struct ReserveBalanceInsufficientInconsistencyContext dcc = { @@ -124,12 +123,9 @@ TAH_PG_get_reserve_balance_insufficient_inconsistency ( "auditor_reserve_balance_insufficient_inconsistency_get", "SELECT" " row_id" - ",denompub_h" - ",denom_risk" - ",denom_loss" - ",deposit_start" - ",deposit_end" - ",value" + ",reserve_pub" + ",inconsistency_gain" + ",inconsistency_amount" " FROM auditor_reserve_balance_insufficient_inconsistency" " WHERE row_id>$1" ); |