merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

commit a118bd2c4951fa7b60737e3cca69e62266a1bcef
parent c7465ea592f0cd34d259e3f94227e3320f62208a
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sun, 28 Jun 2020 11:04:48 +0200

deduplicate logic

Diffstat:
Msrc/backenddb/plugin_merchantdb_postgres.c | 44+++++++++++++++-----------------------------
1 file changed, 15 insertions(+), 29 deletions(-)

diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c @@ -1449,36 +1449,22 @@ postgres_lookup_contract_terms (void *cls, GNUNET_PQ_query_param_string (order_id), GNUNET_PQ_query_param_end }; - check_connection (pg); - if (NULL == contract_terms) - { - struct GNUNET_PQ_ResultSpec rs[] = { - GNUNET_PQ_result_spec_uint64 ("order_serial", - order_serial), - GNUNET_PQ_result_spec_end - }; - - return GNUNET_PQ_eval_prepared_singleton_select (pg->conn, - "lookup_contract_terms", - params, - rs); - } - else - { - struct GNUNET_PQ_ResultSpec rs[] = { - TALER_PQ_result_spec_json ("contract_terms", - contract_terms), - GNUNET_PQ_result_spec_uint64 ("order_serial", - order_serial), - GNUNET_PQ_result_spec_end - }; + struct GNUNET_PQ_ResultSpec rs[] = { + /* contract_terms must be first! */ + TALER_PQ_result_spec_json ("contract_terms", + contract_terms), + GNUNET_PQ_result_spec_uint64 ("order_serial", + order_serial), + GNUNET_PQ_result_spec_end + }; - *contract_terms = NULL; - return GNUNET_PQ_eval_prepared_singleton_select (pg->conn, - "lookup_contract_terms", - params, - rs); - } + check_connection (pg); + return GNUNET_PQ_eval_prepared_singleton_select (pg->conn, + "lookup_contract_terms", + params, + (NULL != contract_terms) + ? rs + : &rs[1]); }