-remove tiny field, no longer needed
This commit is contained in:
parent
b9a9af3a59
commit
1f1d675f3d
@ -1 +1 @@
|
||||
1648212500
|
||||
1648383125
|
||||
|
@ -113,7 +113,7 @@ currency = TESTKUDOS
|
||||
[merchant-exchange-default]
|
||||
CURRENCY = TESTKUDOS
|
||||
EXCHANGE_BASE_URL = http://localhost:8081/
|
||||
MASTER_KEY = E3RYJ3NEYDHW0PA989TVV9ZAT152KF8G51H799K6DFBEDKSV9AX0
|
||||
MASTER_KEY = PW24KBXEYD6EKNPHRG12ES1FV3YSZ8BDE6RH05G7RR6N9D8VCYKG
|
||||
|
||||
[merchant-account-merchant]
|
||||
ACTIVE_default = YES
|
||||
@ -167,7 +167,7 @@ CONFIG = postgres:///auditor-basedb
|
||||
[exchange]
|
||||
LOOKAHEAD_SIGN = 32 weeks 1 day
|
||||
SIGNKEY_DURATION = 4 weeks
|
||||
MASTER_PUBLIC_KEY = E3RYJ3NEYDHW0PA989TVV9ZAT152KF8G51H799K6DFBEDKSV9AX0
|
||||
MASTER_PUBLIC_KEY = PW24KBXEYD6EKNPHRG12ES1FV3YSZ8BDE6RH05G7RR6N9D8VCYKG
|
||||
SIGNKEY_LEGAL_DURATION = 4 weeks
|
||||
UNIXPATH = ${TALER_RUNTIME_DIR}/exchange.http
|
||||
|
||||
@ -175,7 +175,7 @@ UNIXPATH = ${TALER_RUNTIME_DIR}/exchange.http
|
||||
CONFIG = postgres:///auditor-basedb
|
||||
|
||||
[auditor]
|
||||
PUBLIC_KEY = Q2JTJM9QP4Z1563ACJ55MA9Q8RGBR2YJQZ2TAMKM8AW36F83BX90
|
||||
PUBLIC_KEY = AA314P9VK5EESBPPNSFJJB793SSZHPMP2RE38Q5GP75TWNXA8MA0
|
||||
TINY_AMOUNT = TESTKUDOS:0.01
|
||||
BASE_URL = http://localhost:8083/
|
||||
|
||||
|
@ -1 +1 @@
|
||||
E3RYJ3NEYDHW0PA989TVV9ZAT152KF8G51H799K6DFBEDKSV9AX0
|
||||
PW24KBXEYD6EKNPHRG12ES1FV3YSZ8BDE6RH05G7RR6N9D8VCYKG
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1 +1 @@
|
||||
1648212687
|
||||
1648383462
|
||||
|
@ -1 +1 @@
|
||||
4QB4095SK50YDPYGABXARDJ755NXNM0SN25PKFTBE3C0HRWZ334G
|
||||
EGBN4CDH1JA9MXWQ7DY1E9SCQ8C2HNAY3TD9SRQHRMMPSVFCVBD0
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -778,8 +778,6 @@ commit (enum GNUNET_DB_QueryStatus qs)
|
||||
* @param amount value of the deposit, including fee
|
||||
* @param payto_uri where should the funds be wired
|
||||
* @param deadline what was the requested wire transfer deadline
|
||||
* @param tiny did the exchange defer this transfer because it is too small?
|
||||
* NOTE: only valid in internal audit mode!
|
||||
* @param done did the exchange claim that it made a transfer?
|
||||
* NOTE: only valid in internal audit mode!
|
||||
*/
|
||||
@ -790,7 +788,6 @@ wire_missing_cb (void *cls,
|
||||
const struct TALER_Amount *amount,
|
||||
const char *payto_uri,
|
||||
struct GNUNET_TIME_Timestamp deadline,
|
||||
bool tiny,
|
||||
bool done)
|
||||
{
|
||||
json_t *rep;
|
||||
@ -799,23 +796,11 @@ wire_missing_cb (void *cls,
|
||||
TALER_ARL_amount_add (&total_amount_lag,
|
||||
&total_amount_lag,
|
||||
amount);
|
||||
if (internal_checks)
|
||||
{
|
||||
/* In internal mode, we insist that the entry was
|
||||
actually marked as tiny. */
|
||||
if (tiny &&
|
||||
(0 > TALER_amount_cmp (amount,
|
||||
&tiny_amount)) )
|
||||
return; /* acceptable, amount was tiny */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* External auditors do not replicate tiny, so they
|
||||
only check that the amount is tiny */
|
||||
/* For now, we simplify and only check that the
|
||||
amount was tiny */
|
||||
if (0 > TALER_amount_cmp (amount,
|
||||
&tiny_amount))
|
||||
return; /* acceptable, amount was tiny */
|
||||
}
|
||||
rep = GNUNET_JSON_PACK (
|
||||
GNUNET_JSON_pack_uint64 ("row",
|
||||
rowid),
|
||||
|
@ -699,7 +699,6 @@ CREATE TABLE IF NOT EXISTS deposits
|
||||
,coin_sig BYTEA NOT NULL CHECK (LENGTH(coin_sig)=64)
|
||||
,wire_salt BYTEA NOT NULL CHECK (LENGTH(wire_salt)=16)
|
||||
,wire_target_h_payto BYTEA CHECK (LENGTH(wire_target_h_payto)=32)
|
||||
,tiny BOOLEAN NOT NULL DEFAULT FALSE
|
||||
,done BOOLEAN NOT NULL DEFAULT FALSE
|
||||
,extension_blocked BOOLEAN NOT NULL DEFAULT FALSE
|
||||
,extension_details_serial_id INT8 REFERENCES extension_details (extension_details_serial_id) ON DELETE CASCADE
|
||||
@ -722,8 +721,6 @@ COMMENT ON COLUMN deposits.extension_blocked
|
||||
IS 'True if the aggregation of the deposit is currently blocked by some extension mechanism. Used to filter out deposits that must not be processed by the canonical deposit logic.';
|
||||
COMMENT ON COLUMN deposits.extension_details_serial_id
|
||||
IS 'References extensions table, NULL if extensions are not used';
|
||||
COMMENT ON COLUMN deposits.tiny
|
||||
IS 'Set to TRUE if we decided that the amount is too small to ever trigger a wire transfer by itself (requires real aggregation)';
|
||||
|
||||
CREATE INDEX IF NOT EXISTS deposits_by_coin_pub_index
|
||||
ON deposits
|
||||
@ -795,11 +792,8 @@ CREATE OR REPLACE FUNCTION deposits_insert_trigger()
|
||||
AS $$
|
||||
DECLARE
|
||||
is_ready BOOLEAN;
|
||||
DECLARE
|
||||
is_tready BOOLEAN; -- is ready, but may be tiny
|
||||
BEGIN
|
||||
is_ready = NOT (NEW.done OR NEW.tiny OR NEW.extension_blocked);
|
||||
is_tready = NOT (NEW.done OR NEW.extension_blocked);
|
||||
is_ready = NOT (NEW.done OR NEW.extension_blocked);
|
||||
|
||||
IF (is_ready)
|
||||
THEN
|
||||
@ -813,9 +807,6 @@ BEGIN
|
||||
,NEW.shard
|
||||
,NEW.coin_pub
|
||||
,NEW.deposit_serial_id);
|
||||
END IF;
|
||||
IF (is_tready)
|
||||
THEN
|
||||
INSERT INTO deposits_for_matching
|
||||
(refund_deadline
|
||||
,merchant_pub
|
||||
@ -845,15 +836,9 @@ DECLARE
|
||||
was_ready BOOLEAN;
|
||||
DECLARE
|
||||
is_ready BOOLEAN;
|
||||
DECLARE
|
||||
was_tready BOOLEAN; -- was ready, but may be tiny
|
||||
DECLARE
|
||||
is_tready BOOLEAN; -- is ready, but may be tiny
|
||||
BEGIN
|
||||
was_ready = NOT (OLD.done OR OLD.tiny OR OLD.extension_blocked);
|
||||
is_ready = NOT (NEW.done OR NEW.tiny OR NEW.extension_blocked);
|
||||
was_tready = NOT (OLD.done OR OLD.extension_blocked);
|
||||
is_tready = NOT (NEW.done OR NEW.extension_blocked);
|
||||
was_ready = NOT (OLD.done OR OLD.extension_blocked);
|
||||
is_ready = NOT (NEW.done OR NEW.extension_blocked);
|
||||
IF (was_ready AND NOT is_ready)
|
||||
THEN
|
||||
DELETE FROM deposits_by_ready
|
||||
@ -861,9 +846,6 @@ BEGIN
|
||||
AND shard = OLD.shard
|
||||
AND coin_pub = OLD.coin_pub
|
||||
AND deposit_serial_id = OLD.deposit_serial_id;
|
||||
END IF;
|
||||
IF (was_tready AND NOT is_tready)
|
||||
THEN
|
||||
DELETE FROM deposits_for_matching
|
||||
WHERE refund_deadline = OLD.refund_deadline
|
||||
AND merchant_pub = OLD.merchant_pub
|
||||
@ -882,9 +864,6 @@ BEGIN
|
||||
,NEW.shard
|
||||
,NEW.coin_pub
|
||||
,NEW.deposit_serial_id);
|
||||
END IF;
|
||||
IF (is_tready AND NOT was_tready)
|
||||
THEN
|
||||
INSERT INTO deposits_for_matching
|
||||
(refund_deadline
|
||||
,merchant_pub
|
||||
@ -912,11 +891,8 @@ CREATE OR REPLACE FUNCTION deposits_delete_trigger()
|
||||
AS $$
|
||||
DECLARE
|
||||
was_ready BOOLEAN;
|
||||
DECLARE
|
||||
was_tready BOOLEAN; -- is ready, but may be tiny
|
||||
BEGIN
|
||||
was_ready = NOT (OLD.done OR OLD.tiny OR OLD.extension_blocked);
|
||||
was_tready = NOT (OLD.done OR OLD.extension_blocked);
|
||||
was_ready = NOT (OLD.done OR OLD.extension_blocked);
|
||||
|
||||
IF (was_ready)
|
||||
THEN
|
||||
@ -925,9 +901,6 @@ BEGIN
|
||||
AND shard = OLD.shard
|
||||
AND coin_pub = OLD.coin_pub
|
||||
AND deposit_serial_id = OLD.deposit_serial_id;
|
||||
END IF;
|
||||
IF (was_tready)
|
||||
THEN
|
||||
DELETE FROM deposits_for_matching
|
||||
WHERE refund_deadline = OLD.refund_deadline
|
||||
AND merchant_pub = OLD.merchant_pub
|
||||
@ -1061,10 +1034,6 @@ CREATE TRIGGER wire_out_on_delete
|
||||
|
||||
-- ------------------------------ aggregation_transient ----------------------------------------
|
||||
|
||||
-- Note: this table is not yet used; it is designed
|
||||
-- to allow us to get rid of the 'tiny BOOL' and
|
||||
-- the associated need to look at tiny
|
||||
-- deposits repeatedly.
|
||||
CREATE TABLE IF NOT EXISTS aggregation_transient
|
||||
(amount_val INT8 NOT NULL
|
||||
,amount_frac INT4 NOT NULL
|
||||
|
@ -526,7 +526,6 @@ irbt_cb_table_deposits (struct PostgresClosure *pg,
|
||||
GNUNET_PQ_query_param_auto_from_type (&td->details.deposits.wire_salt),
|
||||
GNUNET_PQ_query_param_auto_from_type (
|
||||
&td->details.deposits.wire_target_h_payto),
|
||||
GNUNET_PQ_query_param_bool (td->details.deposits.tiny),
|
||||
GNUNET_PQ_query_param_bool (td->details.deposits.done),
|
||||
GNUNET_PQ_query_param_bool (td->details.deposits.extension_blocked),
|
||||
0 == td->details.deposits.extension_details_serial_id
|
||||
|
@ -953,9 +953,6 @@ lrbt_cb_table_deposits (void *cls,
|
||||
GNUNET_PQ_result_spec_auto_from_type (
|
||||
"wire_target_h_payto",
|
||||
&td.details.deposits.wire_target_h_payto),
|
||||
GNUNET_PQ_result_spec_bool (
|
||||
"tiny",
|
||||
&td.details.deposits.tiny),
|
||||
GNUNET_PQ_result_spec_bool (
|
||||
"done",
|
||||
&td.details.deposits.done),
|
||||
|
@ -1176,33 +1176,6 @@ prepare_statements (struct PostgresClosure *pg)
|
||||
" ,dbr.shard ASC"
|
||||
" LIMIT 1;",
|
||||
4),
|
||||
/* FIXME: deprecated; Used in #postgres_iterate_matching_deposits() */
|
||||
GNUNET_PQ_make_prepare (
|
||||
"deposits_iterate_matching",
|
||||
"SELECT"
|
||||
" dep.deposit_serial_id"
|
||||
",dep.amount_with_fee_val"
|
||||
",dep.amount_with_fee_frac"
|
||||
",denom.fee_deposit_val"
|
||||
",denom.fee_deposit_frac"
|
||||
",dep.h_contract_terms"
|
||||
",dfm.coin_pub"
|
||||
" FROM deposits_for_matching dfm"
|
||||
" JOIN deposits dep "
|
||||
" ON (dep.coin_pub = dfm.coin_pub and dep.deposit_serial_id = dfm.deposit_serial_id)"
|
||||
" JOIN known_coins kc"
|
||||
" ON (dep.coin_pub = kc.coin_pub)"
|
||||
" JOIN denominations denom"
|
||||
" USING (denominations_serial)"
|
||||
" WHERE dfm.refund_deadline<$3"
|
||||
" AND dfm.merchant_pub=$1"
|
||||
" AND dep.merchant_pub=$1"
|
||||
" AND dep.wire_target_h_payto=$2"
|
||||
" LIMIT "
|
||||
TALER_QUOTE (
|
||||
TALER_EXCHANGEDB_MATCHING_DEPOSITS_LIMIT) ";",
|
||||
3),
|
||||
|
||||
/* Used in #postgres_aggregate() */
|
||||
GNUNET_PQ_make_prepare (
|
||||
"aggregate",
|
||||
@ -1311,24 +1284,6 @@ prepare_statements (struct PostgresClosure *pg)
|
||||
" AND wtid_raw=$2",
|
||||
2),
|
||||
|
||||
|
||||
/* FIXME-deprecated: Used in #postgres_mark_deposit_tiny() */
|
||||
GNUNET_PQ_make_prepare (
|
||||
"mark_deposit_tiny",
|
||||
"UPDATE deposits"
|
||||
" SET tiny=TRUE"
|
||||
" WHERE coin_pub=$1"
|
||||
" AND deposit_serial_id=$2",
|
||||
2),
|
||||
/* FIXME-deprecated: Used in #postgres_mark_deposit_done() */
|
||||
GNUNET_PQ_make_prepare (
|
||||
"mark_deposit_done",
|
||||
"UPDATE deposits"
|
||||
" SET done=TRUE"
|
||||
" WHERE coin_pub=$1"
|
||||
" AND deposit_serial_id=$2;",
|
||||
2),
|
||||
|
||||
/* Used in #postgres_get_coin_transactions() to obtain information
|
||||
about how a coin has been spend with /deposit requests. */
|
||||
GNUNET_PQ_make_prepare (
|
||||
@ -1614,7 +1569,7 @@ prepare_statements (struct PostgresClosure *pg)
|
||||
2),
|
||||
/* Used in #postgres_select_deposits_missing_wire */
|
||||
// FIXME: used by the auditor; can probably be done
|
||||
// smarter by checking if 'done' or 'tiny' or 'blocked'
|
||||
// smarter by checking if 'done' or 'blocked'
|
||||
// are set correctly when going over deposits, instead
|
||||
// of JOINing with refunds.
|
||||
GNUNET_PQ_make_prepare (
|
||||
@ -1626,7 +1581,6 @@ prepare_statements (struct PostgresClosure *pg)
|
||||
",amount_with_fee_frac"
|
||||
",payto_uri"
|
||||
",wire_deadline"
|
||||
",tiny"
|
||||
",done"
|
||||
" FROM deposits d"
|
||||
" JOIN known_coins"
|
||||
@ -2590,7 +2544,6 @@ prepare_statements (struct PostgresClosure *pg)
|
||||
",coin_sig"
|
||||
",wire_salt"
|
||||
",wire_target_h_payto"
|
||||
",tiny"
|
||||
",done"
|
||||
",extension_blocked"
|
||||
",extension_details_serial_id"
|
||||
@ -2923,14 +2876,13 @@ prepare_statements (struct PostgresClosure *pg)
|
||||
",coin_sig"
|
||||
",wire_salt"
|
||||
",wire_target_h_payto"
|
||||
",tiny"
|
||||
",done"
|
||||
",extension_blocked"
|
||||
",extension_details_serial_id"
|
||||
") VALUES "
|
||||
"($1, $2, $3, $4, $5, $6, $7, $8, $9, $10,"
|
||||
" $11, $12, $13, $14, $15, $16, $17, $18, $19);",
|
||||
19),
|
||||
" $11, $12, $13, $14, $15, $16, $17, $18);",
|
||||
18),
|
||||
GNUNET_PQ_make_prepare (
|
||||
"insert_into_table_refunds",
|
||||
"INSERT INTO refunds"
|
||||
@ -6201,65 +6153,9 @@ postgres_delete_aggregation_transient (
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Mark a deposit as tiny, thereby declaring that it cannot be
|
||||
* executed by itself and should no longer be returned by
|
||||
* @e iterate_ready_deposits()
|
||||
*
|
||||
* @param cls the @e cls of this struct with the plugin-specific state
|
||||
* @param merchant_pub identifies the beneficiary of the deposit
|
||||
* @param rowid identifies the deposit row to modify
|
||||
* @return query result status
|
||||
*/
|
||||
static enum GNUNET_DB_QueryStatus
|
||||
postgres_mark_deposit_tiny (void *cls,
|
||||
const struct TALER_CoinSpendPublicKeyP *coin_pub,
|
||||
uint64_t rowid)
|
||||
{
|
||||
struct PostgresClosure *pg = cls;
|
||||
struct GNUNET_PQ_QueryParam params[] = {
|
||||
GNUNET_PQ_query_param_auto_from_type (coin_pub),
|
||||
GNUNET_PQ_query_param_uint64 (&rowid),
|
||||
GNUNET_PQ_query_param_end
|
||||
};
|
||||
|
||||
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
|
||||
"mark_deposit_tiny",
|
||||
params);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Mark a deposit as done, thereby declaring that it cannot be
|
||||
* executed at all anymore, and should no longer be returned by
|
||||
* @e iterate_ready_deposits() or @e iterate_matching_deposits().
|
||||
*
|
||||
* @param cls the @e cls of this struct with the plugin-specific state
|
||||
* @param merchant_pub identifies the beneficiary of the deposit
|
||||
* @param rowid identifies the deposit row to modify
|
||||
* @return query result status
|
||||
*/
|
||||
static enum GNUNET_DB_QueryStatus
|
||||
postgres_mark_deposit_done (void *cls,
|
||||
const struct TALER_CoinSpendPublicKeyP *coin_pub,
|
||||
uint64_t rowid)
|
||||
{
|
||||
struct PostgresClosure *pg = cls;
|
||||
struct GNUNET_PQ_QueryParam params[] = {
|
||||
GNUNET_PQ_query_param_auto_from_type (coin_pub),
|
||||
GNUNET_PQ_query_param_uint64 (&rowid),
|
||||
GNUNET_PQ_query_param_end
|
||||
};
|
||||
|
||||
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
|
||||
"mark_deposit_done",
|
||||
params);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtain information about deposits that are ready to be executed. Such
|
||||
* deposits must not be marked as "tiny" or "done", the execution time must be
|
||||
* deposits must not be marked as "done", the execution time must be
|
||||
* in the past, and the KYC status must be 'ok'.
|
||||
*
|
||||
* @param cls the @e cls of this struct with the plugin-specific state
|
||||
@ -6311,173 +6207,6 @@ postgres_get_ready_deposit (void *cls,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Closure for #match_deposit_cb().
|
||||
*/
|
||||
struct MatchingDepositContext
|
||||
{
|
||||
/**
|
||||
* Function to call for each result
|
||||
*/
|
||||
TALER_EXCHANGEDB_MatchingDepositIterator deposit_cb;
|
||||
|
||||
/**
|
||||
* Closure for @e deposit_cb.
|
||||
*/
|
||||
void *deposit_cb_cls;
|
||||
|
||||
/**
|
||||
* Public key of the merchant against which we are matching.
|
||||
*/
|
||||
const struct TALER_MerchantPublicKeyP *merchant_pub;
|
||||
|
||||
/**
|
||||
* Plugin context.
|
||||
*/
|
||||
struct PostgresClosure *pg;
|
||||
|
||||
/**
|
||||
* Maximum number of results to return.
|
||||
*/
|
||||
uint32_t limit;
|
||||
|
||||
/**
|
||||
* Loop counter, actual number of results returned.
|
||||
*/
|
||||
unsigned int i;
|
||||
|
||||
/**
|
||||
* Set to #GNUNET_SYSERR on hard errors.
|
||||
*/
|
||||
enum GNUNET_GenericReturnValue status;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Helper function for #postgres_iterate_matching_deposits().
|
||||
* To be called with the results of a SELECT statement
|
||||
* that has returned @a num_results results.
|
||||
*
|
||||
* @param cls closure of type `struct MatchingDepositContext *`
|
||||
* @param result the postgres result
|
||||
* @param num_results the number of results in @a result
|
||||
*/
|
||||
static void
|
||||
match_deposit_cb (void *cls,
|
||||
PGresult *result,
|
||||
unsigned int num_results)
|
||||
{
|
||||
struct MatchingDepositContext *mdc = cls;
|
||||
struct PostgresClosure *pg = mdc->pg;
|
||||
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||
"Found %u/%u matching deposits\n",
|
||||
num_results,
|
||||
mdc->limit);
|
||||
num_results = GNUNET_MIN (num_results,
|
||||
mdc->limit);
|
||||
for (mdc->i = 0; mdc->i<num_results; mdc->i++)
|
||||
{
|
||||
struct TALER_Amount amount_with_fee;
|
||||
struct TALER_Amount deposit_fee;
|
||||
struct TALER_PrivateContractHashP h_contract_terms;
|
||||
struct TALER_CoinSpendPublicKeyP coin_pub;
|
||||
uint64_t serial_id;
|
||||
enum GNUNET_DB_QueryStatus qs;
|
||||
struct GNUNET_PQ_ResultSpec rs[] = {
|
||||
GNUNET_PQ_result_spec_uint64 ("deposit_serial_id",
|
||||
&serial_id),
|
||||
TALER_PQ_RESULT_SPEC_AMOUNT ("amount_with_fee",
|
||||
&amount_with_fee),
|
||||
TALER_PQ_RESULT_SPEC_AMOUNT ("fee_deposit",
|
||||
&deposit_fee),
|
||||
GNUNET_PQ_result_spec_auto_from_type ("h_contract_terms",
|
||||
&h_contract_terms),
|
||||
GNUNET_PQ_result_spec_auto_from_type ("coin_pub",
|
||||
&coin_pub),
|
||||
GNUNET_PQ_result_spec_end
|
||||
};
|
||||
|
||||
if (GNUNET_OK !=
|
||||
GNUNET_PQ_extract_result (result,
|
||||
rs,
|
||||
mdc->i))
|
||||
{
|
||||
GNUNET_break (0);
|
||||
mdc->status = GNUNET_SYSERR;
|
||||
return;
|
||||
}
|
||||
qs = mdc->deposit_cb (mdc->deposit_cb_cls,
|
||||
serial_id,
|
||||
&coin_pub,
|
||||
&amount_with_fee,
|
||||
&deposit_fee,
|
||||
&h_contract_terms);
|
||||
GNUNET_PQ_cleanup_result (rs);
|
||||
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtain information about other pending deposits for the same
|
||||
* destination. Those deposits must not already be "done".
|
||||
*
|
||||
* @param cls the @e cls of this struct with the plugin-specific state
|
||||
* @param h_payto destination of the wire transfer
|
||||
* @param merchant_pub public key of the merchant
|
||||
* @param deposit_cb function to call for each deposit
|
||||
* @param deposit_cb_cls closure for @a deposit_cb
|
||||
* @param limit maximum number of matching deposits to return
|
||||
* @return transaction status code, if positive:
|
||||
* number of rows processed, 0 if none exist
|
||||
*/
|
||||
static enum GNUNET_DB_QueryStatus
|
||||
postgres_iterate_matching_deposits (
|
||||
void *cls,
|
||||
const struct TALER_PaytoHashP *h_payto,
|
||||
const struct TALER_MerchantPublicKeyP *merchant_pub,
|
||||
TALER_EXCHANGEDB_MatchingDepositIterator deposit_cb,
|
||||
void *deposit_cb_cls,
|
||||
uint32_t limit)
|
||||
{
|
||||
struct PostgresClosure *pg = cls;
|
||||
struct GNUNET_TIME_Absolute now = {0};
|
||||
struct GNUNET_PQ_QueryParam params[] = {
|
||||
GNUNET_PQ_query_param_auto_from_type (merchant_pub),
|
||||
GNUNET_PQ_query_param_auto_from_type (h_payto),
|
||||
GNUNET_PQ_query_param_absolute_time (&now),
|
||||
GNUNET_PQ_query_param_end
|
||||
};
|
||||
struct MatchingDepositContext mdc = {
|
||||
.deposit_cb = deposit_cb,
|
||||
.deposit_cb_cls = deposit_cb_cls,
|
||||
.merchant_pub = merchant_pub,
|
||||
.pg = pg,
|
||||
.limit = limit,
|
||||
.status = GNUNET_OK
|
||||
};
|
||||
enum GNUNET_DB_QueryStatus qs;
|
||||
|
||||
now = GNUNET_TIME_absolute_round_down (GNUNET_TIME_absolute_get (),
|
||||
pg->aggregator_shift);
|
||||
qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
|
||||
"deposits_iterate_matching",
|
||||
params,
|
||||
&match_deposit_cb,
|
||||
&mdc);
|
||||
if (GNUNET_OK != mdc.status)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
return GNUNET_DB_STATUS_HARD_ERROR;
|
||||
}
|
||||
if (qs >= 0)
|
||||
return mdc.i;
|
||||
return qs;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve the record for a known coin.
|
||||
*
|
||||
@ -10806,7 +10535,6 @@ missing_wire_cb (void *cls,
|
||||
struct TALER_Amount amount;
|
||||
char *payto_uri;
|
||||
struct GNUNET_TIME_Timestamp deadline;
|
||||
bool tiny;
|
||||
bool done;
|
||||
struct GNUNET_PQ_ResultSpec rs[] = {
|
||||
GNUNET_PQ_result_spec_uint64 ("deposit_serial_id",
|
||||
@ -10819,8 +10547,6 @@ missing_wire_cb (void *cls,
|
||||
&payto_uri),
|
||||
GNUNET_PQ_result_spec_timestamp ("wire_deadline",
|
||||
&deadline),
|
||||
GNUNET_PQ_result_spec_bool ("tiny",
|
||||
&tiny),
|
||||
GNUNET_PQ_result_spec_bool ("done",
|
||||
&done),
|
||||
GNUNET_PQ_result_spec_end
|
||||
@ -10841,7 +10567,6 @@ missing_wire_cb (void *cls,
|
||||
&amount,
|
||||
payto_uri,
|
||||
deadline,
|
||||
tiny,
|
||||
done);
|
||||
GNUNET_PQ_cleanup_result (rs);
|
||||
}
|
||||
@ -13384,10 +13109,7 @@ libtaler_plugin_exchangedb_postgres_init (void *cls)
|
||||
= &postgres_update_aggregation_transient;
|
||||
plugin->delete_aggregation_transient
|
||||
= &postgres_delete_aggregation_transient;
|
||||
plugin->mark_deposit_tiny = &postgres_mark_deposit_tiny;
|
||||
plugin->mark_deposit_done = &postgres_mark_deposit_done;
|
||||
plugin->get_ready_deposit = &postgres_get_ready_deposit;
|
||||
plugin->iterate_matching_deposits = &postgres_iterate_matching_deposits;
|
||||
plugin->insert_deposit = &postgres_insert_deposit;
|
||||
plugin->insert_refund = &postgres_insert_refund;
|
||||
plugin->select_refunds_by_coin = &postgres_select_refunds_by_coin;
|
||||
|
@ -607,72 +607,10 @@ cb_wt_check (void *cls,
|
||||
|
||||
|
||||
/**
|
||||
* Here #deposit_cb() will store the row ID of the deposit.
|
||||
*/
|
||||
static uint64_t deposit_rowid;
|
||||
|
||||
/**
|
||||
* Here #deposit_cb() will store the row ID of the account.
|
||||
*/
|
||||
static uint64_t wire_target_row;
|
||||
|
||||
/**
|
||||
* Here #deposit_cb() will store the hash of the payto URI.
|
||||
* Here we store the hash of the payto URI.
|
||||
*/
|
||||
static struct TALER_PaytoHashP wire_target_h_payto;
|
||||
|
||||
/**
|
||||
* 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 merchant_pub public key of the merchant
|
||||
* @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
|
||||
* @param wire_target unique ID of the receiver account
|
||||
* @param payto_uri how to pay the merchant, URI in payto://-format;
|
||||
* @return transaction status code, #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT to continue to iterate
|
||||
*/
|
||||
static enum GNUNET_DB_QueryStatus
|
||||
deposit_cb (void *cls,
|
||||
uint64_t rowid,
|
||||
const struct TALER_MerchantPublicKeyP *merchant_pub,
|
||||
const struct TALER_CoinSpendPublicKeyP *coin_pub,
|
||||
const struct TALER_Amount *amount_with_fee,
|
||||
const struct TALER_Amount *deposit_fee,
|
||||
const struct TALER_PrivateContractHashP *h_contract_terms,
|
||||
uint64_t wire_target,
|
||||
const char *payto_uri)
|
||||
{
|
||||
struct TALER_EXCHANGEDB_Deposit *deposit = cls;
|
||||
|
||||
if ( (0 == GNUNET_memcmp (merchant_pub,
|
||||
&deposit->merchant_pub)) &&
|
||||
(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 == GNUNET_memcmp (coin_pub,
|
||||
&deposit->coin.coin_pub)) &&
|
||||
(0 == strcmp (payto_uri,
|
||||
deposit->receiver_wire_account)) )
|
||||
{
|
||||
deposit_rowid = rowid;
|
||||
wire_target_row = wire_target;
|
||||
TALER_payto_hash (payto_uri,
|
||||
&wire_target_h_payto);
|
||||
result = 9;
|
||||
}
|
||||
return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Callback for #select_deposits_above_serial_id ()
|
||||
@ -1191,7 +1129,6 @@ drop:
|
||||
* @param amount value of the deposit, including fee
|
||||
* @param payto_uri where should the funds be wired
|
||||
* @param deadline what was the requested wire transfer deadline
|
||||
* @param tiny did the exchange defer this transfer because it is too small?
|
||||
* @param done did the exchange claim that it made a transfer?
|
||||
*/
|
||||
static void
|
||||
@ -1201,7 +1138,6 @@ wire_missing_cb (void *cls,
|
||||
const struct TALER_Amount *amount,
|
||||
const char *payto_uri,
|
||||
struct GNUNET_TIME_Timestamp deadline,
|
||||
bool tiny,
|
||||
bool done)
|
||||
{
|
||||
const struct TALER_EXCHANGEDB_Deposit *deposit = cls;
|
||||
@ -1209,11 +1145,6 @@ wire_missing_cb (void *cls,
|
||||
(void) payto_uri;
|
||||
(void) deadline;
|
||||
(void) rowid;
|
||||
if (tiny)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
result = 66;
|
||||
}
|
||||
if (done)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
@ -2212,14 +2143,26 @@ run (void *cls)
|
||||
FAILIF (0 == auditor_row_cnt);
|
||||
result = 8;
|
||||
sleep (2); /* give deposit time to be ready */
|
||||
{
|
||||
struct TALER_MerchantPublicKeyP merchant_pub2;
|
||||
char *payto_uri2;
|
||||
|
||||
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
|
||||
plugin->get_ready_deposit (plugin->cls,
|
||||
0,
|
||||
INT32_MAX,
|
||||
true,
|
||||
&deposit_cb,
|
||||
&deposit));
|
||||
FAILIF (8 == result);
|
||||
&merchant_pub2,
|
||||
&payto_uri2));
|
||||
FAILIF (0 != GNUNET_memcmp (&merchant_pub2,
|
||||
&deposit.merchant_pub));
|
||||
FAILIF (0 != strcmp (payto_uri2,
|
||||
deposit.receiver_wire_account));
|
||||
TALER_payto_hash (payto_uri2,
|
||||
&wire_target_h_payto);
|
||||
GNUNET_free (payto_uri2);
|
||||
}
|
||||
|
||||
{
|
||||
struct TALER_Amount total;
|
||||
struct TALER_WireTransferIdentifierRawP wtid;
|
||||
|
@ -351,7 +351,6 @@ struct TALER_EXCHANGEDB_TableData
|
||||
struct TALER_CoinSpendSignatureP coin_sig;
|
||||
struct TALER_WireSaltP wire_salt;
|
||||
struct TALER_PaytoHashP wire_target_h_payto;
|
||||
bool tiny;
|
||||
bool done;
|
||||
bool extension_blocked;
|
||||
uint64_t extension_details_serial_id;
|
||||
@ -1561,58 +1560,6 @@ struct TALER_EXCHANGEDB_TransactionList
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Function called with details about deposits that have been made,
|
||||
* with the goal of executing the corresponding wire transaction.
|
||||
*
|
||||
* @param cls closure
|
||||
* @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
|
||||
*/
|
||||
typedef enum GNUNET_DB_QueryStatus
|
||||
(*TALER_EXCHANGEDB_MatchingDepositIterator)(
|
||||
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 TALER_PrivateContractHashP *h_contract_terms);
|
||||
|
||||
|
||||
/**
|
||||
* Function called with details about deposits that have been made,
|
||||
* with the goal of executing the corresponding wire transaction.
|
||||
*
|
||||
* @param cls closure
|
||||
* @param rowid unique ID for the deposit in our DB, used for marking
|
||||
* it as 'tiny' or 'done'
|
||||
* @param merchant_pub public key of the merchant
|
||||
* @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
|
||||
* @param wire_target unique ID of the receiver account
|
||||
* @param payto_uri how to pay the merchant, URI in payto://-format;
|
||||
* @return transaction status code, #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT to continue to iterate
|
||||
*/
|
||||
typedef enum GNUNET_DB_QueryStatus
|
||||
(*TALER_EXCHANGEDB_DepositIterator)(
|
||||
void *cls,
|
||||
uint64_t rowid,
|
||||
const struct TALER_MerchantPublicKeyP *merchant_pub,
|
||||
const struct TALER_CoinSpendPublicKeyP *coin_pub,
|
||||
const struct TALER_Amount *amount_with_fee,
|
||||
const struct TALER_Amount *deposit_fee,
|
||||
const struct TALER_PrivateContractHashP *h_contract_terms,
|
||||
uint64_t wire_target,
|
||||
const char *payto_uri);
|
||||
|
||||
|
||||
/**
|
||||
* Callback with data about a prepared wire transfer.
|
||||
*
|
||||
@ -2215,7 +2162,6 @@ typedef void
|
||||
* @param amount value of the deposit, including fee
|
||||
* @param payto_uri where should the funds be wired; URI in payto://-format
|
||||
* @param deadline what was the requested wire transfer deadline
|
||||
* @param tiny did the exchange defer this transfer because it is too small?
|
||||
* @param done did the exchange claim that it made a transfer?
|
||||
*/
|
||||
typedef void
|
||||
@ -2226,7 +2172,6 @@ typedef void
|
||||
const struct TALER_Amount *amount,
|
||||
const char *payto_uri,
|
||||
struct GNUNET_TIME_Timestamp deadline,
|
||||
bool tiny,
|
||||
bool done);
|
||||
|
||||
|
||||
@ -3054,41 +2999,9 @@ struct TALER_EXCHANGEDB_Plugin
|
||||
void *cb_cls);
|
||||
|
||||
|
||||
/**
|
||||
* Mark a deposit as tiny, thereby declaring that it cannot be executed by
|
||||
* itself (only included in a larger aggregation) and should no longer be
|
||||
* returned by @e iterate_ready_deposits()
|
||||
*
|
||||
* @param cls the @e cls of this struct with the plugin-specific state
|
||||
* @param coin_pub identifies the coin of the deposit
|
||||
* @param deposit_rowid identifies the deposit row to modify
|
||||
* @return query result status
|
||||
*/
|
||||
enum GNUNET_DB_QueryStatus
|
||||
(*mark_deposit_tiny)(void *cls,
|
||||
const struct TALER_CoinSpendPublicKeyP *coin_pub,
|
||||
uint64_t rowid);
|
||||
|
||||
|
||||
/**
|
||||
* Mark a deposit as done, thereby declaring that it cannot be
|
||||
* executed at all anymore, and should no longer be returned by
|
||||
* @e iterate_ready_deposits() or @e iterate_matching_deposits().
|
||||
*
|
||||
* @param cls the @e cls of this struct with the plugin-specific state
|
||||
* @param coin_pub identifies the coin of the deposit
|
||||
* @param deposit_rowid identifies the deposit row to modify
|
||||
* @return query result status
|
||||
*/
|
||||
enum GNUNET_DB_QueryStatus
|
||||
(*mark_deposit_done)(void *cls,
|
||||
const struct TALER_CoinSpendPublicKeyP *coin_pub,
|
||||
uint64_t rowid);
|
||||
|
||||
|
||||
/**
|
||||
* Obtain information about deposits that are ready to be executed.
|
||||
* Such deposits must not be marked as "tiny" or "done", and the
|
||||
* Such deposits must not be marked as "done", and the
|
||||
* execution time, the refund deadlines must both be in the past and
|
||||
* the KYC status must be 'ok'.
|
||||
*
|
||||
@ -3113,38 +3026,10 @@ struct TALER_EXCHANGEDB_Plugin
|
||||
/**
|
||||
* Maximum number of results we return from iterate_matching_deposits().
|
||||
*
|
||||
* Limit on the number of transactions we aggregate at once. Note
|
||||
* that the limit must be big enough to ensure that when transactions
|
||||
* of the smallest possible unit are aggregated, they do surpass the
|
||||
* "tiny" threshold beyond which we never trigger a wire transaction!
|
||||
* Limit on the number of transactions we aggregate at once.
|
||||
*/
|
||||
#define TALER_EXCHANGEDB_MATCHING_DEPOSITS_LIMIT 10000
|
||||
|
||||
/**
|
||||
* Obtain information about other pending deposits for the same
|
||||
* destination. Those deposits must not already be "done".
|
||||
*
|
||||
* @param cls the @e cls of this struct with the plugin-specific state
|
||||
* @param h_payto destination of the wire transfer
|
||||
* @param merchant_pub public key of the merchant
|
||||
* @param deposit_cb function to call for each deposit
|
||||
* @param deposit_cb_cls closure for @a deposit_cb
|
||||
* @param limit maximum number of matching deposits to return; should
|
||||
* be #TALER_EXCHANGEDB_MATCHING_DEPOSITS_LIMIT, larger values
|
||||
* are not supported, smaller values would be inefficient.
|
||||
* @return number of rows processed, 0 if none exist,
|
||||
* transaction status code on error
|
||||
*/
|
||||
enum GNUNET_DB_QueryStatus
|
||||
(*iterate_matching_deposits)(
|
||||
void *cls,
|
||||
const struct TALER_PaytoHashP *h_payto,
|
||||
const struct TALER_MerchantPublicKeyP *merchant_pub,
|
||||
TALER_EXCHANGEDB_MatchingDepositIterator deposit_cb,
|
||||
void *deposit_cb_cls,
|
||||
uint32_t limit);
|
||||
|
||||
|
||||
/**
|
||||
* Aggregate all matching deposits for @a h_payto and
|
||||
* @a merchant_pub, returning the total amounts.
|
||||
|
Loading…
Reference in New Issue
Block a user