get_global_fee.c (3545B)
1 /* 2 This file is part of TALER 3 Copyright (C) 2022 Taler Systems SA 4 5 TALER is free software; you can redistribute it and/or modify it under the 6 terms of the GNU General Public License as published by the Free Software 7 Foundation; either version 3, or (at your option) any later version. 8 9 TALER is distributed in the hope that it will be useful, but WITHOUT ANY 10 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 11 A PARTICULAR PURPOSE. See the GNU General Public License for more details. 12 13 You should have received a copy of the GNU General Public License along with 14 TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> 15 */ 16 /** 17 * @file exchangedb/get_global_fee.c 18 * @brief Implementation of the get_global_fee function for Postgres 19 * @author Christian Grothoff 20 */ 21 #include "taler/taler_error_codes.h" 22 #include "taler/taler_dbevents.h" 23 #include "taler/taler_pq_lib.h" 24 #include "exchange-database/get_global_fee.h" 25 #include "helper.h" 26 27 28 enum GNUNET_DB_QueryStatus 29 TALER_EXCHANGEDB_get_global_fee (struct TALER_EXCHANGEDB_PostgresContext *pg, 30 struct GNUNET_TIME_Timestamp date, 31 struct GNUNET_TIME_Timestamp *start_date, 32 struct GNUNET_TIME_Timestamp *end_date, 33 struct TALER_GlobalFeeSet *fees, 34 struct GNUNET_TIME_Relative *purse_timeout, 35 struct GNUNET_TIME_Relative *history_expiration 36 , 37 uint32_t *purse_account_limit, 38 struct TALER_MasterSignatureP *master_sig) 39 { 40 struct GNUNET_PQ_QueryParam params[] = { 41 GNUNET_PQ_query_param_timestamp (&date), 42 GNUNET_PQ_query_param_end 43 }; 44 struct GNUNET_PQ_ResultSpec rs[] = { 45 GNUNET_PQ_result_spec_timestamp ("start_date", 46 start_date), 47 GNUNET_PQ_result_spec_timestamp ("end_date", 48 end_date), 49 TALER_PQ_RESULT_SPEC_AMOUNT ("history_fee", 50 &fees->history), 51 TALER_PQ_RESULT_SPEC_AMOUNT ("account_fee", 52 &fees->account), 53 TALER_PQ_RESULT_SPEC_AMOUNT ("purse_fee", 54 &fees->purse), 55 GNUNET_PQ_result_spec_relative_time ("purse_timeout", 56 purse_timeout), 57 GNUNET_PQ_result_spec_relative_time ("history_expiration", 58 history_expiration), 59 GNUNET_PQ_result_spec_uint32 ("purse_account_limit", 60 purse_account_limit), 61 GNUNET_PQ_result_spec_auto_from_type ("master_sig", 62 master_sig), 63 GNUNET_PQ_result_spec_end 64 }; 65 66 PREPARE (pg, 67 "get_global_fee", 68 "SELECT " 69 " start_date" 70 ",end_date" 71 ",history_fee" 72 ",account_fee" 73 ",purse_fee" 74 ",purse_timeout" 75 ",history_expiration" 76 ",purse_account_limit" 77 ",master_sig" 78 " FROM global_fee" 79 " WHERE start_date <= $1" 80 " AND end_date > $1;"); 81 return GNUNET_PQ_eval_prepared_singleton_select (pg->conn, 82 "get_global_fee", 83 params, 84 rs); 85 }