plugin update

This commit is contained in:
Joseph 2022-12-05 04:53:24 -05:00
parent 6e3d1bdc91
commit a71893d5f2
No known key found for this signature in database
GPG Key ID: E709789D3076B5CC
4 changed files with 21 additions and 84 deletions

View File

@ -291,7 +291,6 @@ TESTS = \
test-exchangedb-batch-reserves-in-insert-postgres test-exchangedb-batch-reserves-in-insert-postgres
test_exchangedb_postgres_SOURCES = \ test_exchangedb_postgres_SOURCES = \
test_exchangedb.c test_exchangedb.c
test_exchangedb_postgres_LDADD = \ test_exchangedb_postgres_LDADD = \

View File

@ -65,11 +65,15 @@ TEH_PG_batch2_reserves_in_insert (void *cls,
struct TALER_PaytoHashP h_payto; struct TALER_PaytoHashP h_payto;
uint64_t reserve_uuid; uint64_t reserve_uuid;
bool conflicted; bool conflicted;
bool conflicted2;
bool transaction_duplicate; bool transaction_duplicate;
bool transaction_duplicate2;
bool need_update = false; bool need_update = false;
bool need_update2 = false;
struct GNUNET_TIME_Timestamp reserve_expiration struct GNUNET_TIME_Timestamp reserve_expiration
= GNUNET_TIME_relative_to_timestamp (pg->idle_reserve_expiration_time); = GNUNET_TIME_relative_to_timestamp (pg->idle_reserve_expiration_time);
bool conflicts[reserves_length]; bool conflicts[reserves_length];
bool conflicts2[reserves_length];
char *notify_s[reserves_length]; char *notify_s[reserves_length];
if (GNUNET_OK != if (GNUNET_OK !=
@ -82,10 +86,12 @@ TEH_PG_batch2_reserves_in_insert (void *cls,
"reserve_create", "reserve_create",
"SELECT " "SELECT "
"out_reserve_found AS conflicted" "out_reserve_found AS conflicted"
",out_reserve_found2 AS conflicted2"
",transaction_duplicate" ",transaction_duplicate"
",transaction_duplicate2"
",ruuid AS reserve_uuid" ",ruuid AS reserve_uuid"
" FROM batch2_reserves_insert" " FROM batch2_reserves_insert"
" ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17);"); " ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21);");
expiry = GNUNET_TIME_absolute_to_timestamp ( expiry = GNUNET_TIME_absolute_to_timestamp (
GNUNET_TIME_absolute_add (reserves->execution_time.abs_time, GNUNET_TIME_absolute_add (reserves->execution_time.abs_time,
pg->idle_reserve_expiration_time)); pg->idle_reserve_expiration_time));
@ -134,15 +140,21 @@ TEH_PG_batch2_reserves_in_insert (void *cls,
GNUNET_PQ_query_param_timestamp (&reserve_expiration), GNUNET_PQ_query_param_timestamp (&reserve_expiration),
GNUNET_PQ_query_param_string (notify_s[i]), GNUNET_PQ_query_param_string (notify_s[i]),
GNUNET_PQ_query_param_auto_from_type (&reserve->reserve_pub), GNUNET_PQ_query_param_auto_from_type (&reserve->reserve_pub),
GNUNET_PQ_query_param_uint64 (&reserve->wire_reference),
TALER_PQ_query_param_amount (&reserve->balance), TALER_PQ_query_param_amount (&reserve->balance),
GNUNET_PQ_query_param_timestamp (&expiry), GNUNET_PQ_query_param_string (reserve->exchange_account_name),
GNUNET_PQ_query_param_timestamp (&gc), GNUNET_PQ_query_param_timestamp (&reserve->execution_time),
GNUNET_PQ_query_param_auto_from_type (&h_payto),
GNUNET_PQ_query_param_string (reserve->sender_account_details),
GNUNET_PQ_query_param_timestamp (&reserve_expiration),
GNUNET_PQ_query_param_end GNUNET_PQ_query_param_end
}; };
struct GNUNET_PQ_ResultSpec rs[] = { struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_bool ("conflicted", GNUNET_PQ_result_spec_bool ("conflicted",
&conflicted), &conflicted),
GNUNET_PQ_result_spec_bool ("conflicted2",
&conflicted2),
GNUNET_PQ_result_spec_bool ("transaction_duplicate", GNUNET_PQ_result_spec_bool ("transaction_duplicate",
&transaction_duplicate), &transaction_duplicate),
GNUNET_PQ_result_spec_uint64 ("reserve_uuid", GNUNET_PQ_result_spec_uint64 ("reserve_uuid",
@ -171,14 +183,15 @@ TEH_PG_batch2_reserves_in_insert (void *cls,
? GNUNET_DB_STATUS_SUCCESS_NO_RESULTS ? GNUNET_DB_STATUS_SUCCESS_NO_RESULTS
: GNUNET_DB_STATUS_SUCCESS_ONE_RESULT; : GNUNET_DB_STATUS_SUCCESS_ONE_RESULT;
conflicts[i] = conflicted; conflicts[i] = conflicted;
// fprintf(stdout, "%d", conflicts[i]); conflicts2[i] = conflicted2;
if (!conflicts[i] && transaction_duplicate) // fprintf(stdout, "%d", conflicts[i]);
if (!conflicts[i] && !conflicts2[i]&& transaction_duplicate)
{ {
GNUNET_break (0); GNUNET_break (0);
TEH_PG_rollback (pg); TEH_PG_rollback (pg);
return GNUNET_DB_STATUS_HARD_ERROR; return GNUNET_DB_STATUS_HARD_ERROR;
} }
need_update |= conflicted; need_update |= conflicted |= conflicted2;
} }
// commit // commit
{ {

View File

@ -57,7 +57,7 @@ TEH_PG_get_policy_details (
}; };
return GNUNET_PQ_eval_prepared_singleton_select (pg->conn, return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
"get_policy_details", "get_policy_details",
params, params,

View File

@ -60,7 +60,7 @@
#include <pthread.h> #include <pthread.h>
#include <libpq-fe.h> #include <libpq-fe.h>
/**WHAT I ADD**/ /**NEW INCLUDES**/
#include "pg_insert_purse_request.h" #include "pg_insert_purse_request.h"
#include "pg_iterate_active_signkeys.h" #include "pg_iterate_active_signkeys.h"
#include "pg_preflight.h" #include "pg_preflight.h"
@ -483,81 +483,6 @@ libtaler_plugin_exchangedb_postgres_init (void *cls)
} }
plugin = GNUNET_new (struct TALER_EXCHANGEDB_Plugin); plugin = GNUNET_new (struct TALER_EXCHANGEDB_Plugin);
plugin->cls = pg; plugin->cls = pg;
plugin->get_policy_details = &postgres_get_policy_details;
plugin->add_policy_fulfillment_proof = &postgres_add_policy_fulfillment_proof;
plugin->do_melt = &postgres_do_melt;
plugin->do_refund = &postgres_do_refund;
plugin->do_recoup = &postgres_do_recoup;
plugin->do_recoup_refresh = &postgres_do_recoup_refresh;
plugin->get_reserve_balance = &postgres_get_reserve_balance;
plugin->count_known_coins = &postgres_count_known_coins;
plugin->ensure_coin_known = &postgres_ensure_coin_known;
plugin->get_known_coin = &postgres_get_known_coin;
plugin->get_coin_denomination = &postgres_get_coin_denomination;
plugin->have_deposit2 = &postgres_have_deposit2;
plugin->aggregate = &postgres_aggregate;
plugin->create_aggregation_transient
= &postgres_create_aggregation_transient;
plugin->select_aggregation_transient
= &postgres_select_aggregation_transient;
plugin->find_aggregation_transient
= &postgres_find_aggregation_transient;
plugin->update_aggregation_transient
= &postgres_update_aggregation_transient;
plugin->get_ready_deposit = &postgres_get_ready_deposit;
plugin->insert_deposit = &postgres_insert_deposit;
plugin->insert_refund = &postgres_insert_refund;
plugin->select_refunds_by_coin = &postgres_select_refunds_by_coin;
plugin->get_melt = &postgres_get_melt;
plugin->insert_refresh_reveal = &postgres_insert_refresh_reveal;
plugin->get_refresh_reveal = &postgres_get_refresh_reveal;
plugin->lookup_wire_transfer = &postgres_lookup_wire_transfer;
plugin->lookup_transfer_by_deposit = &postgres_lookup_transfer_by_deposit;
plugin->insert_wire_fee = &postgres_insert_wire_fee;
plugin->insert_global_fee = &postgres_insert_global_fee;
plugin->get_wire_fee = &postgres_get_wire_fee;
plugin->get_global_fee = &postgres_get_global_fee;
plugin->get_global_fees = &postgres_get_global_fees;
plugin->insert_reserve_closed = &postgres_insert_reserve_closed;
plugin->wire_prepare_data_insert = &postgres_wire_prepare_data_insert;
plugin->wire_prepare_data_mark_finished =
&postgres_wire_prepare_data_mark_finished;
plugin->wire_prepare_data_mark_failed =
&postgres_wire_prepare_data_mark_failed;
plugin->wire_prepare_data_get = &postgres_wire_prepare_data_get;
plugin->start_deferred_wire_out = &postgres_start_deferred_wire_out;
plugin->store_wire_transfer_out = &postgres_store_wire_transfer_out;
plugin->gc = &postgres_gc;
plugin->select_deposits_above_serial_id
= &postgres_select_deposits_above_serial_id;
plugin->select_history_requests_above_serial_id
= &postgres_select_history_requests_above_serial_id;
plugin->select_purse_decisions_above_serial_id
= &postgres_select_purse_decisions_above_serial_id;
plugin->select_purse_deposits_by_purse
= &postgres_select_purse_deposits_by_purse;
plugin->select_refreshes_above_serial_id
= &postgres_select_refreshes_above_serial_id;
plugin->select_refunds_above_serial_id
= &postgres_select_refunds_above_serial_id;
plugin->select_reserves_in_above_serial_id
= &postgres_select_reserves_in_above_serial_id;
plugin->select_reserves_in_above_serial_id_by_account
= &postgres_select_reserves_in_above_serial_id_by_account;
plugin->select_withdrawals_above_serial_id
= &postgres_select_withdrawals_above_serial_id;
plugin->select_wire_out_above_serial_id
= &postgres_select_wire_out_above_serial_id;
plugin->select_wire_out_above_serial_id_by_account
= &postgres_select_wire_out_above_serial_id_by_account;
plugin->select_recoup_above_serial_id
= &postgres_select_recoup_above_serial_id;
plugin->select_recoup_refresh_above_serial_id
= &postgres_select_recoup_refresh_above_serial_id;
plugin->get_reserve_by_h_blind
= &postgres_get_reserve_by_h_blind;
/* New style, sort alphabetically! */ /* New style, sort alphabetically! */
plugin->do_reserve_open plugin->do_reserve_open
= &TEH_PG_do_reserve_open; = &TEH_PG_do_reserve_open;