From 13d90bb1a3962272d82da47aa5e193103a2014ae Mon Sep 17 00:00:00 2001
From: Christian Grothoff <christian@grothoff.org>
Date: Sun, 19 Feb 2023 21:46:15 +0100
Subject: on idempotent deposit, just skip most of the transaction

---
 src/exchangedb/exchange_do_purse_deposit.sql | 7 +++++++
 1 file changed, 7 insertions(+)

(limited to 'src/exchangedb/exchange_do_purse_deposit.sql')

diff --git a/src/exchangedb/exchange_do_purse_deposit.sql b/src/exchangedb/exchange_do_purse_deposit.sql
index 7ea426b77..d710e9002 100644
--- a/src/exchangedb/exchange_do_purse_deposit.sql
+++ b/src/exchangedb/exchange_do_purse_deposit.sql
@@ -67,6 +67,7 @@ IF NOT FOUND
 THEN
   -- Idempotency check: check if coin_sig is the same,
   -- if so, success, otherwise conflict!
+
   PERFORM
   FROM exchange.purse_deposits
   WHERE coin_pub = in_coin_pub
@@ -79,6 +80,12 @@ THEN
     out_late=FALSE;
     out_conflict=TRUE;
     RETURN;
+  ELSE
+    -- Deposit exists, do not count for balance. Allow.
+    out_late=FALSE;
+    out_balance_ok=TRUE;
+    out_conflict=FALSE;
+    RETURN;
   END IF;
 END IF;
 
-- 
cgit v1.2.3

