do_fountain_withdraw.h (2602B)
1 /* 2 This file is part of TALER 3 Copyright (C) 2026 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/merchant-database/do_fountain_withdraw.h 18 * @brief implementation of the do_fountain_withdraw function for Postgres 19 * @author Bohdan Potuzhnyi 20 */ 21 #ifndef MERCHANT_DATABASE_DO_FOUNTAIN_WITHDRAW_H 22 #define MERCHANT_DATABASE_DO_FOUNTAIN_WITHDRAW_H 23 24 #include <taler/taler_util.h> 25 #include "merchantdb_lib.h" 26 27 28 struct TALER_MERCHANTDB_PostgresContext; 29 30 /** 31 * Atomically check and consume per-period withdrawal quota for a 32 * fountain. Each entry addresses one (token family, key slot) pair; 33 * entries must be distinct. All-or-nothing: if any entry has no 34 * matching grant or would exceed its limit, no quota is consumed and 35 * @a failed_index reports the offending entry. 36 * 37 * @param pg database context 38 * @param instance_id instance the fountain belongs to 39 * @param fountain_serial serial of the fountain withdrawing from 40 * @param num_entries number of entries in the parallel arrays 41 * @param token_family_serials token family of each entry 42 * @param slot_starts issue-key validity period start of each entry 43 * @param num_requested number of tokens requested by each entry 44 * @param[out] failed_index on failure, set to the index (into the 45 * input arrays) of the offending entry 46 * @param[out] no_grant set to true if the failed entry has no 47 * matching grant 48 * @param[out] exceeded set to true if the failed entry would exceed 49 * its tokens_per_period_limit 50 * @return database result code 51 */ 52 enum GNUNET_DB_QueryStatus 53 TALER_MERCHANTDB_do_fountain_withdraw ( 54 struct TALER_MERCHANTDB_PostgresContext *pg, 55 const char *instance_id, 56 uint64_t fountain_serial, 57 unsigned int num_entries, 58 const uint64_t token_family_serials[static num_entries], 59 const struct GNUNET_TIME_Timestamp slot_starts[static num_entries], 60 const uint64_t num_requested[static num_entries], 61 unsigned int *failed_index, 62 bool *no_grant, 63 bool *exceeded); 64 65 #endif