diff options
| author | Christian Grothoff <christian@grothoff.org> | 2022-08-14 19:03:30 +0200 | 
|---|---|---|
| committer | Christian Grothoff <christian@grothoff.org> | 2022-08-14 19:03:30 +0200 | 
| commit | f5b99b5282e50bfaf744941d22bb5766cec76cb9 (patch) | |
| tree | eb708484c296852f75ffccc91edf5a5efeb45a4a /src/exchangedb | |
| parent | 3e6e873367c0c6b257201867e62ff552b6a0f444 (diff) | |
-work on new KYC logic: remove old DB code
Diffstat (limited to 'src/exchangedb')
| -rw-r--r-- | src/exchangedb/plugin_exchangedb_postgres.c | 50 | ||||
| -rw-r--r-- | src/exchangedb/procedures.sql | 42 | 
2 files changed, 0 insertions, 92 deletions
| diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c index 25d30d00..cf995e36 100644 --- a/src/exchangedb/plugin_exchangedb_postgres.c +++ b/src/exchangedb/plugin_exchangedb_postgres.c @@ -890,16 +890,6 @@ prepare_statements (struct PostgresClosure *pg)        " FROM exchange_do_batch_withdraw_insert"        " ($1,$2,$3,$4,$5,$6,$7,$8,$9);",        9), -    /* Used in #postgres_do_withdraw_limit_check() to check -       if the withdrawals remain below the limit under which -       KYC is not required. */ -    GNUNET_PQ_make_prepare ( -      "call_withdraw_limit_check", -      "SELECT " -      " below_limit" -      " FROM exchange_do_withdraw_limit_check" -      " ($1,$2,$3,$4);", -      4),      /* Used in #postgres_do_deposit() to execute a deposit,         checking the coin's balance in the process as needed. */      GNUNET_PQ_make_prepare ( @@ -6300,45 +6290,6 @@ postgres_do_batch_withdraw_insert (  /** - * Check that reserve remains below threshold for KYC - * checks after withdraw operation. - * - * @param cls the `struct PostgresClosure` with the plugin-specific state - * @param ruuid reserve to check - * @param withdraw_start starting point to accumulate from - * @param upper_limit maximum amount allowed - * @param[out] below_limit set to true if the limit was not exceeded - * @return query execution status - */ -static enum GNUNET_DB_QueryStatus -postgres_do_withdraw_limit_check ( -  void *cls, -  uint64_t ruuid, -  struct GNUNET_TIME_Absolute withdraw_start, -  const struct TALER_Amount *upper_limit, -  bool *below_limit) -{ -  struct PostgresClosure *pg = cls; -  struct GNUNET_PQ_QueryParam params[] = { -    GNUNET_PQ_query_param_uint64 (&ruuid), -    GNUNET_PQ_query_param_absolute_time (&withdraw_start), -    TALER_PQ_query_param_amount (upper_limit), -    GNUNET_PQ_query_param_end -  }; -  struct GNUNET_PQ_ResultSpec rs[] = { -    GNUNET_PQ_result_spec_bool ("below_limit", -                                below_limit), -    GNUNET_PQ_result_spec_end -  }; - -  return GNUNET_PQ_eval_prepared_singleton_select (pg->conn, -                                                   "call_withdraw_limit_check", -                                                   params, -                                                   rs); -} - - -/**   * Compute the shard number of a given @a merchant_pub.   *   * @param merchant_pub merchant public key to compute shard for @@ -17219,7 +17170,6 @@ libtaler_plugin_exchangedb_postgres_init (void *cls)    plugin->do_withdraw = &postgres_do_withdraw;    plugin->do_batch_withdraw = &postgres_do_batch_withdraw;    plugin->do_batch_withdraw_insert = &postgres_do_batch_withdraw_insert; -  plugin->do_withdraw_limit_check = &postgres_do_withdraw_limit_check;    plugin->do_deposit = &postgres_do_deposit;    plugin->do_melt = &postgres_do_melt;    plugin->do_refund = &postgres_do_refund; diff --git a/src/exchangedb/procedures.sql b/src/exchangedb/procedures.sql index 447a5ce3..28a074b4 100644 --- a/src/exchangedb/procedures.sql +++ b/src/exchangedb/procedures.sql @@ -409,48 +409,6 @@ COMMENT ON FUNCTION exchange_do_batch_withdraw_insert(BYTEA, INT8, INT4, BYTEA, -CREATE OR REPLACE FUNCTION exchange_do_withdraw_limit_check( -  IN ruuid INT8, -  IN start_time INT8, -  IN upper_limit_val INT8, -  IN upper_limit_frac INT4, -  OUT below_limit BOOLEAN) -LANGUAGE plpgsql -AS $$ -DECLARE -  total_val INT8; -DECLARE -  total_frac INT8; -- INT4 could overflow during accumulation! -BEGIN --- NOTE: Read-only, but crosses shards. --- Shards: reserves by reserve_pub ---         reserves_out by reserve_uuid -- crosses shards!! - - -SELECT -   SUM(amount_with_fee_val) -- overflow here is not plausible -  ,SUM(CAST(amount_with_fee_frac AS INT8)) -- compute using 64 bits -  INTO -   total_val -  ,total_frac -  FROM exchange.reserves_out - WHERE reserve_uuid=ruuid -   AND execution_date > start_time; - --- normalize result -total_val = total_val + total_frac / 100000000; -total_frac = total_frac % 100000000; - --- compare to threshold -below_limit = (total_val < upper_limit_val) OR -            ( (total_val = upper_limit_val) AND -              (total_frac <= upper_limit_frac) ); -END $$; - -COMMENT ON FUNCTION exchange_do_withdraw_limit_check(INT8, INT8, INT8, INT4) -  IS 'Check whether the withdrawals from the given reserve since the given time are below the given threshold'; - -  -- NOTE: experiment, currently dead, see postgres_Start_deferred_wire_out;  -- now done inline. FIXME: Remove code here once inline version is confirmed working nicely!  CREATE OR REPLACE PROCEDURE defer_wire_out() | 
