-implement long-standing aggregation SQL query simplification

This commit is contained in:
Christian Grothoff 2021-09-03 09:55:16 +02:00
parent bed08b39d0
commit 6e1877b142
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
3 changed files with 0 additions and 29 deletions

View File

@ -302,8 +302,6 @@ refund_by_coin_cb (void *cls,
* *
* @param cls a `struct AggregationUnit` * @param cls a `struct AggregationUnit`
* @param row_id identifies database entry * @param row_id identifies database entry
* @param exchange_timestamp when did the deposit happen
* @param wallet_timestamp when did the contract happen
* @param merchant_pub public key of the merchant * @param merchant_pub public key of the merchant
* @param coin_pub public key of the coin * @param coin_pub public key of the coin
* @param amount_with_fee amount that was deposited including fee * @param amount_with_fee amount that was deposited including fee
@ -311,30 +309,21 @@ refund_by_coin_cb (void *cls,
* @param h_contract_terms hash of the proposal data known to merchant and customer * @param h_contract_terms hash of the proposal data known to merchant and customer
* @param wire_deadline by which the merchant advised that he would like the * @param wire_deadline by which the merchant advised that he would like the
* wire transfer to be executed * wire transfer to be executed
* @param wire wire details for the merchant
* @return transaction status code, #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT to continue to iterate * @return transaction status code, #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT to continue to iterate
*/ */
static enum GNUNET_DB_QueryStatus static enum GNUNET_DB_QueryStatus
deposit_cb (void *cls, deposit_cb (void *cls,
uint64_t row_id, uint64_t row_id,
struct GNUNET_TIME_Absolute exchange_timestamp,
struct GNUNET_TIME_Absolute wallet_timestamp,
const struct TALER_MerchantPublicKeyP *merchant_pub, const struct TALER_MerchantPublicKeyP *merchant_pub,
const struct TALER_CoinSpendPublicKeyP *coin_pub, const struct TALER_CoinSpendPublicKeyP *coin_pub,
const struct TALER_Amount *amount_with_fee, const struct TALER_Amount *amount_with_fee,
const struct TALER_Amount *deposit_fee, const struct TALER_Amount *deposit_fee,
const struct GNUNET_HashCode *h_contract_terms, const struct GNUNET_HashCode *h_contract_terms,
struct GNUNET_TIME_Absolute wire_deadline,
const json_t *wire) const json_t *wire)
{ {
struct AggregationUnit *au = cls; struct AggregationUnit *au = cls;
enum GNUNET_DB_QueryStatus qs; enum GNUNET_DB_QueryStatus qs;
/* NOTE: potential optimization: use custom SQL API to not
fetch this one: */
(void) wire_deadline; /* already checked by SQL query */
(void) exchange_timestamp;
(void) wallet_timestamp;
au->merchant_pub = *merchant_pub; au->merchant_pub = *merchant_pub;
GNUNET_log (GNUNET_ERROR_TYPE_INFO, GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Aggregator processing payment %s with amount %s\n", "Aggregator processing payment %s with amount %s\n",

View File

@ -951,13 +951,10 @@ prepare_statements (struct PostgresClosure *pg)
",amount_with_fee_frac" ",amount_with_fee_frac"
",denom.fee_deposit_val" ",denom.fee_deposit_val"
",denom.fee_deposit_frac" ",denom.fee_deposit_frac"
",wire_deadline"
",h_contract_terms" ",h_contract_terms"
",wire" ",wire"
",merchant_pub" ",merchant_pub"
",kc.coin_pub" ",kc.coin_pub"
",exchange_timestamp"
",wallet_timestamp"
" FROM deposits" " FROM deposits"
" JOIN known_coins kc USING (known_coin_id)" " JOIN known_coins kc USING (known_coin_id)"
" JOIN denominations denom USING (denominations_serial)" " JOIN denominations denom USING (denominations_serial)"
@ -4482,9 +4479,6 @@ postgres_get_ready_deposit (void *cls,
}; };
struct TALER_Amount amount_with_fee; struct TALER_Amount amount_with_fee;
struct TALER_Amount deposit_fee; struct TALER_Amount deposit_fee;
struct GNUNET_TIME_Absolute wire_deadline;
struct GNUNET_TIME_Absolute wallet_timestamp;
struct GNUNET_TIME_Absolute exchange_timestamp;
struct GNUNET_HashCode h_contract_terms; struct GNUNET_HashCode h_contract_terms;
struct TALER_MerchantPublicKeyP merchant_pub; struct TALER_MerchantPublicKeyP merchant_pub;
struct TALER_CoinSpendPublicKeyP coin_pub; struct TALER_CoinSpendPublicKeyP coin_pub;
@ -4497,12 +4491,6 @@ postgres_get_ready_deposit (void *cls,
&amount_with_fee), &amount_with_fee),
TALER_PQ_RESULT_SPEC_AMOUNT ("fee_deposit", TALER_PQ_RESULT_SPEC_AMOUNT ("fee_deposit",
&deposit_fee), &deposit_fee),
TALER_PQ_result_spec_absolute_time ("exchange_timestamp",
&exchange_timestamp),
TALER_PQ_result_spec_absolute_time ("wallet_timestamp",
&wallet_timestamp),
TALER_PQ_result_spec_absolute_time ("wire_deadline",
&wire_deadline),
GNUNET_PQ_result_spec_auto_from_type ("h_contract_terms", GNUNET_PQ_result_spec_auto_from_type ("h_contract_terms",
&h_contract_terms), &h_contract_terms),
GNUNET_PQ_result_spec_auto_from_type ("merchant_pub", GNUNET_PQ_result_spec_auto_from_type ("merchant_pub",
@ -4530,14 +4518,11 @@ postgres_get_ready_deposit (void *cls,
qs = deposit_cb (deposit_cb_cls, qs = deposit_cb (deposit_cb_cls,
serial_id, serial_id,
exchange_timestamp,
wallet_timestamp,
&merchant_pub, &merchant_pub,
&coin_pub, &coin_pub,
&amount_with_fee, &amount_with_fee,
&deposit_fee, &deposit_fee,
&h_contract_terms, &h_contract_terms,
wire_deadline,
wire); wire);
GNUNET_PQ_cleanup_result (rs); GNUNET_PQ_cleanup_result (rs);
return qs; return qs;

View File

@ -1489,14 +1489,11 @@ typedef enum GNUNET_DB_QueryStatus
(*TALER_EXCHANGEDB_DepositIterator)( (*TALER_EXCHANGEDB_DepositIterator)(
void *cls, void *cls,
uint64_t rowid, uint64_t rowid,
struct GNUNET_TIME_Absolute exchange_timestamp,
struct GNUNET_TIME_Absolute wallet_timestamp,
const struct TALER_MerchantPublicKeyP *merchant_pub, const struct TALER_MerchantPublicKeyP *merchant_pub,
const struct TALER_CoinSpendPublicKeyP *coin_pub, const struct TALER_CoinSpendPublicKeyP *coin_pub,
const struct TALER_Amount *amount_with_fee, const struct TALER_Amount *amount_with_fee,
const struct TALER_Amount *deposit_fee, const struct TALER_Amount *deposit_fee,
const struct GNUNET_HashCode *h_contract_terms, const struct GNUNET_HashCode *h_contract_terms,
struct GNUNET_TIME_Absolute wire_deadline,
const json_t *receiver_wire_account); const json_t *receiver_wire_account);