summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-11-29 10:09:21 +0100
committerChristian Grothoff <christian@grothoff.org>2021-11-29 10:09:21 +0100
commitc8480d97a17e1ab8f358dadc48e6e9b3ea17f6da (patch)
tree6368e671458533a604df6b214d5decff9bd7457f /src
parent65533e8df5ea5ebf25bd9ae04186a475057efa9e (diff)
downloadexchange-c8480d97a17e1ab8f358dadc48e6e9b3ea17f6da.tar.gz
exchange-c8480d97a17e1ab8f358dadc48e6e9b3ea17f6da.tar.bz2
exchange-c8480d97a17e1ab8f358dadc48e6e9b3ea17f6da.zip
try to optimize aggregator queries
Diffstat (limited to 'src')
-rw-r--r--src/exchangedb/exchange-0001.sql13
-rw-r--r--src/exchangedb/plugin_exchangedb_postgres.c22
-rw-r--r--src/lib/exchange_api_deposits_get.c3
3 files changed, 20 insertions, 18 deletions
diff --git a/src/exchangedb/exchange-0001.sql b/src/exchangedb/exchange-0001.sql
index 4a6c9afb5..7acd67244 100644
--- a/src/exchangedb/exchange-0001.sql
+++ b/src/exchangedb/exchange-0001.sql
@@ -378,7 +378,7 @@ COMMENT ON COLUMN extension_details.extension_options
CREATE TABLE IF NOT EXISTS deposits
(deposit_serial_id BIGSERIAL PRIMARY KEY
- ,shard INT8 NOT NULL DEFAULT 0
+ ,shard INT8 NOT NULL
,known_coin_id INT8 NOT NULL REFERENCES known_coins (known_coin_id) ON DELETE CASCADE
,amount_with_fee_val INT8 NOT NULL
,amount_with_fee_frac INT4 NOT NULL
@@ -400,7 +400,7 @@ CREATE TABLE IF NOT EXISTS deposits
COMMENT ON TABLE deposits
IS 'Deposits we have received and for which we need to make (aggregate) wire transfers (and manage refunds).';
COMMENT ON COLUMN deposits.shard
- IS 'Used for load sharding. Should be set based on h_payto and merchant_pub. Default of 0 onlyapplies for columns migrated from a previous version without sharding support. 64-bit value because we need an *unsigned* 32-bit value.';
+ IS 'Used for load sharding. Should be set based on h_payto and merchant_pub. 64-bit value because we need an *unsigned* 32-bit value.';
COMMENT ON COLUMN deposits.wire_target_serial_id
IS 'Identifies the target bank account and KYC status';COMMENT ON COLUMN deposits.wire_salt
IS 'Salt used when hashing the payto://-URI to get the h_wire';
@@ -423,12 +423,11 @@ COMMENT ON INDEX deposits_coin_pub_merchant_contract_index
IS 'for get_deposit_for_wtid and test_deposit_done';
CREATE INDEX IF NOT EXISTS deposits_get_ready_index
ON deposits
- (shard
- ,wire_deadline
- ,refund_deadline
- ,tiny
+ (shard ASC
,done
,extension_blocked
+ ,tiny
+ ,wire_deadline ASC
);
COMMENT ON INDEX deposits_coin_pub_merchant_contract_index
IS 'for deposits_get_ready';
@@ -438,7 +437,7 @@ CREATE INDEX IF NOT EXISTS deposits_iterate_matching_index
,wire_target_serial_id
,done
,extension_blocked
- ,wire_deadline
+ ,refund_deadline ASC
);
COMMENT ON INDEX deposits_iterate_matching_index
IS 'for deposits_iterate_matching';
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c
index 3591470e7..004516c51 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -1105,10 +1105,10 @@ prepare_statements (struct PostgresClosure *pg)
" WHERE "
" shard >= $2"
" AND shard <= $3"
- " AND wire_deadline<=$1"
- " AND refund_deadline<$1"
- " AND tiny=FALSE"
" AND done=FALSE"
+ " AND extension_blocked=FALSE"
+ " AND tiny=FALSE"
+ " AND wire_deadline<=$1"
" AND (kyc_ok OR $4)"
" ORDER BY "
" shard ASC"
@@ -1130,14 +1130,16 @@ prepare_statements (struct PostgresClosure *pg)
" JOIN known_coins kc USING (known_coin_id)"
" JOIN denominations denom USING (denominations_serial)"
" WHERE"
- " merchant_pub=$1 AND"
- " wire_target_serial_id=$2 AND"
- " done=FALSE"
- " ORDER BY wire_deadline ASC"
+ " merchant_pub=$1"
+ " AND wire_target_serial_id=$2"
+ " AND done=FALSE"
+ " AND extension_blocked=FALSE"
+ " AND refund_deadline<$3"
+ " ORDER BY refund_deadline ASC"
" LIMIT "
TALER_QUOTE (
TALER_EXCHANGEDB_MATCHING_DEPOSITS_LIMIT) ";",
- 2),
+ 3),
/* Used in #postgres_mark_deposit_tiny() */
GNUNET_PQ_make_prepare (
"mark_deposit_tiny",
@@ -5505,9 +5507,11 @@ postgres_iterate_matching_deposits (
uint32_t limit)
{
struct PostgresClosure *pg = cls;
+ struct GNUNET_TIME_Absolute now;
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (merchant_pub),
GNUNET_PQ_query_param_uint64 (&wire_target),
+ GNUNET_PQ_query_param_absolute_time (&now),
GNUNET_PQ_query_param_end
};
struct MatchingDepositContext mdc = {
@@ -5520,6 +5524,8 @@ postgres_iterate_matching_deposits (
};
enum GNUNET_DB_QueryStatus qs;
+ now = GNUNET_TIME_absolute_get ();
+ (void) GNUNET_TIME_round_abs (&now);
qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
"deposits_iterate_matching",
params,
diff --git a/src/lib/exchange_api_deposits_get.c b/src/lib/exchange_api_deposits_get.c
index 843b00ff3..3c334d760 100644
--- a/src/lib/exchange_api_deposits_get.c
+++ b/src/lib/exchange_api_deposits_get.c
@@ -83,7 +83,6 @@ struct TALER_EXCHANGE_DepositGetHandle
* from the exchange is valid.
*
* @param dwh deposit wtid handle
- * @param json json reply with the signature
* @param exchange_pub the exchange's public key
* @param exchange_sig the exchange's signature
* @return #GNUNET_OK if the signature is valid, #GNUNET_SYSERR if not
@@ -91,7 +90,6 @@ struct TALER_EXCHANGE_DepositGetHandle
static enum GNUNET_GenericReturnValue
verify_deposit_wtid_signature_ok (
const struct TALER_EXCHANGE_DepositGetHandle *dwh,
- const json_t *json,
const struct TALER_ExchangePublicKeyP *exchange_pub,
const struct TALER_ExchangeSignatureP *exchange_sig)
{
@@ -177,7 +175,6 @@ handle_deposit_wtid_finished (void *cls,
&dr.details.success.coin_contribution);
if (GNUNET_OK !=
verify_deposit_wtid_signature_ok (dwh,
- j,
&dr.details.success.exchange_pub,
&dr.details.success.exchange_sig))
{