Line data Source code
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_wire_fee.c
18 : * @brief Implementation of the get_wire_fee function for Postgres
19 : * @author Christian Grothoff
20 : */
21 : #include "taler/taler_pq_lib.h"
22 : #include "exchange-database/get_wire_fee.h"
23 : #include "helper.h"
24 :
25 : enum GNUNET_DB_QueryStatus
26 107 : TALER_EXCHANGEDB_get_wire_fee (
27 : struct TALER_EXCHANGEDB_PostgresContext *pg,
28 : const char *type,
29 : struct GNUNET_TIME_Timestamp date,
30 : uint64_t *rowid,
31 : struct GNUNET_TIME_Timestamp *start_date,
32 : struct GNUNET_TIME_Timestamp *end_date,
33 : struct TALER_WireFeeSet *fees,
34 : struct TALER_MasterSignatureP *master_sig)
35 : {
36 107 : struct GNUNET_PQ_QueryParam params[] = {
37 107 : GNUNET_PQ_query_param_string (type),
38 107 : GNUNET_PQ_query_param_timestamp (&date),
39 : GNUNET_PQ_query_param_end
40 : };
41 107 : struct GNUNET_PQ_ResultSpec rs[] = {
42 107 : GNUNET_PQ_result_spec_uint64 ("wire_fee_serial",
43 : rowid),
44 107 : GNUNET_PQ_result_spec_timestamp ("start_date",
45 : start_date),
46 107 : GNUNET_PQ_result_spec_timestamp ("end_date",
47 : end_date),
48 107 : TALER_PQ_RESULT_SPEC_AMOUNT ("wire_fee",
49 : &fees->wire),
50 107 : TALER_PQ_RESULT_SPEC_AMOUNT ("closing_fee",
51 : &fees->closing),
52 107 : GNUNET_PQ_result_spec_auto_from_type ("master_sig",
53 : master_sig),
54 : GNUNET_PQ_result_spec_end
55 : };
56 :
57 107 : PREPARE (pg,
58 : "get_wire_fee",
59 : "SELECT"
60 : " wire_fee_serial"
61 : ",start_date"
62 : ",end_date"
63 : ",wire_fee"
64 : ",closing_fee"
65 : ",master_sig"
66 : " FROM wire_fee"
67 : " WHERE wire_method=$1"
68 : " AND start_date <= $2"
69 : " AND end_date > $2;");
70 107 : return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
71 : "get_wire_fee",
72 : params,
73 : rs);
74 : }
|