diff options
author | Cedric Zwahlen <cedric.zwahlen@students.bfh.ch> | 2024-03-27 00:33:16 +0100 |
---|---|---|
committer | Cedric Zwahlen <cedric.zwahlen@students.bfh.ch> | 2024-04-19 20:47:29 +0200 |
commit | 4435d40ff3baa24f01157de9e229cf2929e86dd0 (patch) | |
tree | 2bedd842a4bcaf4b25334108086699eb67474566 | |
parent | 39f0abf147f64298645b3d7830ca68c29d70d321 (diff) | |
download | exchange-4435d40ff3baa24f01157de9e229cf2929e86dd0.tar.gz exchange-4435d40ff3baa24f01157de9e229cf2929e86dd0.tar.bz2 exchange-4435d40ff3baa24f01157de9e229cf2929e86dd0.zip |
Improvements
4 files changed, 52 insertions, 12 deletions
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 c51ff2e2b..e61b4298d 100644 --- a/src/auditor/taler-auditor-httpd_amount-arithmetic-inconsistency-get.c +++ b/src/auditor/taler-auditor-httpd_amount-arithmetic-inconsistency-get.c @@ -35,8 +35,13 @@ add_amount_arithmetic_inconsistency (void *cls, printf ("checkpoint pg_3\n"); obj = GNUNET_JSON_PACK ( - GNUNET_JSON_pack_data_auto ("dc", - dc)); + + GNUNET_JSON_pack_data_auto ("operation", &dc->operation), + TALER_JSON_pack_amount ("exchange_amount", &dc->exchange_amount), + TALER_JSON_pack_amount ("auditor_amount", &dc->auditor_amount), + GNUNET_JSON_pack_bool ("profitable", dc->profitable) + + ); GNUNET_break (0 == json_array_append_new (list, obj)); diff --git a/src/auditor/taler-auditor-httpd_amount-arithmetic-inconsistency-put.c b/src/auditor/taler-auditor-httpd_amount-arithmetic-inconsistency-put.c index 2471b4d94..56c713847 100644 --- a/src/auditor/taler-auditor-httpd_amount-arithmetic-inconsistency-put.c +++ b/src/auditor/taler-auditor-httpd_amount-arithmetic-inconsistency-put.c @@ -31,6 +31,17 @@ process_inconsistency ( { enum GNUNET_DB_QueryStatus qs; + + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + /* execute transaction */ qs = TAH_plugin->insert_amount_arithmetic_inconsistency (TAH_plugin->cls, dc); @@ -67,7 +78,11 @@ TAH_AMOUNT_ARITHMETIC_INCONSISTENCY_PUT_handler ( struct GNUNET_JSON_Specification spec[] = { - + GNUNET_JSON_spec_fixed_auto ("operation", &dc.operation), + TALER_JSON_spec_amount ("exchange_amount", TAH_currency, + &dc.exchange_amount), + TALER_JSON_spec_amount ("auditor_amount", TAH_currency,&dc.auditor_amount), + GNUNET_JSON_spec_bool ("profitable", &dc.profitable), GNUNET_JSON_spec_end () }; diff --git a/src/auditor/taler-auditor-httpd_coin-inconsistency-get.c b/src/auditor/taler-auditor-httpd_coin-inconsistency-get.c index 54b123864..ca08f7d4c 100644 --- a/src/auditor/taler-auditor-httpd_coin-inconsistency-get.c +++ b/src/auditor/taler-auditor-httpd_coin-inconsistency-get.c @@ -34,8 +34,13 @@ add_coin_inconsistency (void *cls, printf ("checkpoint pg_3\n"); obj = GNUNET_JSON_PACK ( - GNUNET_JSON_pack_data_auto ("dc", - dc)); + GNUNET_JSON_pack_data_auto ("operation", &dc->operation), + TALER_JSON_pack_amount ("exchange_amount", &dc->exchange_amount), + TALER_JSON_pack_amount ("auditor_amount", &dc->auditor_amount), + GNUNET_JSON_pack_data_auto ("coin_pub",&dc->coin_pub), + GNUNET_JSON_pack_bool ("profitable", dc->profitable) + ); + GNUNET_break (0 == json_array_append_new (list, obj)); diff --git a/src/auditor/taler-auditor-httpd_coin-inconsistency-put.c b/src/auditor/taler-auditor-httpd_coin-inconsistency-put.c index a729ecafe..1535a3e42 100644 --- a/src/auditor/taler-auditor-httpd_coin-inconsistency-put.c +++ b/src/auditor/taler-auditor-httpd_coin-inconsistency-put.c @@ -33,6 +33,16 @@ process_inconsistency ( enum GNUNET_DB_QueryStatus qs; + if (GNUNET_SYSERR == + TAH_plugin->preflight (TAH_plugin->cls)) + { + GNUNET_break (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_SETUP_FAILED, + NULL); + } + /* execute transaction */ qs = TAH_plugin->insert_coin_inconsistency (TAH_plugin->cls, dc); @@ -40,16 +50,16 @@ process_inconsistency ( { GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); TALER_LOG_WARNING ( - "Failed to store /insert-amount-arithmetic in database\n"); + "Failed to store /insert-coin in database\n"); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, TALER_EC_GENERIC_DB_STORE_FAILED, - "insert amount arithmetic"); + "insert coin"); } return TALER_MHD_REPLY_JSON_PACK (connection, MHD_HTTP_OK, GNUNET_JSON_pack_string ("status", - "INSERT_AMOUNT_ARITHMETIC_OK")); + "INSERT_COIN_OK")); } @@ -63,16 +73,21 @@ TAH_COIN_INCONSISTENCY_PUT_handler ( const char *const args[]) { - struct TALER_AUDITORDB_CoinInconsistency dc = { - - }; - + struct TALER_AUDITORDB_CoinInconsistency dc; struct GNUNET_JSON_Specification spec[] = { + GNUNET_JSON_spec_fixed_auto ("operation", &dc.operation), + TALER_JSON_spec_amount ("exchange_amount", TAH_currency, + &dc.exchange_amount), + TALER_JSON_spec_amount ("auditor_amount", TAH_currency,&dc.auditor_amount), + GNUNET_JSON_spec_fixed_auto ("coin_pub", &dc.coin_pub), + GNUNET_JSON_spec_bool ("profitable", &dc.profitable), + GNUNET_JSON_spec_end () }; + // printf("currency:%s", TAH_currency); json_t *json; |