on idempotent deposit, just skip most of the transaction

This commit is contained in:
Christian Grothoff 2023-02-19 21:46:15 +01:00
parent e2fe36a0be
commit 13d90bb1a3
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
2 changed files with 16 additions and 1 deletions

View File

@ -67,6 +67,7 @@ IF NOT FOUND
THEN THEN
-- Idempotency check: check if coin_sig is the same, -- Idempotency check: check if coin_sig is the same,
-- if so, success, otherwise conflict! -- if so, success, otherwise conflict!
PERFORM PERFORM
FROM exchange.purse_deposits FROM exchange.purse_deposits
WHERE coin_pub = in_coin_pub WHERE coin_pub = in_coin_pub
@ -79,6 +80,12 @@ THEN
out_late=FALSE; out_late=FALSE;
out_conflict=TRUE; out_conflict=TRUE;
RETURN; 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;
END IF; END IF;

View File

@ -1,6 +1,6 @@
/* /*
This file is part of TALER This file is part of TALER
Copyright (C) 2014--2022 Taler Systems SA Copyright (C) 2014--2023 Taler Systems SA
TALER is free software; you can redistribute it and/or modify TALER is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as it under the terms of the GNU General Public License as
@ -250,6 +250,14 @@ run (void *cls,
"withdraw-coin-1", "withdraw-coin-1",
"EUR:1.01", "EUR:1.01",
NULL), NULL),
TALER_TESTING_cmd_purse_deposit_coins (
"purse-deposit-coins-idempotent-but-gone",
MHD_HTTP_GONE,
0 /* min age */,
"purse-create-with-reserve",
"withdraw-coin-1",
"EUR:1.01",
NULL),
TALER_TESTING_cmd_purse_poll_finish ( TALER_TESTING_cmd_purse_poll_finish (
"pull-deposit-purse-poll-finish", "pull-deposit-purse-poll-finish",
GNUNET_TIME_relative_multiply ( GNUNET_TIME_relative_multiply (