diff options
author | Christian Grothoff <christian@grothoff.org> | 2020-07-08 19:36:08 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2020-07-08 19:36:08 +0200 |
commit | c3cd21508b0900ee5437edb3828b4b7c2f359495 (patch) | |
tree | 04058188f8a2772e3ebdcdc7564de57322a019f5 /src/exchangedb/plugin_exchangedb_postgres.c | |
parent | c93f64710674bb4f635288c5e326f2cf47b8e8c7 (diff) | |
download | exchange-c3cd21508b0900ee5437edb3828b4b7c2f359495.tar.xz |
synchronize with latest GANA
Diffstat (limited to 'src/exchangedb/plugin_exchangedb_postgres.c')
-rw-r--r-- | src/exchangedb/plugin_exchangedb_postgres.c | 42 |
1 files changed, 27 insertions, 15 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; } |