select_purse_merges_above_serial_id.h (5035B)
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 select_purse_merges_above_serial_id.h 18 * @brief implementation of the select_purse_merges_above_serial_id function for Postgres 19 * @author Christian Grothoff 20 */ 21 #ifndef EXCHANGE_DATABASE_SELECT_PURSE_MERGES_ABOVE_SERIAL_ID_H 22 #define EXCHANGE_DATABASE_SELECT_PURSE_MERGES_ABOVE_SERIAL_ID_H 23 24 #include "taler/taler_util.h" 25 #include "taler/taler_json_lib.h" 26 #include "exchangedb_lib.h" 27 28 29 /** 30 * Function called with details about purse 31 * merges that have been made, with 32 * the goal of auditing the purse merge execution. 33 * 34 * @param cls closure 35 * @param rowid unique serial ID for the deposit in our DB 36 * @param partner_base_url where is the reserve, NULL for this exchange 37 * @param amount total amount expected in the purse 38 * @param balance current balance in the purse (according to the auditor) 39 * @param flags purse flags 40 * @param merge_pub merge capability key 41 * @param reserve_pub reserve the merge affects 42 * @param merge_sig signature affirming the merge 43 * @param purse_pub purse key 44 * @param merge_timestamp when did the merge happen 45 * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop 46 */ 47 #ifndef TALER_EXCHANGEDB_PURSE_MERGE_RESULT_CLOSURE 48 /** 49 * Type of the closure for #TALER_EXCHANGEDB_PurseMergeCallback. 50 */ 51 #define TALER_EXCHANGEDB_PURSE_MERGE_RESULT_CLOSURE void 52 #endif 53 typedef enum GNUNET_GenericReturnValue 54 (*TALER_EXCHANGEDB_PurseMergeCallback)( 55 TALER_EXCHANGEDB_PURSE_MERGE_RESULT_CLOSURE *cls, 56 uint64_t rowid, 57 const char *partner_base_url, 58 const struct TALER_Amount *amount, 59 const struct TALER_Amount *balance, 60 enum TALER_WalletAccountMergeFlags flags, 61 const struct TALER_PurseMergePublicKeyP *merge_pub, 62 const struct TALER_ReservePublicKeyP *reserve_pub, 63 const struct TALER_PurseMergeSignatureP *merge_sig, 64 const struct TALER_PurseContractPublicKeyP *purse_pub, 65 struct GNUNET_TIME_Timestamp merge_timestamp); 66 67 68 /* Callback typedefs */ 69 /** 70 * Function called with details about purse 71 * merges that have been made, with 72 * the goal of auditing the purse merge execution. 73 * 74 * @param cls closure 75 * @param rowid unique serial ID for the deposit in our DB 76 * @param partner_base_url where is the reserve, NULL for this exchange 77 * @param amount total amount expected in the purse 78 * @param balance current balance in the purse (according to the auditor) 79 * @param flags purse flags 80 * @param merge_pub merge capability key 81 * @param reserve_pub reserve the merge affects 82 * @param merge_sig signature affirming the merge 83 * @param purse_pub purse key 84 * @param merge_timestamp when did the merge happen 85 * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop 86 */ 87 typedef enum GNUNET_GenericReturnValue 88 (*TALER_EXCHANGEDB_PurseMergeCallback)( 89 TALER_EXCHANGEDB_PURSE_MERGE_RESULT_CLOSURE *cls, 90 uint64_t rowid, 91 const char *partner_base_url, 92 const struct TALER_Amount *amount, 93 const struct TALER_Amount *balance, 94 enum TALER_WalletAccountMergeFlags flags, 95 const struct TALER_PurseMergePublicKeyP *merge_pub, 96 const struct TALER_ReservePublicKeyP *reserve_pub, 97 const struct TALER_PurseMergeSignatureP *merge_sig, 98 const struct TALER_PurseContractPublicKeyP *purse_pub, 99 struct GNUNET_TIME_Timestamp merge_timestamp); 100 101 /** 102 * Select purse merges deposits above @a serial_id in monotonically increasing 103 * order. 104 * 105 * @param pg the database context 106 * @param serial_id highest serial ID to exclude (select strictly larger) 107 * @param cb function to call on each result 108 * @param cb_cls closure for @a cb 109 * @return transaction status code 110 */ 111 enum GNUNET_DB_QueryStatus 112 TALER_TALER_TALER_EXCHANGEDB_select_purse_merges_above_serial_id (struct 113 TALER_EXCHANGEDB_PostgresContext 114 *pg, 115 uint64_t 116 serial_id, 117 TALER_EXCHANGEDB_PurseMergeCallback 118 cb, 119 TALER_EXCHANGEDB_PURSE_MERGE_RESULT_CLOSURE 120 *cb_cls); 121 122 #endif