diff --git a/contrib/gana b/contrib/gana index 36f9c4996..58a94dc41 160000 --- a/contrib/gana +++ b/contrib/gana @@ -1 +1 @@ -Subproject commit 36f9c499683d33cf3d1a267c6f4ca9e48301b535 +Subproject commit 58a94dc411d8ec0f23c5364c37719e90bb9ad8a9 diff --git a/src/exchangedb/common-0001.sql b/src/exchangedb/common-0001.sql index 564bf3b35..21f531102 100644 --- a/src/exchangedb/common-0001.sql +++ b/src/exchangedb/common-0001.sql @@ -2190,7 +2190,7 @@ $$; COMMENT ON FUNCTION detach_default_partitions IS 'We need to drop default and create new one before deleting the default partitions - otherwise constraints get lost too. Might be needed in shardig too'; + otherwise constraints get lost too. Might be needed in sharding too'; CREATE OR REPLACE FUNCTION drop_default_partitions() diff --git a/src/exchangedb/irbt_callbacks.c b/src/exchangedb/irbt_callbacks.c index ffad1c9b0..570d42214 100644 --- a/src/exchangedb/irbt_callbacks.c +++ b/src/exchangedb/irbt_callbacks.c @@ -131,6 +131,64 @@ irbt_cb_table_wire_targets (struct PostgresClosure *pg, } +/** + * Function called with records to insert into table. + * + * @param pg plugin context + * @param td record to insert + */ +static enum GNUNET_DB_QueryStatus +irbt_cb_table_legitimization_processes (struct PostgresClosure *pg, + const struct + TALER_EXCHANGEDB_TableData *td) +{ + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&td->serial), + GNUNET_PQ_query_param_auto_from_type ( + &td->details.legitimization_processes.h_payto), + GNUNET_PQ_query_param_timestamp ( + &td->details.legitimization_processes.expiration_time), + GNUNET_PQ_query_param_string ( + td->details.legitimization_processes.provider_section), + GNUNET_PQ_query_param_string ( + td->details.legitimization_processes.provider_user_id), + GNUNET_PQ_query_param_string ( + td->details.legitimization_processes.provider_legitimization_id), + GNUNET_PQ_query_param_end + }; + + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "insert_into_table_legitimization_processes", + params); +} + + +/** + * Function called with records to insert into table. + * + * @param pg plugin context + * @param td record to insert + */ +static enum GNUNET_DB_QueryStatus +irbt_cb_table_legitimization_requirements (struct PostgresClosure *pg, + const struct + TALER_EXCHANGEDB_TableData *td) +{ + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&td->serial), + GNUNET_PQ_query_param_auto_from_type ( + &td->details.legitimization_requirements.h_payto), + GNUNET_PQ_query_param_string ( + td->details.legitimization_requirements.required_checks), + GNUNET_PQ_query_param_end + }; + + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "insert_into_table_legitimization_requirements", + params); +} + + /** * Function called with reserves records to insert into table. * @@ -185,6 +243,100 @@ irbt_cb_table_reserves_in (struct PostgresClosure *pg, } +/** + * Function called with reserves_open_requests records to insert into table. + * + * @param pg plugin context + * @param td record to insert + */ +static enum GNUNET_DB_QueryStatus +irbt_cb_table_reserves_open_requests (struct PostgresClosure *pg, + const struct + TALER_EXCHANGEDB_TableData *td) +{ + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&td->serial), + GNUNET_PQ_query_param_timestamp ( + &td->details.reserves_open_requests.request_timestamp), + GNUNET_PQ_query_param_timestamp ( + &td->details.reserves_open_requests.expiration_date), + GNUNET_PQ_query_param_auto_from_type ( + &td->details.reserves_open_requests.reserve_sig), + TALER_PQ_query_param_amount ( + &td->details.reserves_open_requests.reserve_payment), + GNUNET_PQ_query_param_uint32 ( + &td->details.reserves_open_requests.requested_purse_limit), + GNUNET_PQ_query_param_end + }; + + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "insert_into_table_reserves_open_requests", + params); +} + + +/** + * Function called with reserves_open_requests records to insert into table. + * + * @param pg plugin context + * @param td record to insert + */ +static enum GNUNET_DB_QueryStatus +irbt_cb_table_reserves_open_deposits (struct PostgresClosure *pg, + const struct + TALER_EXCHANGEDB_TableData *td) +{ + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&td->serial), + GNUNET_PQ_query_param_timestamp ( + &td->details.reserves_open_deposits.request_timestamp), + GNUNET_PQ_query_param_auto_from_type ( + &td->details.reserves_open_deposits.coin_pub), + GNUNET_PQ_query_param_auto_from_type ( + &td->details.reserves_open_deposits.coin_sig), + GNUNET_PQ_query_param_auto_from_type ( + &td->details.reserves_open_deposits.reserve_sig), + TALER_PQ_query_param_amount ( + &td->details.reserves_open_deposits.contribution), + GNUNET_PQ_query_param_end + }; + + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "insert_into_table_reserves_open_deposits", + params); +} + + +/** + * Function called with reserves_close records to insert into table. + * + * @param pg plugin context + * @param td record to insert + */ +static enum GNUNET_DB_QueryStatus +irbt_cb_table_reserves_close_requests (struct PostgresClosure *pg, + const struct + TALER_EXCHANGEDB_TableData *td) +{ + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&td->serial), + GNUNET_PQ_query_param_auto_from_type ( + &td->details.reserves_close_requests.reserve_pub), + GNUNET_PQ_query_param_timestamp ( + &td->details.reserves_close_requests.execution_date), + GNUNET_PQ_query_param_auto_from_type ( + &td->details.reserves_close_requests.reserve_sig), + GNUNET_PQ_query_param_auto_from_type ( + &td->details.reserves_close_requests.wire_target_h_payto), + GNUNET_PQ_query_param_end + }; + + return GNUNET_PQ_eval_prepared_non_select (pg->conn, + "insert_into_table_reserves_close_requests", + params); +} + + /** * Function called with reserves_close records to insert into table. * diff --git a/src/include/taler_exchangedb_plugin.h b/src/include/taler_exchangedb_plugin.h index 31ccf81c8..eee9b17fc 100644 --- a/src/include/taler_exchangedb_plugin.h +++ b/src/include/taler_exchangedb_plugin.h @@ -195,9 +195,14 @@ enum TALER_EXCHANGEDB_ReplicatedTable TALER_EXCHANGEDB_RT_DENOMINATIONS, TALER_EXCHANGEDB_RT_DENOMINATION_REVOCATIONS, TALER_EXCHANGEDB_RT_WIRE_TARGETS, + TALER_EXCHANGEDB_RT_LEGITIMIZATION_PROCESSES, + TALER_EXCHANGEDB_RT_LEGITIMIZATION_REQUIREMENTS, TALER_EXCHANGEDB_RT_RESERVES, TALER_EXCHANGEDB_RT_RESERVES_IN, TALER_EXCHANGEDB_RT_RESERVES_CLOSE, + TALER_EXCHANGEDB_RT_RESERVES_OPEN_REQUESTS, + TALER_EXCHANGEDB_RT_RESERVES_OPEN_DEPOSITS, + TALER_EXCHANGEDB_RT_RESERVES_CLOSE_REQUESTS, TALER_EXCHANGEDB_RT_RESERVES_OUT, TALER_EXCHANGEDB_RT_AUDITORS, TALER_EXCHANGEDB_RT_AUDITOR_DENOM_SIGS, @@ -281,6 +286,21 @@ struct TALER_EXCHANGEDB_TableData char *payto_uri; } wire_targets; + struct + { + struct TALER_PaytoHashP h_payto; + struct GNUNET_TIME_Timestamp expiration_time; + char *provider_section; + char *provider_user_id; + char *provider_legitimization_id; + } legitimization_processes; + + struct + { + struct TALER_PaytoHashP h_payto; + char *required_checks; + } legitimization_requirements; + struct { struct TALER_ReservePublicKeyP reserve_pub; @@ -298,6 +318,34 @@ struct TALER_EXCHANGEDB_TableData struct TALER_ReservePublicKeyP reserve_pub; } reserves_in; + struct + { + struct TALER_ReservePublicKeyP reserve_pub; + struct GNUNET_TIME_Timestamp request_timestamp; + struct GNUNET_TIME_Timestamp expiration_date; + struct TALER_ReserveSignatureP reserve_sig; + struct TALER_Amount reserve_payment; + uint32_t requested_purse_limit; + } reserves_open_requests; + + struct + { + struct TALER_ReservePublicKeyP reserve_pub; + struct GNUNET_TIME_Timestamp request_timestamp; + struct TALER_CoinSpendPublicKeyP coin_pub; + struct TALER_CoinSpendSignatureP coin_sig; + struct TALER_ReserveSignatureP reserve_sig; + struct TALER_Amount contribution; + } reserves_open_deposits; + + struct + { + struct TALER_ReservePublicKeyP reserve_pub; + struct GNUNET_TIME_Timestamp execution_date; + struct TALER_ReserveSignatureP reserve_sig; + struct TALER_PaytoHashP wire_target_h_payto; + } reserves_close_requests; + struct { struct TALER_ReservePublicKeyP reserve_pub;