summaryrefslogtreecommitdiff
path: root/src/exchange
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-03-03 23:52:08 +0100
committerChristian Grothoff <christian@grothoff.org>2022-03-03 23:52:08 +0100
commit1643b745af309f754959621fa2a631c899ba1975 (patch)
tree19d6252ad82a78e432b8c969b948a7e0cb36c33b /src/exchange
parentf951cdef8ced141326887c1a996e8546774514f6 (diff)
downloadexchange-1643b745af309f754959621fa2a631c899ba1975.tar.gz
exchange-1643b745af309f754959621fa2a631c899ba1975.tar.bz2
exchange-1643b745af309f754959621fa2a631c899ba1975.zip
use 32 byte hash for hpayto, use that for joins on queries to better align queries with partitions
Diffstat (limited to 'src/exchange')
-rw-r--r--src/exchange/taler-exchange-aggregator.c11
-rw-r--r--src/exchange/taler-exchange-httpd_kyc-check.c30
-rw-r--r--src/exchange/taler-exchange-httpd_kyc-proof.c21
3 files changed, 34 insertions, 28 deletions
diff --git a/src/exchange/taler-exchange-aggregator.c b/src/exchange/taler-exchange-aggregator.c
index 58bf20738..40653f9b9 100644
--- a/src/exchange/taler-exchange-aggregator.c
+++ b/src/exchange/taler-exchange-aggregator.c
@@ -81,6 +81,11 @@ struct AggregationUnit
/**
* Selected wire target for the aggregation.
*/
+ struct TALER_PaytoHashP h_payto;
+
+ /**
+ * Serial number of the wire target.
+ */
uint64_t wire_target;
/**
@@ -426,6 +431,8 @@ deposit_cb (void *cls,
GNUNET_assert (NULL == au->payto_uri);
au->payto_uri = GNUNET_strdup (payto_uri);
+ TALER_payto_hash (payto_uri,
+ &au->h_payto);
au->wire_target = wire_target;
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
&au->wtid,
@@ -775,7 +782,7 @@ run_aggregation (void *cls)
TALER_B2S (&au_active.merchant_pub),
(unsigned long long) au_active.wire_target);
qs = db_plugin->iterate_matching_deposits (db_plugin->cls,
- au_active.wire_target,
+ &au_active.h_payto,
&au_active.merchant_pub,
&aggregate_cb,
&au_active,
@@ -918,7 +925,7 @@ run_aggregation (void *cls)
qs = db_plugin->store_wire_transfer_out (db_plugin->cls,
au_active.execution_time,
&au_active.wtid,
- au_active.wire_target,
+ &au_active.h_payto,
au_active.wa->section_name,
&au_active.final_amount);
cleanup_au (&au_active);
diff --git a/src/exchange/taler-exchange-httpd_kyc-check.c b/src/exchange/taler-exchange-httpd_kyc-check.c
index 1e7f4da12..ba9186866 100644
--- a/src/exchange/taler-exchange-httpd_kyc-check.c
+++ b/src/exchange/taler-exchange-httpd_kyc-check.c
@@ -60,11 +60,16 @@ struct KycPoller
struct GNUNET_DB_EventHandler *eh;
/**
- * UUID being checked.
+ * UUID found based on @e h_payto.
*/
uint64_t payment_target_uuid;
/**
+ * UUID being checked.
+ */
+ uint64_t auth_payment_target_uuid;
+
+ /**
* Current KYC status.
*/
struct TALER_EXCHANGEDB_KycStatus kyc;
@@ -76,11 +81,6 @@ struct KycPoller
struct TALER_PaytoHashP h_payto;
/**
- * Hash of the payto:// URI that was given to us for auth.
- */
- struct TALER_PaytoHashP auth_h_payto;
-
- /**
* When will this request time out?
*/
struct GNUNET_TIME_Absolute timeout;
@@ -170,7 +170,6 @@ kyc_check (void *cls,
enum GNUNET_DB_QueryStatus qs;
qs = TEH_plugin->select_kyc_status (TEH_plugin->cls,
- kyp->payment_target_uuid,
&kyp->h_payto,
&kyp->kyc);
if (qs < 0)
@@ -184,6 +183,9 @@ kyc_check (void *cls,
"inselect_wallet_status");
return qs;
}
+ // FIXME: avoid duplicating this...
+ kyp->payment_target_uuid = kyp->kyc.payment_target_uuid;
+
return qs;
}
@@ -261,7 +263,7 @@ TEH_handler_kyc_check (
TALER_EC_GENERIC_PARAMETER_MALFORMED,
"payment_target_uuid");
}
- kyp->payment_target_uuid = (uint64_t) payment_target_uuid;
+ kyp->auth_payment_target_uuid = (uint64_t) payment_target_uuid;
}
{
const char *ts;
@@ -308,8 +310,8 @@ TEH_handler_kyc_check (
if (GNUNET_OK !=
GNUNET_STRINGS_string_to_data (hps,
strlen (hps),
- &kyp->auth_h_payto,
- sizeof (kyp->auth_h_payto)))
+ &kyp->h_payto,
+ sizeof (kyp->h_payto)))
{
GNUNET_break_op (0);
return TALER_MHD_reply_with_error (rc->connection,
@@ -334,7 +336,7 @@ TEH_handler_kyc_check (
struct TALER_KycCompletedEventP rep = {
.header.size = htons (sizeof (rep)),
.header.type = htons (TALER_DBEVENT_EXCHANGE_KYC_COMPLETED),
- .h_payto = kyp->auth_h_payto
+ .h_payto = kyp->h_payto
};
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -356,9 +358,9 @@ TEH_handler_kyc_check (
kyp);
if (GNUNET_SYSERR == ret)
return res;
- if (0 !=
- GNUNET_memcmp (&kyp->h_payto,
- &kyp->auth_h_payto))
+
+ if (kyp->auth_payment_target_uuid !=
+ kyp->payment_target_uuid)
{
GNUNET_break_op (0);
return TALER_MHD_reply_with_error (rc->connection,
diff --git a/src/exchange/taler-exchange-httpd_kyc-proof.c b/src/exchange/taler-exchange-httpd_kyc-proof.c
index 24ddfc74d..333bd733b 100644
--- a/src/exchange/taler-exchange-httpd_kyc-proof.c
+++ b/src/exchange/taler-exchange-httpd_kyc-proof.c
@@ -78,9 +78,9 @@ struct KycProofContext
char *id;
/**
- * Payment target this is about.
+ * Hash of payment target URI this is about.
*/
- unsigned long long payment_target_uuid;
+ struct TALER_PaytoHashP h_payto;
/**
* HTTP response to return.
@@ -171,7 +171,7 @@ persist_kyc_ok (void *cls,
enum GNUNET_DB_QueryStatus qs;
qs = TEH_plugin->set_kyc_ok (TEH_plugin->cls,
- kpc->payment_target_uuid,
+ &kpc->h_payto,
kpc->id);
if (GNUNET_DB_STATUS_HARD_ERROR == qs)
{
@@ -530,24 +530,21 @@ TEH_handler_kyc_proof (
if (NULL == kpc)
{ /* first time */
- char dummy;
-
kpc = GNUNET_new (struct KycProofContext);
kpc->rc = rc;
rc->rh_ctx = kpc;
rc->rh_cleaner = &clean_kpc;
-
- if (1 !=
- sscanf (args[0],
- "%llu%c",
- &kpc->payment_target_uuid,
- &dummy))
+ if (GNUNET_OK !=
+ GNUNET_STRINGS_string_to_data (args[0],
+ strlen (args[0]),
+ &kpc->h_payto,
+ sizeof (kpc->h_payto)))
{
GNUNET_break_op (0);
return TALER_MHD_reply_with_error (rc->connection,
MHD_HTTP_BAD_REQUEST,
TALER_EC_GENERIC_PARAMETER_MALFORMED,
- "payment_target_uuid");
+ "h_payto");
}
kpc->authorization_code
= MHD_lookup_connection_value (rc->connection,