diff options
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/taler-merchant-httpd_exchanges.c | 7 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_proposal.c | 23 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_track-transfer.c | 68 |
3 files changed, 60 insertions, 38 deletions
diff --git a/src/backend/taler-merchant-httpd_exchanges.c b/src/backend/taler-merchant-httpd_exchanges.c index f8e67054..3883d57f 100644 --- a/src/backend/taler-merchant-httpd_exchanges.c +++ b/src/backend/taler-merchant-httpd_exchanges.c @@ -937,9 +937,16 @@ TMH_EXCHANGES_done () exchange); while (NULL != (f = exchange->wire_fees_head)) { + struct TALER_EXCHANGE_WireAggregateFees *af; + GNUNET_CONTAINER_DLL_remove (exchange->wire_fees_head, exchange->wire_fees_tail, f); + while (NULL != (af = f->af)) + { + f->af = af->next; + GNUNET_free (af); + } GNUNET_free (f->wire_method); GNUNET_free (f); } diff --git a/src/backend/taler-merchant-httpd_proposal.c b/src/backend/taler-merchant-httpd_proposal.c index 85a43c0a..7a1cabbb 100644 --- a/src/backend/taler-merchant-httpd_proposal.c +++ b/src/backend/taler-merchant-httpd_proposal.c @@ -160,7 +160,8 @@ proposal_put (struct MHD_Connection *connection, /* Add order_id if it doesn't exist. */ - if (NULL == json_string_value (json_object_get (order, "order_id"))) + if (NULL == json_string_value (json_object_get (order, + "order_id"))) { char buf[256]; time_t timer; @@ -183,7 +184,8 @@ proposal_put (struct MHD_Connection *connection, json_string (buf)); } - if (NULL == json_object_get (order, "timestamp")) + if (NULL == json_object_get (order, + "timestamp")) { struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); @@ -233,7 +235,9 @@ proposal_put (struct MHD_Connection *connection, } /* extract fields we need to sign separately */ - res = TMH_PARSE_json_data (connection, order, spec); + res = TMH_PARSE_json_data (connection, + order, + spec); if (GNUNET_NO == res) { return MHD_YES; @@ -245,7 +249,6 @@ proposal_put (struct MHD_Connection *connection, "Impossible to parse the order"); } - /* check contract is well-formed */ if (GNUNET_OK != check_products (products)) { @@ -260,6 +263,7 @@ proposal_put (struct MHD_Connection *connection, { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Not able to find the specified instance\n"); + GNUNET_JSON_parse_free (spec); return TMH_RESPONSE_reply_not_found (connection, TALER_EC_CONTRACT_INSTANCE_UNKNOWN, "Unknown instance given"); @@ -343,6 +347,8 @@ MH_handler_proposal_put (struct TMH_RequestHandler *rh, { int res; struct TMH_JsonParseContext *ctx; + json_t *root; + json_t *order; if (NULL == *connection_cls) { @@ -355,8 +361,6 @@ MH_handler_proposal_put (struct TMH_RequestHandler *rh, ctx = *connection_cls; } - json_t *root; - res = TMH_PARSE_post_json (connection, &ctx->json_parse_context, upload_data, @@ -368,8 +372,8 @@ MH_handler_proposal_put (struct TMH_RequestHandler *rh, if ((GNUNET_NO == res) || (NULL == root)) return MHD_YES; - json_t *order = json_object_get (root, "order"); - + order = json_object_get (root, + "order"); if (NULL == order) { res = TMH_RESPONSE_reply_arg_missing (connection, @@ -378,7 +382,8 @@ MH_handler_proposal_put (struct TMH_RequestHandler *rh, } else { - res = proposal_put (connection, order); + res = proposal_put (connection, + order); } json_decref (root); return res; diff --git a/src/backend/taler-merchant-httpd_track-transfer.c b/src/backend/taler-merchant-httpd_track-transfer.c index 168fdcb0..a0dadabe 100644 --- a/src/backend/taler-merchant-httpd_track-transfer.c +++ b/src/backend/taler-merchant-httpd_track-transfer.c @@ -108,6 +108,11 @@ struct TrackTransferContext const json_t *original_response; /** + * Modified response to return to the frontend. + */ + json_t *deposits_response; + + /** * Which transaction detail are we currently looking at? */ unsigned int current_offset; @@ -130,6 +135,7 @@ struct TrackTransferContext * individual deposits for each h_contract_terms. */ struct Entry { + /** * Sum accumulator for deposited value. */ @@ -140,12 +146,8 @@ struct Entry { */ struct TALER_Amount deposit_fee; - }; +}; -/** - * Modified response to return to the frontend. - */ -static json_t *deposits_response; /** * Free the @a rctx. @@ -184,8 +186,8 @@ free_transfer_track_context (struct TrackTransferContext *rctx) * @param cls closure, NULL * @param key current key * @param value a `struct MerchantInstance` - * @return GNUNET_YES if the iteration should continue, - * GNUNET_NO otherwise. + * @return #GNUNET_YES if the iteration should continue, + * #GNUNET_NO otherwise. */ static int hashmap_free (void *cls, @@ -206,10 +208,10 @@ hashmap_free (void *cls, * @param cls closure * @param key map's current key * @param map's current value - * @return GNUNET_YES if iteration is to be continued, - * GNUNET_NO otherwise. + * @return #GNUNET_YES if iteration is to be continued, + * #GNUNET_NO otherwise. */ -int +static int build_deposits_response (void *cls, const struct GNUNET_HashCode *key, void *value) @@ -220,31 +222,35 @@ build_deposits_response (void *cls, json_t *contract_terms; json_t *order_id; - if (GNUNET_OK != db->find_contract_terms_from_hash (db->cls, - &contract_terms, - key, - &rctx->mi->pubkey)) + if (GNUNET_OK != + db->find_contract_terms_from_hash (db->cls, + &contract_terms, + key, + &rctx->mi->pubkey)) { GNUNET_break_op (0); return GNUNET_NO; } - order_id = json_object_get (contract_terms, "order_id"); + order_id = json_object_get (contract_terms, + "order_id"); if (NULL == order_id) { GNUNET_break_op (0); + json_decref (contract_terms); return GNUNET_NO; } - element = json_pack ("{s:s, s:o, s:o}", - "order_id", json_string_value (order_id), + element = json_pack ("{s:O, s:o, s:o}", + "order_id", order_id, "deposit_value", TALER_JSON_from_amount (&entry->deposit_value), "deposit_fee", TALER_JSON_from_amount (&entry->deposit_fee)); + json_decref (contract_terms); if (NULL == element) { GNUNET_break_op (0); return GNUNET_NO; } - json_array_append_new (deposits_response, + json_array_append_new (rctx->deposits_response, element); return GNUNET_YES; } @@ -302,12 +308,14 @@ transform_response (const json_t *result, &h_key))) { /* The map already knows this h_contract_terms*/ - if ((GNUNET_SYSERR == TALER_amount_add (¤t_entry->deposit_value, - ¤t_entry->deposit_value, - &iter_value)) || - (GNUNET_SYSERR == TALER_amount_add (¤t_entry->deposit_fee, - ¤t_entry->deposit_fee, - &iter_fee))) + if ( (GNUNET_SYSERR == + TALER_amount_add (¤t_entry->deposit_value, + ¤t_entry->deposit_value, + &iter_value)) || + (GNUNET_SYSERR == + TALER_amount_add (¤t_entry->deposit_fee, + ¤t_entry->deposit_fee, + &iter_fee)) ) { GNUNET_JSON_parse_free (spec); goto cleanup; @@ -332,11 +340,12 @@ transform_response (const json_t *result, } GNUNET_JSON_parse_free (spec); } - deposits_response = json_array (); + rctx->deposits_response = json_array (); - if (GNUNET_SYSERR == GNUNET_CONTAINER_multihashmap_iterate (map, - build_deposits_response, - rctx)) + if (GNUNET_SYSERR == + GNUNET_CONTAINER_multihashmap_iterate (map, + &build_deposits_response, + rctx)) goto cleanup; result_mod = json_copy ((struct json_t *) result); @@ -344,7 +353,8 @@ transform_response (const json_t *result, "deposits"); json_object_set_new (result_mod, "deposits_sums", - deposits_response); + rctx->deposits_response); + rctx->deposits_response = NULL; cleanup: GNUNET_CONTAINER_multihashmap_iterate (map, &hashmap_free, |