batch_ensure_coin_known.h (3508B)
1 /* 2 This file is part of TALER 3 Copyright (C) 2022, 2023 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 src/include/exchange-database/batch_ensure_coin_known.h 18 * @brief implementation of the batch_ensure_coin_known function for Postgres 19 * @author Christian Grothoff 20 */ 21 #ifndef EXCHANGE_DATABASE_BATCH_ENSURE_COIN_KNOWN_H 22 #define EXCHANGE_DATABASE_BATCH_ENSURE_COIN_KNOWN_H 23 24 #include "exchangedb_lib.h" 25 26 27 /** 28 * The conflict that can occur for the age restriction 29 */ 30 enum TALER_EXCHANGEDB_AgeCommitmentHash_Conflict 31 { 32 /** 33 * Value OK, no conflict 34 */ 35 TALER_AgeCommitmentHashP_NoConflict = 0, 36 37 /** 38 * Given hash had a value, but NULL (or zero) was expected 39 */ 40 TALER_AgeCommitmentHashP_NullExpected = 1, 41 42 /** 43 * Given hash was NULL, but value was expected 44 */ 45 TALER_AgeCommitmentHashP_ValueExpected = 2, 46 47 /** 48 * Given hash differs from value in the known coin 49 */ 50 TALER_AgeCommitmentHashP_ValueDiffers = 3, 51 }; 52 53 /** 54 * Per-coin information returned when doing a batch insert. 55 */ 56 struct TALER_EXCHANGEDB_CoinInfo 57 { 58 /** 59 * Row of the coin in the known_coins table. 60 */ 61 uint64_t known_coin_id; 62 63 /** 64 * Hash of the denomination, relevant on @e denom_conflict. 65 */ 66 struct TALER_DenominationHashP denom_hash; 67 68 /** 69 * Hash of the age commitment, relevant on @e age_conflict. 70 */ 71 struct TALER_AgeCommitmentHashP h_age_commitment; 72 73 /** 74 * True if the coin was known previously. 75 */ 76 bool existed; 77 78 /** 79 * True if the known coin has a different denomination; 80 * application will find denomination of the already 81 * known coin in @e denom_hash. 82 */ 83 bool denom_conflict; 84 85 /** 86 * Indicates if and what kind of conflict with the age 87 * restriction of the known coin was present; 88 * application will find age commitment of the already 89 * known coin in @e h_age_commitment. 90 */ 91 enum TALER_EXCHANGEDB_AgeCommitmentHash_Conflict age_conflict; 92 }; 93 94 95 /** 96 * Make sure the array of given @a coin is known to the database. 97 * 98 * @param pg the database context 99 * @param coin array of coins that must be made known 100 * @param[out] result array where to store information about each coin 101 * @param coin_length length of the @a coin and @a result arraysf 102 * @param batch_size desired (maximum) batch size 103 * @return database transaction status, non-negative on success 104 */ 105 enum GNUNET_DB_QueryStatus 106 TALER_EXCHANGEDB_batch_ensure_coin_known (struct 107 TALER_EXCHANGEDB_PostgresContext *pg, 108 const struct TALER_CoinPublicInfo * 109 coin, 110 struct TALER_EXCHANGEDB_CoinInfo * 111 result, 112 unsigned int coin_length, 113 unsigned int batch_size); 114 115 #endif