finish implementation for #7808
This commit is contained in:
parent
7c0de44a2b
commit
1e88796045
@ -1,6 +1,6 @@
|
||||
/*
|
||||
This file is part of TALER
|
||||
Copyright (C) 2014-2017, 2021 Taler Systems SA
|
||||
Copyright (C) 2014-2023 Taler Systems SA
|
||||
|
||||
TALER 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
|
||||
@ -347,9 +347,7 @@ handle_track_transaction_request (
|
||||
struct TALER_CoinDepositEventP rep = {
|
||||
.header.size = htons (sizeof (rep)),
|
||||
.header.type = htons (TALER_DBEVENT_EXCHANGE_DEPOSIT_STATUS_CHANGED),
|
||||
.coin_pub = ctx->coin_pub,
|
||||
.merchant_pub = ctx->merchant,
|
||||
.h_wire = ctx->h_wire
|
||||
.merchant_pub = ctx->merchant
|
||||
};
|
||||
|
||||
ctx->eh = TEH_plugin->event_listen (
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "taler_error_codes.h"
|
||||
#include "taler_dbevents.h"
|
||||
#include "taler_pq_lib.h"
|
||||
#include "pg_event_notify.h"
|
||||
#include "pg_aggregate.h"
|
||||
#include "pg_helper.h"
|
||||
|
||||
@ -35,34 +36,12 @@ TEH_PG_aggregate (
|
||||
{
|
||||
struct PostgresClosure *pg = cls;
|
||||
struct GNUNET_TIME_Absolute now = {0};
|
||||
struct GNUNET_PQ_QueryParam params[] = {
|
||||
GNUNET_PQ_query_param_absolute_time (&now),
|
||||
GNUNET_PQ_query_param_auto_from_type (merchant_pub),
|
||||
GNUNET_PQ_query_param_auto_from_type (h_payto),
|
||||
GNUNET_PQ_query_param_auto_from_type (wtid),
|
||||
GNUNET_PQ_query_param_end
|
||||
};
|
||||
uint64_t sum_deposit_value;
|
||||
uint64_t sum_deposit_frac;
|
||||
uint64_t sum_refund_value;
|
||||
uint64_t sum_refund_frac;
|
||||
uint64_t sum_fee_value;
|
||||
uint64_t sum_fee_frac;
|
||||
struct GNUNET_PQ_ResultSpec rs[] = {
|
||||
GNUNET_PQ_result_spec_uint64 ("sum_deposit_value",
|
||||
&sum_deposit_value),
|
||||
GNUNET_PQ_result_spec_uint64 ("sum_deposit_fraction",
|
||||
&sum_deposit_frac),
|
||||
GNUNET_PQ_result_spec_uint64 ("sum_refund_value",
|
||||
&sum_refund_value),
|
||||
GNUNET_PQ_result_spec_uint64 ("sum_refund_fraction",
|
||||
&sum_refund_frac),
|
||||
GNUNET_PQ_result_spec_uint64 ("sum_fee_value",
|
||||
&sum_fee_value),
|
||||
GNUNET_PQ_result_spec_uint64 ("sum_fee_fraction",
|
||||
&sum_fee_frac),
|
||||
GNUNET_PQ_result_spec_end
|
||||
};
|
||||
enum GNUNET_DB_QueryStatus qs;
|
||||
struct TALER_Amount sum_deposit;
|
||||
struct TALER_Amount sum_refund;
|
||||
@ -71,8 +50,6 @@ TEH_PG_aggregate (
|
||||
|
||||
now = GNUNET_TIME_absolute_round_down (GNUNET_TIME_absolute_get (),
|
||||
pg->aggregator_shift);
|
||||
|
||||
/* Used in #postgres_aggregate() */
|
||||
PREPARE (pg,
|
||||
"aggregate",
|
||||
"WITH dep AS (" /* restrict to our merchant and account and mark as done */
|
||||
@ -148,11 +125,35 @@ TEH_PG_aggregate (
|
||||
" FULL OUTER JOIN ref ON (FALSE)" /* We just want all sums */
|
||||
" FULL OUTER JOIN fees ON (FALSE);");
|
||||
|
||||
{
|
||||
struct GNUNET_PQ_QueryParam params[] = {
|
||||
GNUNET_PQ_query_param_absolute_time (&now),
|
||||
GNUNET_PQ_query_param_auto_from_type (merchant_pub),
|
||||
GNUNET_PQ_query_param_auto_from_type (h_payto),
|
||||
GNUNET_PQ_query_param_auto_from_type (wtid),
|
||||
GNUNET_PQ_query_param_end
|
||||
};
|
||||
struct GNUNET_PQ_ResultSpec rs[] = {
|
||||
GNUNET_PQ_result_spec_uint64 ("sum_deposit_value",
|
||||
&sum_deposit_value),
|
||||
GNUNET_PQ_result_spec_uint64 ("sum_deposit_fraction",
|
||||
&sum_deposit_frac),
|
||||
GNUNET_PQ_result_spec_uint64 ("sum_refund_value",
|
||||
&sum_refund_value),
|
||||
GNUNET_PQ_result_spec_uint64 ("sum_refund_fraction",
|
||||
&sum_refund_frac),
|
||||
GNUNET_PQ_result_spec_uint64 ("sum_fee_value",
|
||||
&sum_fee_value),
|
||||
GNUNET_PQ_result_spec_uint64 ("sum_fee_fraction",
|
||||
&sum_fee_frac),
|
||||
GNUNET_PQ_result_spec_end
|
||||
};
|
||||
|
||||
qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
|
||||
"aggregate",
|
||||
params,
|
||||
rs);
|
||||
qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
|
||||
"aggregate",
|
||||
params,
|
||||
rs);
|
||||
}
|
||||
if (qs < 0)
|
||||
{
|
||||
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
|
||||
@ -165,6 +166,18 @@ TEH_PG_aggregate (
|
||||
total));
|
||||
return qs;
|
||||
}
|
||||
{
|
||||
struct TALER_CoinDepositEventP rep = {
|
||||
.header.size = htons (sizeof (rep)),
|
||||
.header.type = htons (TALER_DBEVENT_EXCHANGE_DEPOSIT_STATUS_CHANGED),
|
||||
.merchant_pub = *merchant_pub
|
||||
};
|
||||
|
||||
TEH_PG_event_notify (pg,
|
||||
&rep.header,
|
||||
NULL,
|
||||
0);
|
||||
}
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_amount_set_zero (pg->currency,
|
||||
&sum_deposit));
|
||||
|
@ -3546,6 +3546,7 @@ typedef void
|
||||
* @param h_wire hash of merchant's wire transfer details
|
||||
* @param h_contract_terms hash of the proposal data
|
||||
* @param coin_pub public key of the coin
|
||||
* @param timeout timeout to use for long-polling, 0 for no long polling
|
||||
* @param cb function to call with the result
|
||||
* @param cb_cls closure for @a cb
|
||||
* @return handle to abort request
|
||||
@ -3557,6 +3558,7 @@ TALER_EXCHANGE_deposits_get (
|
||||
const struct TALER_MerchantWireHashP *h_wire,
|
||||
const struct TALER_PrivateContractHashP *h_contract_terms,
|
||||
const struct TALER_CoinSpendPublicKeyP *coin_pub,
|
||||
struct GNUNET_TIME_Relative timeout,
|
||||
TALER_EXCHANGE_DepositGetCallback cb,
|
||||
void *cb_cls);
|
||||
|
||||
|
@ -160,20 +160,10 @@ struct TALER_CoinDepositEventP
|
||||
struct GNUNET_DB_EventHeaderP header;
|
||||
|
||||
/**
|
||||
* The coin's public key.
|
||||
*/
|
||||
struct TALER_CoinSpendPublicKeyP coin_pub;
|
||||
|
||||
/**
|
||||
* The Merchant's public key.
|
||||
* Public key of the merchant.
|
||||
*/
|
||||
struct TALER_MerchantPublicKeyP merchant_pub;
|
||||
|
||||
/**
|
||||
* Hash over the wiring information of the merchant.
|
||||
*/
|
||||
struct TALER_MerchantWireHashP h_wire;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
This file is part of TALER
|
||||
Copyright (C) 2014-2021 Taler Systems SA
|
||||
Copyright (C) 2014-2023 Taler Systems SA
|
||||
|
||||
TALER is free software; you can redistribute it and/or modify it under the
|
||||
terms of the GNU General Public License as published by the Free Software
|
||||
@ -260,6 +260,7 @@ TALER_EXCHANGE_deposits_get (
|
||||
const struct TALER_MerchantWireHashP *h_wire,
|
||||
const struct TALER_PrivateContractHashP *h_contract_terms,
|
||||
const struct TALER_CoinSpendPublicKeyP *coin_pub,
|
||||
struct GNUNET_TIME_Relative timeout,
|
||||
TALER_EXCHANGE_DepositGetCallback cb,
|
||||
void *cb_cls)
|
||||
{
|
||||
@ -293,6 +294,7 @@ TALER_EXCHANGE_deposits_get (
|
||||
char msig_str[sizeof (struct TALER_MerchantSignatureP) * 2];
|
||||
char chash_str[sizeof (struct TALER_PrivateContractHashP) * 2];
|
||||
char whash_str[sizeof (struct TALER_MerchantWireHashP) * 2];
|
||||
char timeout_str[24];
|
||||
char *end;
|
||||
|
||||
end = GNUNET_STRINGS_data_to_string (h_wire,
|
||||
@ -320,15 +322,33 @@ TALER_EXCHANGE_deposits_get (
|
||||
msig_str,
|
||||
sizeof (msig_str));
|
||||
*end = '\0';
|
||||
if (GNUNET_TIME_relative_is_zero (timeout))
|
||||
{
|
||||
timeout_str[0] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
GNUNET_snprintf (
|
||||
timeout_str,
|
||||
sizeof (timeout_str),
|
||||
"%llu",
|
||||
(unsigned long long) (
|
||||
timeout.rel_value_us
|
||||
/ GNUNET_TIME_UNIT_MILLISECONDS.rel_value_us));
|
||||
}
|
||||
|
||||
GNUNET_snprintf (arg_str,
|
||||
sizeof (arg_str),
|
||||
"/deposits/%s/%s/%s/%s?merchant_sig=%s",
|
||||
"/deposits/%s/%s/%s/%s?merchant_sig=%s%s%s",
|
||||
whash_str,
|
||||
mpub_str,
|
||||
chash_str,
|
||||
cpub_str,
|
||||
msig_str);
|
||||
msig_str,
|
||||
GNUNET_TIME_relative_is_zero (timeout)
|
||||
? ""
|
||||
: "&timeout_ms=",
|
||||
timeout_str);
|
||||
}
|
||||
|
||||
dwh = GNUNET_new (struct TALER_EXCHANGE_DepositGetHandle);
|
||||
|
@ -281,6 +281,7 @@ track_transaction_run (void *cls,
|
||||
&h_wire_details,
|
||||
&h_contract_terms,
|
||||
&coin_pub,
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
&deposit_wtid_cb,
|
||||
tts);
|
||||
GNUNET_assert (NULL != tts->tth);
|
||||
|
Loading…
Reference in New Issue
Block a user