summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2023-11-03 16:17:20 +0100
committerChristian Grothoff <christian@grothoff.org>2023-11-03 16:17:20 +0100
commit94e8ecf90f4e66456aed4f15cece3ca3da81bf4c (patch)
treee89921a0dd4d65b196f4c77c9bf20d47257fd451
parentee57a5f9c481555d0462012439a99778a2dbcbcb (diff)
downloadexchange-94e8ecf90f4e66456aed4f15cece3ca3da81bf4c.tar.gz
exchange-94e8ecf90f4e66456aed4f15cece3ca3da81bf4c.tar.bz2
exchange-94e8ecf90f4e66456aed4f15cece3ca3da81bf4c.zip
towards real-time deposit auditor: ideas
-rw-r--r--src/auditor/taler-helper-auditor-deposits.c21
-rw-r--r--src/auditordb/auditor-0001.sql7
2 files changed, 28 insertions, 0 deletions
diff --git a/src/auditor/taler-helper-auditor-deposits.c b/src/auditor/taler-helper-auditor-deposits.c
index fc7395994..8ec2b223e 100644
--- a/src/auditor/taler-helper-auditor-deposits.c
+++ b/src/auditor/taler-helper-auditor-deposits.c
@@ -30,6 +30,27 @@
#include "taler_signatures.h"
#include "report-lib.h"
+/*
+--
+-- SELECT serial_id,h_contract_terms,h_wire,merchant_pub ...
+-- FROM auditor.depoist_confirmations
+-- WHERE NOT ancient
+-- ORDER BY exchange_timestamp ASC;
+-- SELECT 1
+- FROM exchange.deposits dep
+ WHERE ($RESULT.contract_terms = dep.h_contract_terms) AND ($RESULT.h_wire = dep.h_wire) AND ...);
+-- IF FOUND
+-- DELETE FROM auditor.depoist_confirmations
+-- WHERE serial_id = $RESULT.serial_id;
+-- SELECT exchange_timestamp AS latest
+-- FROM exchange.deposits ORDER BY exchange_timestamp DESC;
+-- latest -= 1 hour; // time is not exactly monotonic...
+-- UPDATE auditor.deposit_confirmations
+-- SET ancient=TRUE
+-- WHERE exchange_timestamp < latest
+-- AND NOT ancient;
+*/
+
/**
* Return value from main().
diff --git a/src/auditordb/auditor-0001.sql b/src/auditordb/auditor-0001.sql
index b755da4b0..e54641ac4 100644
--- a/src/auditordb/auditor-0001.sql
+++ b/src/auditordb/auditor-0001.sql
@@ -296,11 +296,18 @@ CREATE TABLE IF NOT EXISTS deposit_confirmations
,exchange_sig BYTEA NOT NULL CHECK (LENGTH(exchange_sig)=64)
,exchange_pub BYTEA NOT NULL CHECK (LENGTH(exchange_pub)=32)
,master_sig BYTEA NOT NULL CHECK (LENGTH(master_sig)=64)
+ ,suppressed BOOLEAN NOT NULL DEFAULT FALSE,
+ ,ancient BOOLEAN NOT NULL DEFAULT FALSE,
,PRIMARY KEY (h_contract_terms,h_wire,merchant_pub,exchange_sig,exchange_pub,master_sig)
);
COMMENT ON TABLE deposit_confirmations
IS 'deposit confirmation sent to us by merchants; we must check that the exchange reported these properly.';
+CREATE INDEX IF NOT EXISTS auditor_deposit_confirmations_not_ancient
+ ON deposit_confirmations
+ (exchange_timestamp ASC)
+ WHERE NOT ancient;
+
CREATE TABLE IF NOT EXISTS auditor_predicted_result
(master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE