exchange/src/exchangedb/irbt_callbacks.c

573 lines
18 KiB
C
Raw Normal View History

/*
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)
{
struct GNUNET_HashCode denom_hash;
2021-01-10 17:07:09 +01:00
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&td->serial),
GNUNET_PQ_query_param_auto_from_type (&denom_hash),
GNUNET_PQ_query_param_rsa_public_key (
td->details.denominations.denom_pub.rsa_public_key),
// GNUNET_PQ_query_param_auto_from_type (&master_pub), // FIXME: !?
GNUNET_PQ_query_param_auto_from_type (
&td->details.denominations.master_sig),
TALER_PQ_query_param_absolute_time (
&td->details.denominations.valid_from),
TALER_PQ_query_param_absolute_time (
&td->details.denominations.expire_withdraw),
TALER_PQ_query_param_absolute_time (
&td->details.denominations.expire_deposit),
TALER_PQ_query_param_absolute_time (
&td->details.denominations.expire_legal),
TALER_PQ_query_param_amount (&td->details.denominations.coin),
TALER_PQ_query_param_amount (
&td->details.denominations.fee_withdraw),
TALER_PQ_query_param_amount (
&td->details.denominations.fee_deposit),
TALER_PQ_query_param_amount (
&td->details.denominations.fee_refresh),
TALER_PQ_query_param_amount (
&td->details.denominations.fee_refund),
2021-01-10 17:07:09 +01:00
GNUNET_PQ_query_param_end
};
(void) pg;
GNUNET_CRYPTO_rsa_public_key_hash (
td->details.denominations.denom_pub.rsa_public_key,
&denom_hash);
2021-01-10 17:07:09 +01:00
return GNUNET_PQ_eval_prepared_non_select (session->conn,
2021-01-10 17:27:46 +01:00
"insert_into_table_denominations",
2021-01-10 17:07:09 +01:00
params);
}
/**
* 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)
{
2021-01-10 17:07:09 +01:00
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&td->serial),
GNUNET_PQ_query_param_auto_from_type (
&td->details.denomination_revocations.master_sig),
GNUNET_PQ_query_param_uint64 (
&td->details.denomination_revocations.denominations_serial),
2021-01-10 17:07:09 +01:00
GNUNET_PQ_query_param_end
};
(void) pg;
return GNUNET_PQ_eval_prepared_non_select (session->conn,
2021-01-10 17:27:46 +01:00
"insert_into_table_denomination_revocations",
2021-01-10 17:07:09 +01:00
params);
}
/**
* 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)
{
2021-01-10 17:07:09 +01:00
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&td->serial),
GNUNET_PQ_query_param_auto_from_type (&td->details.reserves.reserve_pub),
GNUNET_PQ_query_param_string (td->details.reserves.account_details),
TALER_PQ_query_param_amount (&td->details.reserves.current_balance),
TALER_PQ_query_param_absolute_time (&td->details.reserves.expiration_date),
TALER_PQ_query_param_absolute_time (&td->details.reserves.gc_date),
2021-01-10 17:07:09 +01:00
GNUNET_PQ_query_param_end
};
(void) pg;
return GNUNET_PQ_eval_prepared_non_select (session->conn,
2021-01-10 17:27:46 +01:00
"insert_into_table_reserves",
2021-01-10 17:07:09 +01:00
params);
}
/**
* 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)
{
2021-01-10 17:07:09 +01:00
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&td->serial),
GNUNET_PQ_query_param_end
};
(void) pg;
return GNUNET_PQ_eval_prepared_non_select (session->conn,
2021-01-10 17:27:46 +01:00
"insert_into_table_reserves_in",
2021-01-10 17:07:09 +01:00
params);
}
/**
* 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)
{
2021-01-10 17:07:09 +01:00
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&td->serial),
GNUNET_PQ_query_param_end
};
(void) pg;
return GNUNET_PQ_eval_prepared_non_select (session->conn,
2021-01-10 17:27:46 +01:00
"insert_into_table_reserves_close",
2021-01-10 17:07:09 +01:00
params);
}
/**
* 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)
{
2021-01-10 17:07:09 +01:00
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&td->serial),
GNUNET_PQ_query_param_end
};
(void) pg;
return GNUNET_PQ_eval_prepared_non_select (session->conn,
2021-01-10 17:27:46 +01:00
"insert_into_table_reserves_out",
2021-01-10 17:07:09 +01:00
params);
}
/**
* 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)
{
2021-01-10 17:07:09 +01:00
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&td->serial),
GNUNET_PQ_query_param_end
};
(void) pg;
return GNUNET_PQ_eval_prepared_non_select (session->conn,
2021-01-10 17:27:46 +01:00
"insert_into_table_auditors",
2021-01-10 17:07:09 +01:00
params);
}
/**
* 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)
{
2021-01-10 17:07:09 +01:00
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&td->serial),
GNUNET_PQ_query_param_end
};
(void) pg;
return GNUNET_PQ_eval_prepared_non_select (session->conn,
2021-01-10 17:27:46 +01:00
"insert_into_table_auditor_denom_sigs",
2021-01-10 17:07:09 +01:00
params);
}
/**
* 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)
{
2021-01-10 17:07:09 +01:00
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&td->serial),
GNUNET_PQ_query_param_end
};
(void) pg;
return GNUNET_PQ_eval_prepared_non_select (session->conn,
2021-01-10 17:27:46 +01:00
"insert_into_table_exchange_sign_keys",
2021-01-10 17:07:09 +01:00
params);
}
/**
* 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)
{
2021-01-10 17:07:09 +01:00
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&td->serial),
GNUNET_PQ_query_param_end
};
(void) pg;
return GNUNET_PQ_eval_prepared_non_select (session->conn,
2021-01-10 17:27:46 +01:00
"insert_into_table_signkey_revocations",
2021-01-10 17:07:09 +01:00
params);
}
/**
* 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)
{
2021-01-10 17:07:09 +01:00
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&td->serial),
GNUNET_PQ_query_param_end
};
(void) pg;
return GNUNET_PQ_eval_prepared_non_select (session->conn,
2021-01-10 17:27:46 +01:00
"insert_into_table_known_coins",
2021-01-10 17:07:09 +01:00
params);
}
/**
* 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)
{
2021-01-10 17:07:09 +01:00
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&td->serial),
GNUNET_PQ_query_param_end
};
(void) pg;
return GNUNET_PQ_eval_prepared_non_select (session->conn,
2021-01-10 17:27:46 +01:00
"insert_into_table_refresh_commitments",
2021-01-10 17:07:09 +01:00
params);
}
/**
* 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)
{
2021-01-10 17:07:09 +01:00
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&td->serial),
GNUNET_PQ_query_param_end
};
(void) pg;
return GNUNET_PQ_eval_prepared_non_select (session->conn,
2021-01-10 17:27:46 +01:00
"insert_into_table_refresh_revealed_coins",
2021-01-10 17:07:09 +01:00
params);
}
/**
* 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)
{
2021-01-10 17:07:09 +01:00
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&td->serial),
GNUNET_PQ_query_param_end
};
(void) pg;
return GNUNET_PQ_eval_prepared_non_select (session->conn,
2021-01-10 17:27:46 +01:00
"insert_into_table_refresh_transfer_keys",
2021-01-10 17:07:09 +01:00
params);
}
/**
* 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)
{
2021-01-10 17:07:09 +01:00
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&td->serial),
GNUNET_PQ_query_param_end
};
(void) pg;
return GNUNET_PQ_eval_prepared_non_select (session->conn,
2021-01-10 17:27:46 +01:00
"insert_into_table_deposits",
2021-01-10 17:07:09 +01:00
params);
}
/**
* 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)
{
2021-01-10 17:07:09 +01:00
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&td->serial),
GNUNET_PQ_query_param_end
};
(void) pg;
return GNUNET_PQ_eval_prepared_non_select (session->conn,
2021-01-10 17:27:46 +01:00
"insert_into_table_refunds",
2021-01-10 17:07:09 +01:00
params);
}
/**
* 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)
{
2021-01-10 17:07:09 +01:00
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&td->serial),
GNUNET_PQ_query_param_end
};
(void) pg;
return GNUNET_PQ_eval_prepared_non_select (session->conn,
2021-01-10 17:27:46 +01:00
"insert_into_table_wire_out",
2021-01-10 17:07:09 +01:00
params);
}
/**
* 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)
{
2021-01-10 17:07:09 +01:00
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&td->serial),
GNUNET_PQ_query_param_end
};
(void) pg;
return GNUNET_PQ_eval_prepared_non_select (session->conn,
2021-01-10 17:27:46 +01:00
"insert_into_table_aggregation_tracking",
2021-01-10 17:07:09 +01:00
params);
}
/**
* 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)
{
2021-01-10 17:07:09 +01:00
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&td->serial),
GNUNET_PQ_query_param_end
};
(void) pg;
return GNUNET_PQ_eval_prepared_non_select (session->conn,
2021-01-10 17:27:46 +01:00
"insert_into_table_wire_fee",
2021-01-10 17:07:09 +01:00
params);
}
/**
* 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)
{
2021-01-10 17:07:09 +01:00
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&td->serial),
GNUNET_PQ_query_param_end
};
(void) pg;
return GNUNET_PQ_eval_prepared_non_select (session->conn,
2021-01-10 17:27:46 +01:00
"insert_into_table_recoup",
2021-01-10 17:07:09 +01:00
params);
}
/**
* 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)
{
2021-01-10 17:07:09 +01:00
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&td->serial),
GNUNET_PQ_query_param_end
};
(void) pg;
return GNUNET_PQ_eval_prepared_non_select (session->conn,
2021-01-10 17:27:46 +01:00
"insert_into_table_recoup_refresh",
2021-01-10 17:07:09 +01:00
params);
}
/* end of irbt_callbacks.c */