anastasis-db_mark_challenge_code_satisfied.c (2411B)
1 /* 2 This file is part of Anastasis 3 Copyright (C) 2020-2022 Anastasis SARL 4 5 Anastasis is free software; you can redistribute it and/or modify it under the 6 terms of the GNU Affero General Public License as published by the Free Software 7 Foundation; either version 3, or (at your option) any later version. 8 9 Anastasis 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 Affero General Public License for more details. 12 13 You should have received a copy of the GNU Affero General Public License along with 14 Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/> 15 */ 16 /** 17 * @file stasis/anastasis-db_mark_challenge_code_satisfied.c 18 * @brief Anastasis database: mark challenge code satisfied 19 * @author Christian Grothoff 20 */ 21 #include "platform.h" 22 #include "anastasis-db_pg.h" 23 #include "anastasis/anastasis-database/mark_challenge_code_satisfied.h" 24 #include "anastasis/anastasis-database/transaction.h" 25 #include "anastasis/anastasis-database/preflight.h" 26 #include <taler/taler_pq_lib.h> 27 28 29 /** 30 * Set the 'satisfied' bit for the given challenge and code to 31 * 'true'. 32 * 33 * @param truth_uuid identification of the challenge which the code corresponds to 34 * @param code code which is now satisfied 35 * @return transaction status 36 */ 37 enum GNUNET_DB_QueryStatus 38 ANASTASIS_DB_mark_challenge_code_satisfied ( 39 const struct ANASTASIS_CRYPTO_TruthUUIDP *truth_uuid, 40 const uint64_t code) 41 { 42 struct GNUNET_PQ_QueryParam params[] = { 43 GNUNET_PQ_query_param_auto_from_type (truth_uuid), 44 GNUNET_PQ_query_param_uint64 (&code), 45 GNUNET_PQ_query_param_end 46 }; 47 48 PREPARE ("challengecode_set_satisfied", 49 "UPDATE anastasis_challengecode" 50 " SET satisfied=TRUE" 51 " WHERE truth_uuid=$1" 52 " AND code=$2" 53 " AND creation_date IN" 54 " (SELECT creation_date" 55 " FROM anastasis_challengecode" 56 " WHERE truth_uuid=$1" 57 " AND code=$2" 58 " ORDER BY creation_date DESC" 59 " LIMIT 1);"); 60 return GNUNET_PQ_eval_prepared_non_select (pg->conn, 61 "challengecode_set_satisfied", 62 params); 63 } 64 65 66 /* end of anastasis-db_mark_challenge_code_satisfied.c */