Line data Source code
1 : /*
2 : This file is part of TALER
3 : Copyright (C) 2024 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 : #include "taler/taler_pq_lib.h"
17 : #include "pg_helper.h"
18 : #include "auditor-database/insert_purse_not_closed_inconsistencies.h"
19 :
20 :
21 : enum GNUNET_DB_QueryStatus
22 3 : TALER_AUDITORDB_insert_purse_not_closed_inconsistencies (
23 : struct TALER_AUDITORDB_PostgresContext *ctx,
24 : const struct TALER_AUDITORDB_PurseNotClosedInconsistencies *dc)
25 : {
26 3 : struct GNUNET_PQ_QueryParam params[] = {
27 3 : GNUNET_PQ_query_param_auto_from_type (&dc->purse_pub),
28 3 : TALER_PQ_query_param_amount (ctx->conn,
29 : &dc->amount),
30 3 : GNUNET_PQ_query_param_absolute_time (&dc->expiration_date),
31 : GNUNET_PQ_query_param_end
32 : };
33 :
34 3 : PREPARE (ctx,
35 : "insert_purse_not_closed_inconsistencies",
36 : "INSERT INTO auditor_purse_not_closed_inconsistencies "
37 : "(purse_pub"
38 : ",amount"
39 : ",expiration_date"
40 : ") VALUES ($1,$2,$3)"
41 : /* The purse auditor re-reports every expired purse on every
42 : round; without this the table grows by one row per purse
43 : per round until GC removes the purse ten years later. */
44 : " ON CONFLICT (purse_pub) DO UPDATE"
45 : " SET amount=excluded.amount"
46 : " ,expiration_date=excluded.expiration_date"
47 : );
48 3 : return GNUNET_PQ_eval_prepared_non_select (ctx->conn,
49 : "insert_purse_not_closed_inconsistencies",
50 : params);
51 : }
|