denormalize reserve_pub in reserve tables to enable sharding
This commit is contained in:
parent
527d903678
commit
62444504f7
@ -140,7 +140,6 @@ withdraw_transaction (void *cls,
|
|||||||
enum GNUNET_DB_QueryStatus qs;
|
enum GNUNET_DB_QueryStatus qs;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
bool balance_ok = false;
|
bool balance_ok = false;
|
||||||
uint64_t reserve_uuid;
|
|
||||||
struct GNUNET_TIME_Timestamp now;
|
struct GNUNET_TIME_Timestamp now;
|
||||||
|
|
||||||
now = GNUNET_TIME_timestamp_get ();
|
now = GNUNET_TIME_timestamp_get ();
|
||||||
@ -151,8 +150,7 @@ withdraw_transaction (void *cls,
|
|||||||
now,
|
now,
|
||||||
&found,
|
&found,
|
||||||
&balance_ok,
|
&balance_ok,
|
||||||
&wc->kyc,
|
&wc->kyc);
|
||||||
&reserve_uuid);
|
|
||||||
if (0 > qs)
|
if (0 > qs)
|
||||||
{
|
{
|
||||||
if (GNUNET_DB_STATUS_HARD_ERROR == qs)
|
if (GNUNET_DB_STATUS_HARD_ERROR == qs)
|
||||||
@ -234,7 +232,7 @@ withdraw_transaction (void *cls,
|
|||||||
|
|
||||||
qs2 = TEH_plugin->do_withdraw_limit_check (
|
qs2 = TEH_plugin->do_withdraw_limit_check (
|
||||||
TEH_plugin->cls,
|
TEH_plugin->cls,
|
||||||
reserve_uuid,
|
&wc->collectable.reserve_pub,
|
||||||
GNUNET_TIME_absolute_subtract (now.abs_time,
|
GNUNET_TIME_absolute_subtract (now.abs_time,
|
||||||
TEH_kyc_config.withdraw_period),
|
TEH_kyc_config.withdraw_period),
|
||||||
&TEH_kyc_config.withdraw_limit,
|
&TEH_kyc_config.withdraw_limit,
|
||||||
|
@ -87,13 +87,15 @@ COMMENT ON COLUMN wire_targets.external_id
|
|||||||
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS reserves
|
CREATE TABLE IF NOT EXISTS reserves
|
||||||
(reserve_uuid BIGSERIAL UNIQUE
|
(reserve_uuid BIGSERIAL
|
||||||
,reserve_pub BYTEA PRIMARY KEY CHECK(LENGTH(reserve_pub)=32)
|
,reserve_pub BYTEA PRIMARY KEY CHECK(LENGTH(reserve_pub)=32)
|
||||||
,current_balance_val INT8 NOT NULL
|
,current_balance_val INT8 NOT NULL
|
||||||
,current_balance_frac INT4 NOT NULL
|
,current_balance_frac INT4 NOT NULL
|
||||||
,expiration_date INT8 NOT NULL
|
,expiration_date INT8 NOT NULL
|
||||||
,gc_date INT8 NOT NULL
|
,gc_date INT8 NOT NULL
|
||||||
);
|
)
|
||||||
|
PARTITION BY HASH (reserve_pub);
|
||||||
|
|
||||||
COMMENT ON TABLE reserves
|
COMMENT ON TABLE reserves
|
||||||
IS 'Summarizes the balance of a reserve. Updated when new funds are added or withdrawn.';
|
IS 'Summarizes the balance of a reserve. Updated when new funds are added or withdrawn.';
|
||||||
COMMENT ON COLUMN reserves.expiration_date
|
COMMENT ON COLUMN reserves.expiration_date
|
||||||
@ -101,6 +103,17 @@ COMMENT ON COLUMN reserves.expiration_date
|
|||||||
COMMENT ON COLUMN reserves.gc_date
|
COMMENT ON COLUMN reserves.gc_date
|
||||||
IS 'Used to forget all information about a reserve during garbage collection';
|
IS 'Used to forget all information about a reserve during garbage collection';
|
||||||
|
|
||||||
|
CREATE TABLE reserves_0 PARTITION OF reserves FOR VALUES WITH (MODULUS 8, REMAINDER 0);
|
||||||
|
CREATE TABLE reserves_1 PARTITION OF reserves FOR VALUES WITH (MODULUS 8, REMAINDER 1);
|
||||||
|
CREATE TABLE reserves_2 PARTITION OF reserves FOR VALUES WITH (MODULUS 8, REMAINDER 2);
|
||||||
|
CREATE TABLE reserves_3 PARTITION OF reserves FOR VALUES WITH (MODULUS 8, REMAINDER 3);
|
||||||
|
CREATE TABLE reserves_4 PARTITION OF reserves FOR VALUES WITH (MODULUS 8, REMAINDER 4);
|
||||||
|
CREATE TABLE reserves_5 PARTITION OF reserves FOR VALUES WITH (MODULUS 8, REMAINDER 5);
|
||||||
|
CREATE TABLE reserves_6 PARTITION OF reserves FOR VALUES WITH (MODULUS 8, REMAINDER 6);
|
||||||
|
CREATE TABLE reserves_7 PARTITION OF reserves FOR VALUES WITH (MODULUS 8, REMAINDER 7);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS reserves_expiration_index
|
CREATE INDEX IF NOT EXISTS reserves_expiration_index
|
||||||
ON reserves
|
ON reserves
|
||||||
(expiration_date
|
(expiration_date
|
||||||
@ -119,14 +132,14 @@ COMMENT ON INDEX reserves_gc_index
|
|||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS reserves_in
|
CREATE TABLE IF NOT EXISTS reserves_in
|
||||||
(reserve_in_serial_id BIGSERIAL UNIQUE
|
(reserve_in_serial_id BIGSERIAL UNIQUE
|
||||||
,reserve_uuid INT8 NOT NULL REFERENCES reserves (reserve_uuid) ON DELETE CASCADE
|
,reserve_pub BYTEA NOT NULL REFERENCES reserves (reserve_pub) ON DELETE CASCADE
|
||||||
,wire_reference INT8 NOT NULL
|
,wire_reference INT8 NOT NULL
|
||||||
,credit_val INT8 NOT NULL
|
,credit_val INT8 NOT NULL
|
||||||
,credit_frac INT4 NOT NULL
|
,credit_frac INT4 NOT NULL
|
||||||
,wire_source_serial_id INT8 NOT NULL REFERENCES wire_targets (wire_target_serial_id)
|
,wire_source_serial_id INT8 NOT NULL REFERENCES wire_targets (wire_target_serial_id)
|
||||||
,exchange_account_section TEXT NOT NULL
|
,exchange_account_section TEXT NOT NULL
|
||||||
,execution_date INT8 NOT NULL
|
,execution_date INT8 NOT NULL
|
||||||
,PRIMARY KEY (reserve_uuid, wire_reference)
|
,PRIMARY KEY (reserve_pub, wire_reference)
|
||||||
);
|
);
|
||||||
COMMENT ON TABLE reserves_in
|
COMMENT ON TABLE reserves_in
|
||||||
IS 'list of transfers of funds into the reserves, one per incoming wire transfer';
|
IS 'list of transfers of funds into the reserves, one per incoming wire transfer';
|
||||||
@ -144,9 +157,10 @@ CREATE INDEX IF NOT EXISTS reserves_in_exchange_account_serial
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS reserves_close
|
CREATE TABLE IF NOT EXISTS reserves_close
|
||||||
(close_uuid BIGSERIAL PRIMARY KEY
|
(close_uuid BIGSERIAL PRIMARY KEY
|
||||||
,reserve_uuid INT8 NOT NULL REFERENCES reserves (reserve_uuid) ON DELETE CASCADE
|
,reserve_pub BYTEA NOT NULL REFERENCES reserves (reserve_pub) ON DELETE CASCADE
|
||||||
,execution_date INT8 NOT NULL
|
,execution_date INT8 NOT NULL
|
||||||
,wtid BYTEA NOT NULL CHECK (LENGTH(wtid)=32)
|
,wtid BYTEA NOT NULL CHECK (LENGTH(wtid)=32)
|
||||||
,wire_target_serial_id INT8 NOT NULL REFERENCES wire_targets (wire_target_serial_id)
|
,wire_target_serial_id INT8 NOT NULL REFERENCES wire_targets (wire_target_serial_id)
|
||||||
@ -161,7 +175,7 @@ COMMENT ON COLUMN reserves_close.wire_target_serial_id
|
|||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS reserves_close_by_uuid
|
CREATE INDEX IF NOT EXISTS reserves_close_by_uuid
|
||||||
ON reserves_close
|
ON reserves_close
|
||||||
(reserve_uuid);
|
(reserve_pub);
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS reserves_out
|
CREATE TABLE IF NOT EXISTS reserves_out
|
||||||
@ -169,7 +183,7 @@ CREATE TABLE IF NOT EXISTS reserves_out
|
|||||||
,h_blind_ev BYTEA PRIMARY KEY CHECK (LENGTH(h_blind_ev)=64)
|
,h_blind_ev BYTEA PRIMARY KEY CHECK (LENGTH(h_blind_ev)=64)
|
||||||
,denominations_serial INT8 NOT NULL REFERENCES denominations (denominations_serial)
|
,denominations_serial INT8 NOT NULL REFERENCES denominations (denominations_serial)
|
||||||
,denom_sig BYTEA NOT NULL
|
,denom_sig BYTEA NOT NULL
|
||||||
,reserve_uuid INT8 NOT NULL REFERENCES reserves (reserve_uuid) ON DELETE CASCADE
|
,reserve_pub BYTEA NOT NULL REFERENCES reserves (reserve_pub) ON DELETE CASCADE
|
||||||
,reserve_sig BYTEA NOT NULL CHECK (LENGTH(reserve_sig)=64)
|
,reserve_sig BYTEA NOT NULL CHECK (LENGTH(reserve_sig)=64)
|
||||||
,execution_date INT8 NOT NULL
|
,execution_date INT8 NOT NULL
|
||||||
,amount_with_fee_val INT8 NOT NULL
|
,amount_with_fee_val INT8 NOT NULL
|
||||||
@ -182,10 +196,10 @@ COMMENT ON COLUMN reserves_out.h_blind_ev
|
|||||||
COMMENT ON COLUMN reserves_out.denominations_serial
|
COMMENT ON COLUMN reserves_out.denominations_serial
|
||||||
IS 'We do not CASCADE ON DELETE here, we may keep the denomination data alive';
|
IS 'We do not CASCADE ON DELETE here, we may keep the denomination data alive';
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS reserves_out_reserve_uuid_index
|
CREATE INDEX IF NOT EXISTS reserves_out_reserve_pub_index
|
||||||
ON reserves_out
|
ON reserves_out
|
||||||
(reserve_uuid);
|
(reserve_pub);
|
||||||
COMMENT ON INDEX reserves_out_reserve_uuid_index
|
COMMENT ON INDEX reserves_out_reserve_pub_index
|
||||||
IS 'for get_reserves_out';
|
IS 'for get_reserves_out';
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS reserves_out_execution_date
|
CREATE INDEX IF NOT EXISTS reserves_out_execution_date
|
||||||
@ -710,7 +724,6 @@ CREATE OR REPLACE FUNCTION exchange_do_withdraw(
|
|||||||
OUT reserve_found BOOLEAN,
|
OUT reserve_found BOOLEAN,
|
||||||
OUT balance_ok BOOLEAN,
|
OUT balance_ok BOOLEAN,
|
||||||
OUT kycok BOOLEAN,
|
OUT kycok BOOLEAN,
|
||||||
OUT ruuid INT8,
|
|
||||||
OUT account_uuid INT8)
|
OUT account_uuid INT8)
|
||||||
LANGUAGE plpgsql
|
LANGUAGE plpgsql
|
||||||
AS $$
|
AS $$
|
||||||
@ -734,21 +747,18 @@ THEN
|
|||||||
reserve_found=FALSE;
|
reserve_found=FALSE;
|
||||||
balance_ok=FALSE;
|
balance_ok=FALSE;
|
||||||
kycok=FALSE;
|
kycok=FALSE;
|
||||||
ruuid=0;
|
|
||||||
account_uuid=0;
|
account_uuid=0;
|
||||||
ASSERT false, 'denomination unknown';
|
ASSERT false, 'denomination unknown';
|
||||||
RETURN;
|
RETURN;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
reserves.reserve_uuid
|
current_balance_val
|
||||||
,current_balance_val
|
|
||||||
,current_balance_frac
|
,current_balance_frac
|
||||||
,expiration_date
|
,expiration_date
|
||||||
,gc_date
|
,gc_date
|
||||||
INTO
|
INTO
|
||||||
ruuid
|
reserve_val
|
||||||
,reserve_val
|
|
||||||
,reserve_frac
|
,reserve_frac
|
||||||
,reserve_gc
|
,reserve_gc
|
||||||
FROM reserves
|
FROM reserves
|
||||||
@ -770,7 +780,7 @@ INSERT INTO reserves_out
|
|||||||
(h_blind_ev
|
(h_blind_ev
|
||||||
,denominations_serial
|
,denominations_serial
|
||||||
,denom_sig
|
,denom_sig
|
||||||
,reserve_uuid
|
,reserve_pub
|
||||||
,reserve_sig
|
,reserve_sig
|
||||||
,execution_date
|
,execution_date
|
||||||
,amount_with_fee_val
|
,amount_with_fee_val
|
||||||
@ -779,7 +789,7 @@ VALUES
|
|||||||
(h_coin_envelope
|
(h_coin_envelope
|
||||||
,denom_serial
|
,denom_serial
|
||||||
,denom_sig
|
,denom_sig
|
||||||
,ruuid
|
,rpub
|
||||||
,reserve_sig
|
,reserve_sig
|
||||||
,now
|
,now
|
||||||
,amount_val
|
,amount_val
|
||||||
@ -830,7 +840,7 @@ UPDATE reserves SET
|
|||||||
,current_balance_val=reserve_val
|
,current_balance_val=reserve_val
|
||||||
,current_balance_frac=reserve_frac
|
,current_balance_frac=reserve_frac
|
||||||
WHERE
|
WHERE
|
||||||
reserves.reserve_uuid=ruuid;
|
reserves.reserve_pub=rpub;
|
||||||
|
|
||||||
reserve_found=TRUE;
|
reserve_found=TRUE;
|
||||||
balance_ok=TRUE;
|
balance_ok=TRUE;
|
||||||
@ -845,7 +855,7 @@ SELECT
|
|||||||
,account_uuid
|
,account_uuid
|
||||||
FROM reserves_in
|
FROM reserves_in
|
||||||
JOIN wire_targets ON (wire_source_serial_id = wire_target_serial_id)
|
JOIN wire_targets ON (wire_source_serial_id = wire_target_serial_id)
|
||||||
WHERE reserve_uuid=ruuid
|
WHERE reserve_pub=rpub
|
||||||
LIMIT 1; -- limit 1 should not be required (without p2p transfers)
|
LIMIT 1; -- limit 1 should not be required (without p2p transfers)
|
||||||
|
|
||||||
END $$;
|
END $$;
|
||||||
@ -856,7 +866,7 @@ COMMENT ON FUNCTION exchange_do_withdraw(INT8, INT4, BYTEA, BYTEA, BYTEA, BYTEA,
|
|||||||
|
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION exchange_do_withdraw_limit_check(
|
CREATE OR REPLACE FUNCTION exchange_do_withdraw_limit_check(
|
||||||
IN ruuid INT8,
|
IN rpub BYTEA,
|
||||||
IN start_time INT8,
|
IN start_time INT8,
|
||||||
IN upper_limit_val INT8,
|
IN upper_limit_val INT8,
|
||||||
IN upper_limit_frac INT4,
|
IN upper_limit_frac INT4,
|
||||||
@ -876,7 +886,7 @@ SELECT
|
|||||||
total_val
|
total_val
|
||||||
,total_frac
|
,total_frac
|
||||||
FROM reserves_out
|
FROM reserves_out
|
||||||
WHERE reserves_out.reserve_uuid=ruuid
|
WHERE reserves_out.reserve_pub=rpub
|
||||||
AND execution_date > start_time;
|
AND execution_date > start_time;
|
||||||
|
|
||||||
-- normalize result
|
-- normalize result
|
||||||
@ -889,7 +899,7 @@ below_limit = (total_val < upper_limit_val) OR
|
|||||||
(total_frac <= upper_limit_frac) );
|
(total_frac <= upper_limit_frac) );
|
||||||
END $$;
|
END $$;
|
||||||
|
|
||||||
COMMENT ON FUNCTION exchange_do_withdraw_limit_check(INT8, INT8, INT8, INT4)
|
COMMENT ON FUNCTION exchange_do_withdraw_limit_check(BYTEA, INT8, INT8, INT4)
|
||||||
IS 'Check whether the withdrawals from the given reserve since the given time are below the given threshold';
|
IS 'Check whether the withdrawals from the given reserve since the given time are below the given threshold';
|
||||||
|
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ irbt_cb_table_reserves_in (struct PostgresClosure *pg,
|
|||||||
td->details.reserves_in.exchange_account_section),
|
td->details.reserves_in.exchange_account_section),
|
||||||
GNUNET_PQ_query_param_timestamp (
|
GNUNET_PQ_query_param_timestamp (
|
||||||
&td->details.reserves_in.execution_date),
|
&td->details.reserves_in.execution_date),
|
||||||
GNUNET_PQ_query_param_uint64 (&td->details.reserves_in.reserve_uuid),
|
GNUNET_PQ_query_param_auto_from_type (&td->details.reserves_in.reserve_pub),
|
||||||
GNUNET_PQ_query_param_end
|
GNUNET_PQ_query_param_end
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -204,7 +204,8 @@ irbt_cb_table_reserves_close (struct PostgresClosure *pg,
|
|||||||
&td->details.reserves_close.wire_target_serial_id),
|
&td->details.reserves_close.wire_target_serial_id),
|
||||||
TALER_PQ_query_param_amount (&td->details.reserves_close.amount),
|
TALER_PQ_query_param_amount (&td->details.reserves_close.amount),
|
||||||
TALER_PQ_query_param_amount (&td->details.reserves_close.closing_fee),
|
TALER_PQ_query_param_amount (&td->details.reserves_close.closing_fee),
|
||||||
GNUNET_PQ_query_param_uint64 (&td->details.reserves_close.reserve_uuid),
|
GNUNET_PQ_query_param_auto_from_type (
|
||||||
|
&td->details.reserves_close.reserve_pub),
|
||||||
GNUNET_PQ_query_param_end
|
GNUNET_PQ_query_param_end
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -232,8 +233,8 @@ irbt_cb_table_reserves_out (struct PostgresClosure *pg,
|
|||||||
&td->details.reserves_out.denominations_serial),
|
&td->details.reserves_out.denominations_serial),
|
||||||
TALER_PQ_query_param_blinded_denom_sig (
|
TALER_PQ_query_param_blinded_denom_sig (
|
||||||
&td->details.reserves_out.denom_sig),
|
&td->details.reserves_out.denom_sig),
|
||||||
GNUNET_PQ_query_param_uint64 (
|
GNUNET_PQ_query_param_auto_from_type (
|
||||||
&td->details.reserves_out.reserve_uuid),
|
&td->details.reserves_out.reserve_pub),
|
||||||
GNUNET_PQ_query_param_auto_from_type (
|
GNUNET_PQ_query_param_auto_from_type (
|
||||||
&td->details.reserves_out.reserve_sig),
|
&td->details.reserves_out.reserve_sig),
|
||||||
GNUNET_PQ_query_param_timestamp (
|
GNUNET_PQ_query_param_timestamp (
|
||||||
|
@ -277,9 +277,9 @@ lrbt_cb_table_reserves_in (void *cls,
|
|||||||
GNUNET_PQ_result_spec_uint64 (
|
GNUNET_PQ_result_spec_uint64 (
|
||||||
"serial",
|
"serial",
|
||||||
&td.serial),
|
&td.serial),
|
||||||
GNUNET_PQ_result_spec_uint64 (
|
GNUNET_PQ_result_spec_auto_from_type (
|
||||||
"reserve_uuid",
|
"reserve_pub",
|
||||||
&td.details.reserves_in.reserve_uuid),
|
&td.details.reserves_in.reserve_pub),
|
||||||
GNUNET_PQ_result_spec_uint64 (
|
GNUNET_PQ_result_spec_uint64 (
|
||||||
"wire_reference",
|
"wire_reference",
|
||||||
&td.details.reserves_in.wire_reference),
|
&td.details.reserves_in.wire_reference),
|
||||||
@ -338,9 +338,9 @@ lrbt_cb_table_reserves_close (void *cls,
|
|||||||
GNUNET_PQ_result_spec_uint64 (
|
GNUNET_PQ_result_spec_uint64 (
|
||||||
"serial",
|
"serial",
|
||||||
&td.serial),
|
&td.serial),
|
||||||
GNUNET_PQ_result_spec_uint64 (
|
GNUNET_PQ_result_spec_auto_from_type (
|
||||||
"reserve_uuid",
|
"reserve_pub",
|
||||||
&td.details.reserves_close.reserve_uuid),
|
&td.details.reserves_close.reserve_pub),
|
||||||
GNUNET_PQ_result_spec_timestamp (
|
GNUNET_PQ_result_spec_timestamp (
|
||||||
"execution_date",
|
"execution_date",
|
||||||
&td.details.reserves_close.execution_date),
|
&td.details.reserves_close.execution_date),
|
||||||
@ -408,9 +408,9 @@ lrbt_cb_table_reserves_out (void *cls,
|
|||||||
TALER_PQ_result_spec_blinded_denom_sig (
|
TALER_PQ_result_spec_blinded_denom_sig (
|
||||||
"denom_sig",
|
"denom_sig",
|
||||||
&td.details.reserves_out.denom_sig),
|
&td.details.reserves_out.denom_sig),
|
||||||
GNUNET_PQ_result_spec_uint64 (
|
GNUNET_PQ_result_spec_auto_from_type (
|
||||||
"reserve_uuid",
|
"reserve_pub",
|
||||||
&td.details.reserves_out.reserve_uuid),
|
&td.details.reserves_out.reserve_pub),
|
||||||
GNUNET_PQ_result_spec_auto_from_type (
|
GNUNET_PQ_result_spec_auto_from_type (
|
||||||
"reserve_sig",
|
"reserve_sig",
|
||||||
&td.details.reserves_out.reserve_sig),
|
&td.details.reserves_out.reserve_sig),
|
||||||
|
@ -378,7 +378,7 @@ prepare_statements (struct PostgresClosure *pg)
|
|||||||
",kyc_ok"
|
",kyc_ok"
|
||||||
",wire_target_serial_id AS payment_target_uuid"
|
",wire_target_serial_id AS payment_target_uuid"
|
||||||
" FROM reserves"
|
" FROM reserves"
|
||||||
" JOIN reserves_in ri USING (reserve_uuid)"
|
" JOIN reserves_in ri USING (reserve_pub)"
|
||||||
" JOIN wire_targets wt "
|
" JOIN wire_targets wt "
|
||||||
" ON (ri.wire_source_serial_id = wt.wire_target_serial_id)"
|
" ON (ri.wire_source_serial_id = wt.wire_target_serial_id)"
|
||||||
" WHERE reserve_pub=$1"
|
" WHERE reserve_pub=$1"
|
||||||
@ -467,7 +467,7 @@ prepare_statements (struct PostgresClosure *pg)
|
|||||||
GNUNET_PQ_make_prepare (
|
GNUNET_PQ_make_prepare (
|
||||||
"reserves_close_insert",
|
"reserves_close_insert",
|
||||||
"INSERT INTO reserves_close "
|
"INSERT INTO reserves_close "
|
||||||
"(reserve_uuid"
|
"(reserve_pub"
|
||||||
",execution_date"
|
",execution_date"
|
||||||
",wtid"
|
",wtid"
|
||||||
",wire_target_serial_id"
|
",wire_target_serial_id"
|
||||||
@ -475,9 +475,7 @@ prepare_statements (struct PostgresClosure *pg)
|
|||||||
",amount_frac"
|
",amount_frac"
|
||||||
",closing_fee_val"
|
",closing_fee_val"
|
||||||
",closing_fee_frac"
|
",closing_fee_frac"
|
||||||
") SELECT reserve_uuid, $2, $3, $4, $5, $6, $7, $8"
|
") VALUES ($1, $2, $3, $4, $5, $6, $7, $8);",
|
||||||
" FROM reserves"
|
|
||||||
" WHERE reserve_pub=$1;",
|
|
||||||
8),
|
8),
|
||||||
/* Used in #reserves_update() when the reserve is updated */
|
/* Used in #reserves_update() when the reserve is updated */
|
||||||
GNUNET_PQ_make_prepare (
|
GNUNET_PQ_make_prepare (
|
||||||
@ -494,23 +492,21 @@ prepare_statements (struct PostgresClosure *pg)
|
|||||||
GNUNET_PQ_make_prepare (
|
GNUNET_PQ_make_prepare (
|
||||||
"reserves_in_add_transaction",
|
"reserves_in_add_transaction",
|
||||||
"INSERT INTO reserves_in "
|
"INSERT INTO reserves_in "
|
||||||
"(reserve_uuid"
|
"(reserve_pub"
|
||||||
",wire_reference"
|
",wire_reference"
|
||||||
",credit_val"
|
",credit_val"
|
||||||
",credit_frac"
|
",credit_frac"
|
||||||
",exchange_account_section"
|
",exchange_account_section"
|
||||||
",wire_source_serial_id"
|
",wire_source_serial_id"
|
||||||
",execution_date"
|
",execution_date"
|
||||||
") SELECT reserve_uuid, $2, $3, $4, $5, $6, $7"
|
") VALUES ($1, $2, $3, $4, $5, $6, $7)"
|
||||||
" FROM reserves"
|
|
||||||
" WHERE reserve_pub=$1"
|
|
||||||
" ON CONFLICT DO NOTHING;",
|
" ON CONFLICT DO NOTHING;",
|
||||||
7),
|
7),
|
||||||
/* Used in #postgres_reserves_in_insert() to store transaction details */
|
/* Used in #postgres_reserves_in_insert() to store transaction details */
|
||||||
GNUNET_PQ_make_prepare (
|
GNUNET_PQ_make_prepare (
|
||||||
"reserves_in_add_by_uuid",
|
"reserves_in_add_by_pub",
|
||||||
"INSERT INTO reserves_in "
|
"INSERT INTO reserves_in "
|
||||||
"(reserve_uuid"
|
"(reserve_pub"
|
||||||
",wire_reference"
|
",wire_reference"
|
||||||
",credit_val"
|
",credit_val"
|
||||||
",credit_frac"
|
",credit_frac"
|
||||||
@ -545,7 +541,7 @@ prepare_statements (struct PostgresClosure *pg)
|
|||||||
",reserve_in_serial_id"
|
",reserve_in_serial_id"
|
||||||
" FROM reserves_in"
|
" FROM reserves_in"
|
||||||
" JOIN reserves"
|
" JOIN reserves"
|
||||||
" USING (reserve_uuid)"
|
" USING (reserve_pub)"
|
||||||
" JOIN wire_targets"
|
" JOIN wire_targets"
|
||||||
" ON (wire_source_serial_id = wire_target_serial_id)"
|
" ON (wire_source_serial_id = wire_target_serial_id)"
|
||||||
" WHERE reserve_in_serial_id>=$1"
|
" WHERE reserve_in_serial_id>=$1"
|
||||||
@ -565,7 +561,7 @@ prepare_statements (struct PostgresClosure *pg)
|
|||||||
",reserve_in_serial_id"
|
",reserve_in_serial_id"
|
||||||
" FROM reserves_in"
|
" FROM reserves_in"
|
||||||
" JOIN reserves "
|
" JOIN reserves "
|
||||||
" USING (reserve_uuid)"
|
" USING (reserve_pub)"
|
||||||
" JOIN wire_targets"
|
" JOIN wire_targets"
|
||||||
" ON (wire_source_serial_id = wire_target_serial_id)"
|
" ON (wire_source_serial_id = wire_target_serial_id)"
|
||||||
" WHERE reserve_in_serial_id>=$1 AND exchange_account_section=$2"
|
" WHERE reserve_in_serial_id>=$1 AND exchange_account_section=$2"
|
||||||
@ -584,10 +580,7 @@ prepare_statements (struct PostgresClosure *pg)
|
|||||||
" FROM reserves_in"
|
" FROM reserves_in"
|
||||||
" JOIN wire_targets"
|
" JOIN wire_targets"
|
||||||
" ON (wire_source_serial_id = wire_target_serial_id)"
|
" ON (wire_source_serial_id = wire_target_serial_id)"
|
||||||
" WHERE reserve_uuid="
|
" WHERE reserve_pub=$1;",
|
||||||
" (SELECT reserve_uuid "
|
|
||||||
" FROM reserves"
|
|
||||||
" WHERE reserve_pub=$1);",
|
|
||||||
1),
|
1),
|
||||||
/* Lock withdraw table; NOTE: we may want to eventually shard the
|
/* Lock withdraw table; NOTE: we may want to eventually shard the
|
||||||
deposit table to avoid this lock being the main point of
|
deposit table to avoid this lock being the main point of
|
||||||
@ -619,7 +612,6 @@ prepare_statements (struct PostgresClosure *pg)
|
|||||||
" reserve_found"
|
" reserve_found"
|
||||||
",balance_ok"
|
",balance_ok"
|
||||||
",kycok AS kyc_ok"
|
",kycok AS kyc_ok"
|
||||||
",ruuid AS reserve_uuid"
|
|
||||||
",account_uuid AS payment_target_uuid"
|
",account_uuid AS payment_target_uuid"
|
||||||
" FROM exchange_do_withdraw"
|
" FROM exchange_do_withdraw"
|
||||||
" ($1,$2,$3,$4,$5,$6,$7,$8,$9);",
|
" ($1,$2,$3,$4,$5,$6,$7,$8,$9);",
|
||||||
@ -643,23 +635,18 @@ prepare_statements (struct PostgresClosure *pg)
|
|||||||
authorizing the withdrawal. */
|
authorizing the withdrawal. */
|
||||||
GNUNET_PQ_make_prepare (
|
GNUNET_PQ_make_prepare (
|
||||||
"insert_withdraw_info",
|
"insert_withdraw_info",
|
||||||
"WITH ds AS"
|
|
||||||
" (SELECT denominations_serial"
|
|
||||||
" FROM denominations"
|
|
||||||
" WHERE denom_pub_hash=$2)"
|
|
||||||
"INSERT INTO reserves_out "
|
"INSERT INTO reserves_out "
|
||||||
"(h_blind_ev"
|
"(h_blind_ev"
|
||||||
",denominations_serial"
|
",denominations_serial"
|
||||||
",denom_sig"
|
",denom_sig"
|
||||||
",reserve_uuid"
|
",reserve_pub"
|
||||||
",reserve_sig"
|
",reserve_sig"
|
||||||
",execution_date"
|
",execution_date"
|
||||||
",amount_with_fee_val"
|
",amount_with_fee_val"
|
||||||
",amount_with_fee_frac"
|
",amount_with_fee_frac"
|
||||||
") SELECT $1, ds.denominations_serial, $3, reserve_uuid, $5, $6, $7, $8"
|
") SELECT $1, denominations_serial, $3, $4, $5, $6, $7, $8"
|
||||||
" FROM reserves"
|
" FROM denominations"
|
||||||
" CROSS JOIN ds"
|
" WHERE denom_pub_hash=$2;",
|
||||||
" WHERE reserve_pub=$4;",
|
|
||||||
8),
|
8),
|
||||||
/* Used in #postgres_get_withdraw_info() to
|
/* Used in #postgres_get_withdraw_info() to
|
||||||
locate the response for a /reserve/withdraw request
|
locate the response for a /reserve/withdraw request
|
||||||
@ -679,7 +666,7 @@ prepare_statements (struct PostgresClosure *pg)
|
|||||||
",denom.fee_withdraw_frac"
|
",denom.fee_withdraw_frac"
|
||||||
" FROM reserves_out"
|
" FROM reserves_out"
|
||||||
" JOIN reserves"
|
" JOIN reserves"
|
||||||
" USING (reserve_uuid)"
|
" USING (reserve_pub)"
|
||||||
" JOIN denominations denom"
|
" JOIN denominations denom"
|
||||||
" USING (denominations_serial)"
|
" USING (denominations_serial)"
|
||||||
" WHERE h_blind_ev=$1;",
|
" WHERE h_blind_ev=$1;",
|
||||||
@ -703,10 +690,7 @@ prepare_statements (struct PostgresClosure *pg)
|
|||||||
" FROM reserves_out"
|
" FROM reserves_out"
|
||||||
" JOIN denominations denom"
|
" JOIN denominations denom"
|
||||||
" USING (denominations_serial)"
|
" USING (denominations_serial)"
|
||||||
" WHERE reserve_uuid="
|
" WHERE reserve_pub=$1;",
|
||||||
" (SELECT reserve_uuid"
|
|
||||||
" FROM reserves"
|
|
||||||
" WHERE reserve_pub=$1);",
|
|
||||||
1),
|
1),
|
||||||
/* Used in #postgres_select_withdrawals_above_serial_id() */
|
/* Used in #postgres_select_withdrawals_above_serial_id() */
|
||||||
GNUNET_PQ_make_prepare (
|
GNUNET_PQ_make_prepare (
|
||||||
@ -722,7 +706,7 @@ prepare_statements (struct PostgresClosure *pg)
|
|||||||
",reserve_out_serial_id"
|
",reserve_out_serial_id"
|
||||||
" FROM reserves_out"
|
" FROM reserves_out"
|
||||||
" JOIN reserves"
|
" JOIN reserves"
|
||||||
" USING (reserve_uuid)"
|
" USING (reserve_pub)"
|
||||||
" JOIN denominations denom"
|
" JOIN denominations denom"
|
||||||
" USING (denominations_serial)"
|
" USING (denominations_serial)"
|
||||||
" WHERE reserve_out_serial_id>=$1"
|
" WHERE reserve_out_serial_id>=$1"
|
||||||
@ -1531,7 +1515,7 @@ prepare_statements (struct PostgresClosure *pg)
|
|||||||
" JOIN reserves_out ro"
|
" JOIN reserves_out ro"
|
||||||
" USING (reserve_out_serial_id)"
|
" USING (reserve_out_serial_id)"
|
||||||
" JOIN reserves"
|
" JOIN reserves"
|
||||||
" USING (reserve_uuid)"
|
" USING (reserve_pub)"
|
||||||
" JOIN denominations denoms"
|
" JOIN denominations denoms"
|
||||||
" ON (coins.denominations_serial = denoms.denominations_serial)"
|
" ON (coins.denominations_serial = denoms.denominations_serial)"
|
||||||
" WHERE recoup_uuid>=$1"
|
" WHERE recoup_uuid>=$1"
|
||||||
@ -1589,7 +1573,7 @@ prepare_statements (struct PostgresClosure *pg)
|
|||||||
" JOIN wire_targets"
|
" JOIN wire_targets"
|
||||||
" USING (wire_target_serial_id)"
|
" USING (wire_target_serial_id)"
|
||||||
" JOIN reserves"
|
" JOIN reserves"
|
||||||
" USING (reserve_uuid)"
|
" USING (reserve_pub)"
|
||||||
" WHERE close_uuid>=$1"
|
" WHERE close_uuid>=$1"
|
||||||
" ORDER BY close_uuid ASC;",
|
" ORDER BY close_uuid ASC;",
|
||||||
1),
|
1),
|
||||||
@ -1613,10 +1597,7 @@ prepare_statements (struct PostgresClosure *pg)
|
|||||||
" USING (denominations_serial)"
|
" USING (denominations_serial)"
|
||||||
" JOIN reserves_out ro"
|
" JOIN reserves_out ro"
|
||||||
" USING (reserve_out_serial_id)"
|
" USING (reserve_out_serial_id)"
|
||||||
" WHERE ro.reserve_uuid="
|
" WHERE ro.reserve_pub=$1;",
|
||||||
" (SELECT reserve_uuid"
|
|
||||||
" FROM reserves"
|
|
||||||
" WHERE reserve_pub=$1);",
|
|
||||||
1),
|
1),
|
||||||
/* Used in #postgres_get_coin_transactions() to obtain recoup transactions
|
/* Used in #postgres_get_coin_transactions() to obtain recoup transactions
|
||||||
affecting old coins of refreshed coins */
|
affecting old coins of refreshed coins */
|
||||||
@ -1661,10 +1642,7 @@ prepare_statements (struct PostgresClosure *pg)
|
|||||||
" FROM reserves_close"
|
" FROM reserves_close"
|
||||||
" JOIN wire_targets"
|
" JOIN wire_targets"
|
||||||
" USING (wire_target_serial_id)"
|
" USING (wire_target_serial_id)"
|
||||||
" WHERE reserve_uuid="
|
" WHERE reserve_pub=$1;",
|
||||||
" (SELECT reserve_uuid"
|
|
||||||
" FROM reserves"
|
|
||||||
" WHERE reserve_pub=$1);",
|
|
||||||
1),
|
1),
|
||||||
/* Used in #postgres_get_expired_reserves() */
|
/* Used in #postgres_get_expired_reserves() */
|
||||||
GNUNET_PQ_make_prepare (
|
GNUNET_PQ_make_prepare (
|
||||||
@ -1677,7 +1655,7 @@ prepare_statements (struct PostgresClosure *pg)
|
|||||||
",current_balance_frac"
|
",current_balance_frac"
|
||||||
" FROM reserves"
|
" FROM reserves"
|
||||||
" JOIN reserves_in ri"
|
" JOIN reserves_in ri"
|
||||||
" USING (reserve_uuid)"
|
" USING (reserve_pub)"
|
||||||
" JOIN wire_targets wt"
|
" JOIN wire_targets wt"
|
||||||
" ON (ri.wire_source_serial_id = wt.wire_target_serial_id)"
|
" ON (ri.wire_source_serial_id = wt.wire_target_serial_id)"
|
||||||
" WHERE expiration_date<=$1"
|
" WHERE expiration_date<=$1"
|
||||||
@ -1703,7 +1681,7 @@ prepare_statements (struct PostgresClosure *pg)
|
|||||||
" JOIN reserves_out ro"
|
" JOIN reserves_out ro"
|
||||||
" USING (reserve_out_serial_id)"
|
" USING (reserve_out_serial_id)"
|
||||||
" JOIN reserves"
|
" JOIN reserves"
|
||||||
" USING (reserve_uuid)"
|
" USING (reserve_pub)"
|
||||||
" JOIN known_coins coins"
|
" JOIN known_coins coins"
|
||||||
" USING (known_coin_id)"
|
" USING (known_coin_id)"
|
||||||
" JOIN denominations denoms"
|
" JOIN denominations denoms"
|
||||||
@ -1744,7 +1722,7 @@ prepare_statements (struct PostgresClosure *pg)
|
|||||||
" reserves.reserve_pub"
|
" reserves.reserve_pub"
|
||||||
" FROM reserves_out"
|
" FROM reserves_out"
|
||||||
" JOIN reserves"
|
" JOIN reserves"
|
||||||
" USING (reserve_uuid)"
|
" USING (reserve_pub)"
|
||||||
" WHERE h_blind_ev=$1"
|
" WHERE h_blind_ev=$1"
|
||||||
" LIMIT 1;",
|
" LIMIT 1;",
|
||||||
1),
|
1),
|
||||||
@ -1952,10 +1930,7 @@ prepare_statements (struct PostgresClosure *pg)
|
|||||||
" amount_with_fee_val"
|
" amount_with_fee_val"
|
||||||
",amount_with_fee_frac"
|
",amount_with_fee_frac"
|
||||||
" FROM reserves_out"
|
" FROM reserves_out"
|
||||||
" WHERE reserve_uuid="
|
" WHERE reserve_pub=$1"
|
||||||
" (SELECT reserve_uuid"
|
|
||||||
" FROM reserves"
|
|
||||||
" WHERE reserve_pub=$1)"
|
|
||||||
" AND execution_date > $2;",
|
" AND execution_date > $2;",
|
||||||
2),
|
2),
|
||||||
/* used in #postgres_lookup_wire_fee_by_time() */
|
/* used in #postgres_lookup_wire_fee_by_time() */
|
||||||
@ -2199,7 +2174,7 @@ prepare_statements (struct PostgresClosure *pg)
|
|||||||
"select_above_serial_by_table_reserves_in",
|
"select_above_serial_by_table_reserves_in",
|
||||||
"SELECT"
|
"SELECT"
|
||||||
" reserve_in_serial_id AS serial"
|
" reserve_in_serial_id AS serial"
|
||||||
",reserve_uuid"
|
",reserve_pub"
|
||||||
",wire_reference"
|
",wire_reference"
|
||||||
",credit_val"
|
",credit_val"
|
||||||
",credit_frac"
|
",credit_frac"
|
||||||
@ -2214,7 +2189,7 @@ prepare_statements (struct PostgresClosure *pg)
|
|||||||
"select_above_serial_by_table_reserves_close",
|
"select_above_serial_by_table_reserves_close",
|
||||||
"SELECT"
|
"SELECT"
|
||||||
" close_uuid AS serial"
|
" close_uuid AS serial"
|
||||||
",reserve_uuid"
|
",reserve_pub"
|
||||||
",execution_date"
|
",execution_date"
|
||||||
",wtid"
|
",wtid"
|
||||||
",wire_target_serial_id"
|
",wire_target_serial_id"
|
||||||
@ -2233,7 +2208,7 @@ prepare_statements (struct PostgresClosure *pg)
|
|||||||
",h_blind_ev"
|
",h_blind_ev"
|
||||||
",denominations_serial"
|
",denominations_serial"
|
||||||
",denom_sig"
|
",denom_sig"
|
||||||
",reserve_uuid"
|
",reserve_pub"
|
||||||
",reserve_sig"
|
",reserve_sig"
|
||||||
",execution_date"
|
",execution_date"
|
||||||
",amount_with_fee_val"
|
",amount_with_fee_val"
|
||||||
@ -2504,7 +2479,7 @@ prepare_statements (struct PostgresClosure *pg)
|
|||||||
",wire_source_serial_id"
|
",wire_source_serial_id"
|
||||||
",exchange_account_section"
|
",exchange_account_section"
|
||||||
",execution_date"
|
",execution_date"
|
||||||
",reserve_uuid"
|
",reserve_pub"
|
||||||
") VALUES "
|
") VALUES "
|
||||||
"($1, $2, $3, $4, $5, $6, $7, $8);",
|
"($1, $2, $3, $4, $5, $6, $7, $8);",
|
||||||
8),
|
8),
|
||||||
@ -2519,7 +2494,7 @@ prepare_statements (struct PostgresClosure *pg)
|
|||||||
",amount_frac"
|
",amount_frac"
|
||||||
",closing_fee_val"
|
",closing_fee_val"
|
||||||
",closing_fee_frac"
|
",closing_fee_frac"
|
||||||
",reserve_uuid"
|
",reserve_pub"
|
||||||
") VALUES "
|
") VALUES "
|
||||||
"($1, $2, $3, $4, $5, $6, $7, $8, $9);",
|
"($1, $2, $3, $4, $5, $6, $7, $8, $9);",
|
||||||
9),
|
9),
|
||||||
@ -2530,7 +2505,7 @@ prepare_statements (struct PostgresClosure *pg)
|
|||||||
",h_blind_ev"
|
",h_blind_ev"
|
||||||
",denominations_serial"
|
",denominations_serial"
|
||||||
",denom_sig"
|
",denom_sig"
|
||||||
",reserve_uuid"
|
",reserve_pub"
|
||||||
",reserve_sig"
|
",reserve_sig"
|
||||||
",execution_date"
|
",execution_date"
|
||||||
",amount_with_fee_val"
|
",amount_with_fee_val"
|
||||||
@ -4249,41 +4224,21 @@ postgres_reserves_in_insert (void *cls,
|
|||||||
return qs3;
|
return qs3;
|
||||||
}
|
}
|
||||||
GNUNET_assert (0 != kyc.payment_target_uuid);
|
GNUNET_assert (0 != kyc.payment_target_uuid);
|
||||||
if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs1)
|
/* We do not have the UUID, so insert by public key */
|
||||||
{
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
/* We do not have the UUID, so insert by public key */
|
GNUNET_PQ_query_param_auto_from_type (&reserve.pub),
|
||||||
struct GNUNET_PQ_QueryParam params[] = {
|
GNUNET_PQ_query_param_uint64 (&wire_ref),
|
||||||
GNUNET_PQ_query_param_auto_from_type (&reserve.pub),
|
TALER_PQ_query_param_amount (balance),
|
||||||
GNUNET_PQ_query_param_uint64 (&wire_ref),
|
GNUNET_PQ_query_param_string (exchange_account_section),
|
||||||
TALER_PQ_query_param_amount (balance),
|
GNUNET_PQ_query_param_uint64 (&kyc.payment_target_uuid),
|
||||||
GNUNET_PQ_query_param_string (exchange_account_section),
|
GNUNET_PQ_query_param_timestamp (&execution_time),
|
||||||
GNUNET_PQ_query_param_uint64 (&kyc.payment_target_uuid),
|
GNUNET_PQ_query_param_end
|
||||||
GNUNET_PQ_query_param_timestamp (&execution_time),
|
};
|
||||||
GNUNET_PQ_query_param_end
|
|
||||||
};
|
|
||||||
|
|
||||||
qs2 = GNUNET_PQ_eval_prepared_non_select (pg->conn,
|
qs2 = GNUNET_PQ_eval_prepared_non_select (pg->conn,
|
||||||
"reserves_in_add_transaction",
|
"reserves_in_add_transaction",
|
||||||
params);
|
params);
|
||||||
}
|
/* qs2 could be 0 as statement used 'ON CONFLICT DO NOTHING' */
|
||||||
else
|
|
||||||
{
|
|
||||||
/* We do have the UUID, use that for the insert */
|
|
||||||
struct GNUNET_PQ_QueryParam params[] = {
|
|
||||||
GNUNET_PQ_query_param_uint64 (&reserve_uuid),
|
|
||||||
GNUNET_PQ_query_param_uint64 (&wire_ref),
|
|
||||||
TALER_PQ_query_param_amount (balance),
|
|
||||||
GNUNET_PQ_query_param_string (exchange_account_section),
|
|
||||||
GNUNET_PQ_query_param_uint64 (&kyc.payment_target_uuid),
|
|
||||||
GNUNET_PQ_query_param_timestamp (&execution_time),
|
|
||||||
GNUNET_PQ_query_param_end
|
|
||||||
};
|
|
||||||
|
|
||||||
qs2 = GNUNET_PQ_eval_prepared_non_select (pg->conn,
|
|
||||||
"reserves_in_add_by_uuid",
|
|
||||||
params);
|
|
||||||
}
|
|
||||||
/* qs2 could be 0 as both statements used 'ON CONFLICT DO NOTHING' */
|
|
||||||
if (0 >= qs2)
|
if (0 >= qs2)
|
||||||
{
|
{
|
||||||
if ( (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs2) &&
|
if ( (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs2) &&
|
||||||
@ -4558,7 +4513,6 @@ postgres_do_check_coin_balance (
|
|||||||
* @param[out] found set to true if the reserve was found
|
* @param[out] found set to true if the reserve was found
|
||||||
* @param[out] balance_ok set to true if the balance was sufficient
|
* @param[out] balance_ok set to true if the balance was sufficient
|
||||||
* @param[out] kyc_ok set to true if the kyc status of the reserve is satisfied
|
* @param[out] kyc_ok set to true if the kyc status of the reserve is satisfied
|
||||||
* @param[out] reserve_uuid set to the UUID of the reserve
|
|
||||||
* @return query execution status
|
* @return query execution status
|
||||||
*/
|
*/
|
||||||
static enum GNUNET_DB_QueryStatus
|
static enum GNUNET_DB_QueryStatus
|
||||||
@ -4568,8 +4522,7 @@ postgres_do_withdraw (
|
|||||||
struct GNUNET_TIME_Timestamp now,
|
struct GNUNET_TIME_Timestamp now,
|
||||||
bool *found,
|
bool *found,
|
||||||
bool *balance_ok,
|
bool *balance_ok,
|
||||||
struct TALER_EXCHANGEDB_KycStatus *kyc,
|
struct TALER_EXCHANGEDB_KycStatus *kyc)
|
||||||
uint64_t *reserve_uuid)
|
|
||||||
{
|
{
|
||||||
struct PostgresClosure *pg = cls;
|
struct PostgresClosure *pg = cls;
|
||||||
struct GNUNET_TIME_Timestamp gc;
|
struct GNUNET_TIME_Timestamp gc;
|
||||||
@ -4591,8 +4544,6 @@ postgres_do_withdraw (
|
|||||||
balance_ok),
|
balance_ok),
|
||||||
GNUNET_PQ_result_spec_bool ("kyc_ok",
|
GNUNET_PQ_result_spec_bool ("kyc_ok",
|
||||||
&kyc->ok),
|
&kyc->ok),
|
||||||
GNUNET_PQ_result_spec_uint64 ("reserve_uuid",
|
|
||||||
reserve_uuid),
|
|
||||||
GNUNET_PQ_result_spec_uint64 ("payment_target_uuid",
|
GNUNET_PQ_result_spec_uint64 ("payment_target_uuid",
|
||||||
&kyc->payment_target_uuid),
|
&kyc->payment_target_uuid),
|
||||||
GNUNET_PQ_result_spec_end
|
GNUNET_PQ_result_spec_end
|
||||||
@ -4624,14 +4575,14 @@ postgres_do_withdraw (
|
|||||||
static enum GNUNET_DB_QueryStatus
|
static enum GNUNET_DB_QueryStatus
|
||||||
postgres_do_withdraw_limit_check (
|
postgres_do_withdraw_limit_check (
|
||||||
void *cls,
|
void *cls,
|
||||||
uint64_t reserve_uuid,
|
const struct TALER_ReservePublicKeyP *reserve_pub,
|
||||||
struct GNUNET_TIME_Absolute withdraw_start,
|
struct GNUNET_TIME_Absolute withdraw_start,
|
||||||
const struct TALER_Amount *upper_limit,
|
const struct TALER_Amount *upper_limit,
|
||||||
bool *below_limit)
|
bool *below_limit)
|
||||||
{
|
{
|
||||||
struct PostgresClosure *pg = cls;
|
struct PostgresClosure *pg = cls;
|
||||||
struct GNUNET_PQ_QueryParam params[] = {
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
GNUNET_PQ_query_param_uint64 (&reserve_uuid),
|
GNUNET_PQ_query_param_auto_from_type (reserve_pub),
|
||||||
GNUNET_PQ_query_param_absolute_time (&withdraw_start),
|
GNUNET_PQ_query_param_absolute_time (&withdraw_start),
|
||||||
TALER_PQ_query_param_amount (upper_limit),
|
TALER_PQ_query_param_amount (upper_limit),
|
||||||
GNUNET_PQ_query_param_end
|
GNUNET_PQ_query_param_end
|
||||||
|
@ -1674,7 +1674,6 @@ run (void *cls)
|
|||||||
bool found;
|
bool found;
|
||||||
bool balance_ok;
|
bool balance_ok;
|
||||||
struct TALER_EXCHANGEDB_KycStatus kyc;
|
struct TALER_EXCHANGEDB_KycStatus kyc;
|
||||||
uint64_t ruuid;
|
|
||||||
|
|
||||||
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
|
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
|
||||||
plugin->do_withdraw (plugin->cls,
|
plugin->do_withdraw (plugin->cls,
|
||||||
@ -1682,8 +1681,7 @@ run (void *cls)
|
|||||||
now,
|
now,
|
||||||
&found,
|
&found,
|
||||||
&balance_ok,
|
&balance_ok,
|
||||||
&kyc,
|
&kyc));
|
||||||
&ruuid));
|
|
||||||
GNUNET_assert (found);
|
GNUNET_assert (found);
|
||||||
GNUNET_assert (balance_ok);
|
GNUNET_assert (balance_ok);
|
||||||
GNUNET_assert (! kyc.ok);
|
GNUNET_assert (! kyc.ok);
|
||||||
|
@ -239,12 +239,12 @@ struct TALER_EXCHANGEDB_TableData
|
|||||||
uint64_t sender_account;
|
uint64_t sender_account;
|
||||||
char *exchange_account_section;
|
char *exchange_account_section;
|
||||||
struct GNUNET_TIME_Timestamp execution_date;
|
struct GNUNET_TIME_Timestamp execution_date;
|
||||||
uint64_t reserve_uuid;
|
struct TALER_ReservePublicKeyP reserve_pub;
|
||||||
} reserves_in;
|
} reserves_in;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
uint64_t reserve_uuid;
|
struct TALER_ReservePublicKeyP reserve_pub;
|
||||||
struct GNUNET_TIME_Timestamp execution_date;
|
struct GNUNET_TIME_Timestamp execution_date;
|
||||||
struct TALER_WireTransferIdentifierRawP wtid;
|
struct TALER_WireTransferIdentifierRawP wtid;
|
||||||
uint64_t wire_target_serial_id;
|
uint64_t wire_target_serial_id;
|
||||||
@ -257,7 +257,7 @@ struct TALER_EXCHANGEDB_TableData
|
|||||||
struct TALER_BlindedCoinHash h_blind_ev;
|
struct TALER_BlindedCoinHash h_blind_ev;
|
||||||
uint64_t denominations_serial;
|
uint64_t denominations_serial;
|
||||||
struct TALER_BlindedDenominationSignature denom_sig;
|
struct TALER_BlindedDenominationSignature denom_sig;
|
||||||
uint64_t reserve_uuid;
|
struct TALER_ReservePublicKeyP reserve_pub;
|
||||||
struct TALER_ReserveSignatureP reserve_sig;
|
struct TALER_ReserveSignatureP reserve_sig;
|
||||||
struct GNUNET_TIME_Timestamp execution_date;
|
struct GNUNET_TIME_Timestamp execution_date;
|
||||||
struct TALER_Amount amount_with_fee;
|
struct TALER_Amount amount_with_fee;
|
||||||
@ -2537,7 +2537,6 @@ struct TALER_EXCHANGEDB_Plugin
|
|||||||
* @param[out] found set to true if the reserve was found
|
* @param[out] found set to true if the reserve was found
|
||||||
* @param[out] balance_ok set to true if the balance was sufficient
|
* @param[out] balance_ok set to true if the balance was sufficient
|
||||||
* @param[out] kyc set to the KYC status of the reserve
|
* @param[out] kyc set to the KYC status of the reserve
|
||||||
* @param[out] reserve_uuid set to the UUID of the reserve
|
|
||||||
* @return query execution status
|
* @return query execution status
|
||||||
*/
|
*/
|
||||||
enum GNUNET_DB_QueryStatus
|
enum GNUNET_DB_QueryStatus
|
||||||
@ -2547,8 +2546,7 @@ struct TALER_EXCHANGEDB_Plugin
|
|||||||
struct GNUNET_TIME_Timestamp now,
|
struct GNUNET_TIME_Timestamp now,
|
||||||
bool *found,
|
bool *found,
|
||||||
bool *balance_ok,
|
bool *balance_ok,
|
||||||
struct TALER_EXCHANGEDB_KycStatus *kyc_ok,
|
struct TALER_EXCHANGEDB_KycStatus *kyc_ok);
|
||||||
uint64_t *reserve_uuid);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2556,7 +2554,7 @@ struct TALER_EXCHANGEDB_Plugin
|
|||||||
* checks after withdraw operation.
|
* checks after withdraw operation.
|
||||||
*
|
*
|
||||||
* @param cls the `struct PostgresClosure` with the plugin-specific state
|
* @param cls the `struct PostgresClosure` with the plugin-specific state
|
||||||
* @param reserve_uuid reserve to check
|
* @param reserve_pub reserve to check
|
||||||
* @param withdraw_start starting point to accumulate from
|
* @param withdraw_start starting point to accumulate from
|
||||||
* @param upper_limit maximum amount allowed
|
* @param upper_limit maximum amount allowed
|
||||||
* @param[out] below_limit set to true if the limit was not exceeded
|
* @param[out] below_limit set to true if the limit was not exceeded
|
||||||
@ -2565,7 +2563,7 @@ struct TALER_EXCHANGEDB_Plugin
|
|||||||
enum GNUNET_DB_QueryStatus
|
enum GNUNET_DB_QueryStatus
|
||||||
(*do_withdraw_limit_check)(
|
(*do_withdraw_limit_check)(
|
||||||
void *cls,
|
void *cls,
|
||||||
uint64_t reserve_uuid,
|
const struct TALER_ReservePublicKeyP *reserve_pub,
|
||||||
struct GNUNET_TIME_Absolute withdraw_start,
|
struct GNUNET_TIME_Absolute withdraw_start,
|
||||||
const struct TALER_Amount *upper_limit,
|
const struct TALER_Amount *upper_limit,
|
||||||
bool *below_limit);
|
bool *below_limit);
|
||||||
|
Loading…
Reference in New Issue
Block a user