ensure_coin_known.h (2932B)
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 src/include/exchange-database/ensure_coin_known.h 18 * @brief implementation of the ensure_coin_known function for Postgres 19 * @author Christian Grothoff 20 */ 21 #ifndef EXCHANGE_DATABASE_ENSURE_COIN_KNOWN_H 22 #define EXCHANGE_DATABASE_ENSURE_COIN_KNOWN_H 23 24 #include "exchangedb_lib.h" 25 26 /** 27 * Possible status codes from making sure a coin is known. 28 */ 29 enum TALER_EXCHANGEDB_CoinKnownStatus 30 { 31 /** 32 * The coin was successfully added. 33 */ 34 TALER_EXCHANGEDB_CKS_ADDED = 1, 35 36 /** 37 * The coin was already present. 38 */ 39 TALER_EXCHANGEDB_CKS_PRESENT = 0, 40 41 /** 42 * Serialization failure. 43 */ 44 TALER_EXCHANGEDB_CKS_SOFT_FAIL = -1, 45 46 /** 47 * Hard database failure. 48 */ 49 TALER_EXCHANGEDB_CKS_HARD_FAIL = -2, 50 51 /** 52 * Conflicting coin (different denomination key) already in database. 53 */ 54 TALER_EXCHANGEDB_CKS_DENOM_CONFLICT = -3, 55 56 /** 57 * Conflicting coin (expected NULL age hash) already in database. 58 */ 59 TALER_EXCHANGEDB_CKS_AGE_CONFLICT_EXPECTED_NULL = -4, 60 61 /** 62 * Conflicting coin (unexpected NULL age hash) already in database. 63 */ 64 TALER_EXCHANGEDB_CKS_AGE_CONFLICT_EXPECTED_NON_NULL = -5, 65 66 /** 67 * Conflicting coin (different age hash) already in database. 68 */ 69 TALER_EXCHANGEDB_CKS_AGE_CONFLICT_VALUE_DIFFERS = -6, 70 71 }; 72 73 74 /** 75 * Make sure the given @a coin is known to the database. 76 * 77 * @param pg the database context 78 * @param coin the coin that must be made known 79 * @param[out] known_coin_id set to the unique row of the coin 80 * @param[out] denom_hash set to the denomination hash of the existing 81 * coin (for conflict error reporting) 82 * @param[out] h_age_commitment set to the conflicting age commitment hash on conflict 83 * @return database transaction status, non-negative on success 84 */ 85 enum TALER_EXCHANGEDB_CoinKnownStatus 86 TALER_EXCHANGEDB_ensure_coin_known (struct TALER_EXCHANGEDB_PostgresContext *pg, 87 const struct TALER_CoinPublicInfo *coin, 88 uint64_t *known_coin_id, 89 struct TALER_DenominationHashP *denom_hash, 90 struct TALER_AgeCommitmentHashP * 91 h_age_commitment) 92 ; 93 94 #endif