commit 73126db2037973810e4b87661c5cd3d1e9804b73
parent 99574aca92b87cfce6318fa7d2c013ed98a6c64e
Author: Christian Grothoff <christian@grothoff.org>
Date: Sat, 10 Oct 2026 00:15:13 +0200
fix DB join, use shard properly
Diffstat:
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/exchangedb/get_wire_hash_for_contract.c b/src/exchangedb/get_wire_hash_for_contract.c
@@ -21,6 +21,7 @@
#include "exchangedb_lib.h"
#include "taler/taler_pq_lib.h"
#include "exchange-database/get_wire_hash_for_contract.h"
+#include "exchange-database/compute_shard.h"
#include "helper.h"
@@ -32,7 +33,9 @@ TALER_EXCHANGEDB_get_wire_hash_for_contract (
struct TALER_MerchantWireHashP *h_wire)
{
enum GNUNET_DB_QueryStatus qs;
+ uint64_t deposit_shard = TALER_EXCHANGEDB_compute_shard (merchant_pub);
struct GNUNET_PQ_QueryParam params[] = {
+ GNUNET_PQ_query_param_uint64 (&deposit_shard),
GNUNET_PQ_query_param_auto_from_type (merchant_pub),
GNUNET_PQ_query_param_auto_from_type (h_contract_terms),
GNUNET_PQ_query_param_end
@@ -47,21 +50,18 @@ TALER_EXCHANGEDB_get_wire_hash_for_contract (
GNUNET_PQ_result_spec_end
};
- /* check if the necessary records exist and get them */
+ /* (shard, merchant_pub, h_contract_terms) is unique in batch_deposits */
PREPARE (pg,
"get_wire_hash_for_contract",
"SELECT"
" bdep.wire_salt"
" ,wt.payto_uri"
- " FROM coin_deposits"
- " JOIN batch_deposits bdep"
- " USING (batch_deposit_serial_id)"
+ " FROM batch_deposits bdep"
" JOIN wire_targets wt"
" USING (wire_target_h_payto)"
- " WHERE bdep.merchant_pub=$1"
- " AND bdep.h_contract_terms=$2");
- /* NOTE: above query might be more efficient if we computed the shard
- from the merchant_pub and included that in the query */
+ " WHERE bdep.shard=$1"
+ " AND bdep.merchant_pub=$2"
+ " AND bdep.h_contract_terms=$3");
qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
"get_wire_hash_for_contract",
params,