diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-01-10 13:27:33 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-01-10 13:27:33 +0100 |
commit | 80b4fc08690267faf1b9eba9e66aa50921fdfaef (patch) | |
tree | 1b1508c6b1410a12eade79ddba4e23fab18d5a2f /src | |
parent | 0e16fb816cb96611211265690d0fd797cf897dc4 (diff) |
skeleton for postgres_insert_records_by_table
Diffstat (limited to 'src')
-rw-r--r-- | src/exchangedb/Makefile.am | 1 | ||||
-rw-r--r-- | src/exchangedb/irbt_callbacks.c | 346 | ||||
-rw-r--r-- | src/exchangedb/plugin_exchangedb_postgres.c | 96 |
3 files changed, 440 insertions, 3 deletions
diff --git a/src/exchangedb/Makefile.am b/src/exchangedb/Makefile.am index bfc42ec1e..8a4adf6b3 100644 --- a/src/exchangedb/Makefile.am +++ b/src/exchangedb/Makefile.am @@ -25,6 +25,7 @@ EXTRA_DIST = \ exchangedb.conf \ exchangedb-postgres.conf \ plugin_exchangedb_common.c \ + irbt_callbacks.c \ lrbt_callbacks.c \ test-exchange-db-postgres.conf \ $(sql_DATA) diff --git a/src/exchangedb/irbt_callbacks.c b/src/exchangedb/irbt_callbacks.c new file mode 100644 index 000000000..d94295096 --- /dev/null +++ b/src/exchangedb/irbt_callbacks.c @@ -0,0 +1,346 @@ +/* + This file is part of GNUnet + Copyright (C) 2020 Taler Systems SA + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/** + * @file exchangedb/irbt_callbacks.c + * @brief callbacks used by postgres_insert_records_by_table, to be + * inlined into the plugin + * @author Christian Grothoff + */ + + +/** + * Function called with denominations records to insert into table. + * + * @param pg plugin context + * @param session database session + * @param td record to insert + */ +static enum GNUNET_DB_QueryStatus +irbt_cb_table_denominations (struct PostgresClosure *pg, + struct TALER_EXCHANGEDB_Session *session, + const struct TALER_EXCHANGEDB_TableData *td) +{ +} + + +/** + * Function called with denomination_revocations records to insert into table. + * + * @param pg plugin context + * @param session database session + * @param td record to insert + */ +static enum GNUNET_DB_QueryStatus +irbt_cb_table_denomination_revocations (struct PostgresClosure *pg, + struct TALER_EXCHANGEDB_Session *session, + const struct + TALER_EXCHANGEDB_TableData *td) +{ +} + + +/** + * Function called with reserves records to insert into table. + * + * @param pg plugin context + * @param session database session + * @param td record to insert + */ +static enum GNUNET_DB_QueryStatus +irbt_cb_table_reserves (struct PostgresClosure *pg, + struct TALER_EXCHANGEDB_Session *session, + const struct TALER_EXCHANGEDB_TableData *td) +{ +} + + +/** + * Function called with reserves_in records to insert into table. + * + * @param pg plugin context + * @param session database session + * @param td record to insert + */ +static enum GNUNET_DB_QueryStatus +irbt_cb_table_reserves_in (struct PostgresClosure *pg, + struct TALER_EXCHANGEDB_Session *session, + const struct TALER_EXCHANGEDB_TableData *td) +{ +} + + +/** + * Function called with reserves_close records to insert into table. + * + * @param pg plugin context + * @param session database session + * @param td record to insert + */ +static enum GNUNET_DB_QueryStatus +irbt_cb_table_reserves_close (struct PostgresClosure *pg, + struct TALER_EXCHANGEDB_Session *session, + const struct TALER_EXCHANGEDB_TableData *td) +{ +} + + +/** + * Function called with reserves_out records to insert into table. + * + * @param pg plugin context + * @param session database session + * @param td record to insert + */ +static enum GNUNET_DB_QueryStatus +irbt_cb_table_reserves_out (struct PostgresClosure *pg, + struct TALER_EXCHANGEDB_Session *session, + const struct TALER_EXCHANGEDB_TableData *td) +{ +} + + +/** + * Function called with auditors records to insert into table. + * + * @param pg plugin context + * @param session database session + * @param td record to insert + */ +static enum GNUNET_DB_QueryStatus +irbt_cb_table_auditors (struct PostgresClosure *pg, + struct TALER_EXCHANGEDB_Session *session, + const struct TALER_EXCHANGEDB_TableData *td) +{ +} + + +/** + * Function called with auditor_denom_sigs records to insert into table. + * + * @param pg plugin context + * @param session database session + * @param td record to insert + */ +static enum GNUNET_DB_QueryStatus +irbt_cb_table_auditor_denom_sigs (struct PostgresClosure *pg, + struct TALER_EXCHANGEDB_Session *session, + const struct TALER_EXCHANGEDB_TableData *td) +{ +} + + +/** + * Function called with exchange_sign_keys records to insert into table. + * + * @param pg plugin context + * @param session database session + * @param td record to insert + */ +static enum GNUNET_DB_QueryStatus +irbt_cb_table_exchange_sign_keys (struct PostgresClosure *pg, + struct TALER_EXCHANGEDB_Session *session, + const struct TALER_EXCHANGEDB_TableData *td) +{ +} + + +/** + * Function called with signkey_revocations records to insert into table. + * + * @param pg plugin context + * @param session database session + * @param td record to insert + */ +static enum GNUNET_DB_QueryStatus +irbt_cb_table_signkey_revocations (struct PostgresClosure *pg, + struct TALER_EXCHANGEDB_Session *session, + const struct TALER_EXCHANGEDB_TableData *td) +{ +} + + +/** + * Function called with known_coins records to insert into table. + * + * @param pg plugin context + * @param session database session + * @param td record to insert + */ +static enum GNUNET_DB_QueryStatus +irbt_cb_table_known_coins (struct PostgresClosure *pg, + struct TALER_EXCHANGEDB_Session *session, + const struct TALER_EXCHANGEDB_TableData *td) +{ +} + + +/** + * Function called with refresh_commitments records to insert into table. + * + * @param pg plugin context + * @param session database session + * @param td record to insert + */ +static enum GNUNET_DB_QueryStatus +irbt_cb_table_refresh_commitments (struct PostgresClosure *pg, + struct TALER_EXCHANGEDB_Session *session, + const struct TALER_EXCHANGEDB_TableData *td) +{ +} + + +/** + * Function called with refresh_revealed_coins records to insert into table. + * + * @param pg plugin context + * @param session database session + * @param td record to insert + */ +static enum GNUNET_DB_QueryStatus +irbt_cb_table_refresh_revealed_coins (struct PostgresClosure *pg, + struct TALER_EXCHANGEDB_Session *session, + const struct + TALER_EXCHANGEDB_TableData *td) +{ +} + + +/** + * Function called with refresh_transfer_keys records to insert into table. + * + * @param pg plugin context + * @param session database session + * @param td record to insert + */ +static enum GNUNET_DB_QueryStatus +irbt_cb_table_refresh_transfer_keys (struct PostgresClosure *pg, + struct TALER_EXCHANGEDB_Session *session, + const struct + TALER_EXCHANGEDB_TableData *td) +{ +} + + +/** + * Function called with deposits records to insert into table. + * + * @param pg plugin context + * @param session database session + * @param td record to insert + */ +static enum GNUNET_DB_QueryStatus +irbt_cb_table_deposits (struct PostgresClosure *pg, + struct TALER_EXCHANGEDB_Session *session, + const struct TALER_EXCHANGEDB_TableData *td) +{ +} + + +/** + * Function called with refunds records to insert into table. + * + * @param pg plugin context + * @param session database session + * @param td record to insert + */ +static enum GNUNET_DB_QueryStatus +irbt_cb_table_refunds (struct PostgresClosure *pg, + struct TALER_EXCHANGEDB_Session *session, + const struct TALER_EXCHANGEDB_TableData *td) +{ +} + + +/** + * Function called with wire_out records to insert into table. + * + * @param pg plugin context + * @param session database session + * @param td record to insert + */ +static enum GNUNET_DB_QueryStatus +irbt_cb_table_wire_out (struct PostgresClosure *pg, + struct TALER_EXCHANGEDB_Session *session, + const struct TALER_EXCHANGEDB_TableData *td) +{ +} + + +/** + * Function called with aggregation_tracking records to insert into table. + * + * @param pg plugin context + * @param session database session + * @param td record to insert + */ +static enum GNUNET_DB_QueryStatus +irbt_cb_table_aggregation_tracking (struct PostgresClosure *pg, + struct TALER_EXCHANGEDB_Session *session, + const struct TALER_EXCHANGEDB_TableData *td) +{ +} + + +/** + * Function called with wire_fee records to insert into table. + * + * @param pg plugin context + * @param session database session + * @param td record to insert + */ +static enum GNUNET_DB_QueryStatus +irbt_cb_table_wire_fee (struct PostgresClosure *pg, + struct TALER_EXCHANGEDB_Session *session, + const struct TALER_EXCHANGEDB_TableData *td) +{ +} + + +/** + * Function called with recoup records to insert into table. + * + * @param pg plugin context + * @param session database session + * @param td record to insert + */ +static enum GNUNET_DB_QueryStatus +irbt_cb_table_recoup (struct PostgresClosure *pg, + struct TALER_EXCHANGEDB_Session *session, + const struct TALER_EXCHANGEDB_TableData *td) +{ +} + + +/** + * Function called with recoup_refresh records to insert into table. + * + * @param pg plugin context + * @param session database session + * @param td record to insert + */ +static enum GNUNET_DB_QueryStatus +irbt_cb_table_recoup_refresh (struct PostgresClosure *pg, + struct TALER_EXCHANGEDB_Session *session, + const struct TALER_EXCHANGEDB_TableData *td) +{ +} + + +/* end of irbt_callbacks.c */ diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c index a815c1b1a..187c727dd 100644 --- a/src/exchangedb/plugin_exchangedb_postgres.c +++ b/src/exchangedb/plugin_exchangedb_postgres.c @@ -9771,6 +9771,23 @@ postgres_lookup_records_by_table (void *cls, /** + * Signature of helper functions of #postgres_insert_records_by_table. + * + * @param pg plugin context + * @param session database session + * @param td record to insert + * @return transaction status code + */ +typedef enum GNUNET_DB_QueryStatus +(*InsertRecordCallback)(struct PostgresClosure *pg, + struct TALER_EXCHANGEDB_Session *session, + const struct TALER_EXCHANGEDB_TableData *td); + + +#include "irbt_callbacks.c" + + +/** * Insert record set into @a table. Used in exchange-auditor database * replication. * @@ -9778,15 +9795,88 @@ postgres_lookup_records_by_table (void *cls, * @param session a session * @param tb table data to insert * @return transaction status code, #GNUNET_DB_STATUS_HARD_ERROR if - * @a table does not have a serial number + * @e table in @a tr is not supported */ static enum GNUNET_DB_QueryStatus postgres_insert_records_by_table (void *cls, struct TALER_EXCHANGEDB_Session *session, const struct TALER_EXCHANGEDB_TableData *td) { - GNUNET_break (0); // FIXME: not implemented! - return GNUNET_DB_STATUS_HARD_ERROR; + struct PostgresClosure *pg = cls; + InsertRecordCallback rh; + + switch (td->table) + { + case TALER_EXCHANGEDB_RT_DENOMINATIONS: + rh = &irbt_cb_table_denominations; + break; + case TALER_EXCHANGEDB_RT_DENOMINATION_REVOCATIONS: + rh = &irbt_cb_table_denomination_revocations; + break; + case TALER_EXCHANGEDB_RT_RESERVES: + rh = &irbt_cb_table_reserves; + break; + case TALER_EXCHANGEDB_RT_RESERVES_IN: + rh = &irbt_cb_table_reserves_in; + break; + case TALER_EXCHANGEDB_RT_RESERVES_CLOSE: + rh = &irbt_cb_table_reserves_close; + break; + case TALER_EXCHANGEDB_RT_RESERVES_OUT: + rh = &irbt_cb_table_reserves_out; + break; + case TALER_EXCHANGEDB_RT_AUDITORS: + rh = &irbt_cb_table_auditors; + break; + case TALER_EXCHANGEDB_RT_AUDITOR_DENOM_SIGS: + rh = &irbt_cb_table_auditor_denom_sigs; + break; + case TALER_EXCHANGEDB_RT_EXCHANGE_SIGN_KEYS: + rh = &irbt_cb_table_exchange_sign_keys; + break; + case TALER_EXCHANGEDB_RT_SIGNKEY_REVOCATIONS: + rh = &irbt_cb_table_signkey_revocations; + break; + case TALER_EXCHANGEDB_RT_KNOWN_COINS: + rh = &irbt_cb_table_known_coins; + break; + case TALER_EXCHANGEDB_RT_REFRESH_COMMITMENTS: + rh = &irbt_cb_table_refresh_commitments; + break; + case TALER_EXCHANGEDB_RT_REFRESH_REVEALED_COINS: + rh = &irbt_cb_table_refresh_revealed_coins; + break; + case TALER_EXCHANGEDB_RT_REFRESH_TRANSFER_KEYS: + rh = &irbt_cb_table_refresh_transfer_keys; + break; + case TALER_EXCHANGEDB_RT_DEPOSITS: + rh = &irbt_cb_table_deposits; + break; + case TALER_EXCHANGEDB_RT_REFUNDS: + rh = &irbt_cb_table_refunds; + break; + case TALER_EXCHANGEDB_RT_WIRE_OUT: + rh = &irbt_cb_table_wire_out; + break; + case TALER_EXCHANGEDB_RT_AGGREGATION_TRACKING: + rh = &irbt_cb_table_aggregation_tracking; + break; + case TALER_EXCHANGEDB_RT_WIRE_FEE: + rh = &irbt_cb_table_wire_fee; + break; + case TALER_EXCHANGEDB_RT_RECOUP: + rh = &irbt_cb_table_recoup; + break; + case TALER_EXCHANGEDB_RT_RECOUP_REFRESH: + rh = &irbt_cb_table_recoup_refresh; + break; + default: + GNUNET_break (0); + return GNUNET_DB_STATUS_HARD_ERROR; + } + return rh (pg, + session, + td); } |