aboutsummaryrefslogtreecommitdiff
path: root/src/exchangedb
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-07-08 19:36:08 +0200
committerChristian Grothoff <christian@grothoff.org>2020-07-08 19:36:08 +0200
commitc3cd21508b0900ee5437edb3828b4b7c2f359495 (patch)
tree04058188f8a2772e3ebdcdc7564de57322a019f5 /src/exchangedb
parentc93f64710674bb4f635288c5e326f2cf47b8e8c7 (diff)
synchronize with latest GANA
Diffstat (limited to 'src/exchangedb')
-rw-r--r--src/exchangedb/plugin_exchangedb_postgres.c42
-rw-r--r--src/exchangedb/test_exchangedb.c6
2 files changed, 30 insertions, 18 deletions
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c
index 0f96f0e86..8e45d6711 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -3187,7 +3187,7 @@ postgres_count_known_coins (void *cls,
* @param coin the coin that must be made known
* @return database transaction status, non-negative on success
*/
-static enum GNUNET_DB_QueryStatus
+static enum TALER_EXCHANGEDB_CoinKnownStatus
postgres_ensure_coin_known (void *cls,
struct TALER_EXCHANGEDB_Session *session,
const struct TALER_CoinPublicInfo *coin)
@@ -3207,33 +3207,45 @@ postgres_ensure_coin_known (void *cls,
#endif
/* check if the coin is already known */
+ // FIXME: modify to not also fetch the RSA signature, needlessly costly!
qs = postgres_get_known_coin (pc,
session,
&coin->coin_pub,
&known_coin);
- if (0 > qs)
- {
- GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
- return GNUNET_SYSERR;
- }
- if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs)
+ switch (qs)
{
+ case GNUNET_DB_STATUS_HARD_ERROR:
+ return TALER_EXCHANGEDB_CKS_SOFT_FAIL;
+ case GNUNET_DB_STATUS_SOFT_ERROR:
+ return TALER_EXCHANGEDB_CKS_HARD_FAIL;
+ case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
GNUNET_CRYPTO_rsa_signature_free (known_coin.denom_sig.rsa_signature);
- return GNUNET_DB_STATUS_SUCCESS_NO_RESULTS; /* no change! */
+ if (0 == GNUNET_memcmp (&known_coin.denom_pub_hash,
+ &coin->denom_pub_hash))
+ return TALER_EXCHANGEDB_CKS_PRESENT;
+ GNUNET_break_op (0);
+ return TALER_EXCHANGEDB_CKS_CONFLICT;
+ case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
+ break;
}
- GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs);
+
/* if not known, insert it */
qs = insert_known_coin (pc,
session,
coin);
- if (0 >= qs)
+ switch (qs)
{
- if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
- qs = GNUNET_DB_STATUS_HARD_ERROR; /* should be impossible */
- GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
- return qs;
+ case GNUNET_DB_STATUS_HARD_ERROR:
+ return TALER_EXCHANGEDB_CKS_SOFT_FAIL;
+ case GNUNET_DB_STATUS_SOFT_ERROR:
+ return TALER_EXCHANGEDB_CKS_HARD_FAIL;
+ case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
+ GNUNET_break (0);
+ return TALER_EXCHANGEDB_CKS_HARD_FAIL;
+ case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
+ break;
}
- return qs;
+ return TALER_EXCHANGEDB_CKS_ADDED;
}
diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c
index 8567c87cb..c9b5c6ce7 100644
--- a/src/exchangedb/test_exchangedb.c
+++ b/src/exchangedb/test_exchangedb.c
@@ -559,7 +559,7 @@ test_melting (struct TALER_EXCHANGEDB_Session *session)
session,
&refresh_session.rc,
&ret_refresh_session));
- FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
+ FAILIF (TALER_EXCHANGEDB_CKS_ADDED !=
plugin->ensure_coin_known (plugin->cls,
session,
&refresh_session.coin));
@@ -1746,7 +1746,7 @@ run (void *cls)
deposit.coin.denom_sig = cbc.sig;
deadline = GNUNET_TIME_absolute_get ();
(void) GNUNET_TIME_round_abs (&deadline);
- FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
+ FAILIF (TALER_EXCHANGEDB_CKS_ADDED !=
plugin->ensure_coin_known (plugin->cls,
session,
&deposit.coin));
@@ -1921,7 +1921,7 @@ run (void *cls)
deposit.refund_deadline = deadline;
deposit.wire_deadline = deadline;
result = 8;
- FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
+ FAILIF (TALER_EXCHANGEDB_CKS_ADDED !=
plugin->ensure_coin_known (plugin->cls,
session,
&deposit.coin));