aboutsummaryrefslogtreecommitdiff
path: root/src/exchangedb
diff options
context:
space:
mode:
Diffstat (limited to 'src/exchangedb')
-rw-r--r--src/exchangedb/plugin_exchangedb_postgres.c23
-rw-r--r--src/exchangedb/test_exchangedb.c59
2 files changed, 53 insertions, 29 deletions
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c
index dede901f9..98b3c170b 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -908,9 +908,6 @@ postgres_get_session (void *cls)
",amount_with_fee_frac"
",denom.fee_deposit_val"
",denom.fee_deposit_frac"
- ",wire_deadline"
- ",exchange_timestamp"
- ",wallet_timestamp"
",h_contract_terms"
",coin_pub"
" FROM deposits"
@@ -2868,7 +2865,7 @@ struct MatchingDepositContext
/**
* Function to call for each result
*/
- TALER_EXCHANGEDB_DepositIterator deposit_cb;
+ TALER_EXCHANGEDB_MatchingDepositIterator deposit_cb;
/**
* Closure for @e deposit_cb.
@@ -2929,9 +2926,6 @@ match_deposit_cb (void *cls,
{
struct TALER_Amount amount_with_fee;
struct TALER_Amount deposit_fee;
- struct GNUNET_TIME_Absolute exchange_timestamp;
- struct GNUNET_TIME_Absolute wallet_timestamp;
- struct GNUNET_TIME_Absolute wire_deadline;
struct GNUNET_HashCode h_contract_terms;
struct TALER_CoinSpendPublicKeyP coin_pub;
uint64_t serial_id;
@@ -2943,12 +2937,6 @@ match_deposit_cb (void *cls,
&amount_with_fee),
TALER_PQ_RESULT_SPEC_AMOUNT ("fee_deposit",
&deposit_fee),
- TALER_PQ_result_spec_absolute_time ("wire_deadline",
- &wire_deadline),
- TALER_PQ_result_spec_absolute_time ("exchange_timestamp",
- &exchange_timestamp),
- TALER_PQ_result_spec_absolute_time ("wallet_timestamp",
- &wallet_timestamp),
GNUNET_PQ_result_spec_auto_from_type ("h_contract_terms",
&h_contract_terms),
GNUNET_PQ_result_spec_auto_from_type ("coin_pub",
@@ -2967,15 +2955,10 @@ match_deposit_cb (void *cls,
}
qs = mdc->deposit_cb (mdc->deposit_cb_cls,
serial_id,
- exchange_timestamp,
- wallet_timestamp,
- mdc->merchant_pub,
&coin_pub,
&amount_with_fee,
&deposit_fee,
- &h_contract_terms,
- wire_deadline,
- NULL);
+ &h_contract_terms);
GNUNET_PQ_cleanup_result (rs);
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs)
break;
@@ -3003,7 +2986,7 @@ postgres_iterate_matching_deposits (
struct TALER_EXCHANGEDB_Session *session,
const struct GNUNET_HashCode *h_wire,
const struct TALER_MerchantPublicKeyP *merchant_pub,
- TALER_EXCHANGEDB_DepositIterator deposit_cb,
+ TALER_EXCHANGEDB_MatchingDepositIterator deposit_cb,
void *deposit_cb_cls,
uint32_t limit)
{
diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c
index 043095e7b..8567c87cb 100644
--- a/src/exchangedb/test_exchangedb.c
+++ b/src/exchangedb/test_exchangedb.c
@@ -842,7 +842,7 @@ static uint64_t deposit_rowid;
* @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
* wire transfer to be executed
- * @param wire wire details for the merchant, NULL from iterate_matching_deposits()
+ * @param wire wire details for the merchant
* @return transaction status code, #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT to continue to iterate
*/
static enum GNUNET_DB_QueryStatus
@@ -862,10 +862,9 @@ deposit_cb (void *cls,
struct GNUNET_HashCode h_wire;
deposit_rowid = rowid;
- if (NULL != wire)
- GNUNET_assert (GNUNET_OK ==
- TALER_JSON_merchant_wire_signature_hash (wire,
- &h_wire));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_JSON_merchant_wire_signature_hash (wire,
+ &h_wire));
if ( (0 != GNUNET_memcmp (merchant_pub,
&deposit->merchant_pub)) ||
(0 != TALER_amount_cmp (amount_with_fee,
@@ -877,9 +876,51 @@ deposit_cb (void *cls,
(0 != memcmp (coin_pub,
&deposit->coin.coin_pub,
sizeof (struct TALER_CoinSpendPublicKeyP))) ||
- ( (NULL != wire) &&
- (0 != GNUNET_memcmp (&h_wire,
- &deposit->h_wire)) ) )
+ (0 != GNUNET_memcmp (&h_wire,
+ &deposit->h_wire)) )
+ {
+ GNUNET_break (0);
+ return GNUNET_DB_STATUS_HARD_ERROR;
+ }
+
+ return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT;
+}
+
+
+/**
+ * Function called with details about deposits that
+ * have been made. Called in the test on the
+ * deposit given in @a cls.
+ *
+ * @param cls closure a `struct TALER_EXCHANGEDB_Deposit *`
+ * @param rowid unique ID for the deposit in our DB, used for marking
+ * it as 'tiny' or 'done'
+ * @param coin_pub public key of the coin
+ * @param amount_with_fee amount that was deposited including fee
+ * @param deposit_fee amount the exchange gets to keep as transaction fees
+ * @param h_contract_terms hash of the proposal data known to merchant and customer
+ * @return transaction status code, #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT to continue to iterate
+ */
+static enum GNUNET_DB_QueryStatus
+matching_deposit_cb (void *cls,
+ uint64_t rowid,
+ const struct TALER_CoinSpendPublicKeyP *coin_pub,
+ const struct TALER_Amount *amount_with_fee,
+ const struct TALER_Amount *deposit_fee,
+ const struct GNUNET_HashCode *h_contract_terms)
+{
+ struct TALER_EXCHANGEDB_Deposit *deposit = cls;
+
+ deposit_rowid = rowid;
+ if ( (0 != TALER_amount_cmp (amount_with_fee,
+ &deposit->amount_with_fee)) ||
+ (0 != TALER_amount_cmp (deposit_fee,
+ &deposit->deposit_fee)) ||
+ (0 != GNUNET_memcmp (h_contract_terms,
+ &deposit->h_contract_terms)) ||
+ (0 != memcmp (coin_pub,
+ &deposit->coin.coin_pub,
+ sizeof (struct TALER_CoinSpendPublicKeyP))) )
{
GNUNET_break (0);
return GNUNET_DB_STATUS_HARD_ERROR;
@@ -1936,7 +1977,7 @@ run (void *cls)
session,
&deposit.h_wire,
&deposit.merchant_pub,
- &deposit_cb,
+ &matching_deposit_cb,
&deposit,
2));
sleep (2); /* giv deposit time to be ready */