[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] branch master updated: Fixed some errors
From: |
gnunet |
Subject: |
[taler-anastasis] branch master updated: Fixed some errors |
Date: |
Fri, 01 Nov 2019 21:05:31 +0100 |
This is an automated email from the git hooks/post-receive script.
dennis-neufeld pushed a commit to branch master
in repository anastasis.
The following commit(s) were added to refs/heads/master by this push:
new 0501338 Fixed some errors
0501338 is described below
commit 0501338e60ec7fbd374bd9194d33ab7fe3227596
Author: Dennis Neufeld <address@hidden>
AuthorDate: Fri Nov 1 20:05:05 2019 +0000
Fixed some errors
---
src/backup-db/plugin_anastasis_postgres.c | 7 ++--
src/backup-db/test_anastasis_db.c | 10 +++---
src/include/anastasis_database_lib.h | 35 ++++++++++++++++++++
src/include/anastasis_error_codes.h | 53 ++++++++++---------------------
4 files changed, 61 insertions(+), 44 deletions(-)
diff --git a/src/backup-db/plugin_anastasis_postgres.c
b/src/backup-db/plugin_anastasis_postgres.c
index affa2ce..f245244 100644
--- a/src/backup-db/plugin_anastasis_postgres.c
+++ b/src/backup-db/plugin_anastasis_postgres.c
@@ -26,6 +26,7 @@
#include <taler/taler_pq_lib.h>
#include "anastasis_database_plugin.h"
#include "anastasis_database_lib.h"
+#include "anastasis_error_codes.h"
/**
* How often do we re-try if we run into a DB serialization error?
@@ -271,7 +272,7 @@ postgres_store_recovery_document (void *cls,
rollback (pg);
return qs;
case ANASTASIS_DB_STATUS_SUCCESS_NO_RESULTS:
- return ANASTASIS_DB_STATUS_UNKNOWN_USER;
+ return ANASTASIS_EC_DB_STATUS_UNKNOWN_USER;
case ANASTASIS_DB_STATUS_SUCCESS_ONE_RESULT:
paid_until = GNUNET_TIME_absolute_max (GNUNET_TIME_absolute_get (),
paid_until);
@@ -286,7 +287,7 @@ postgres_store_recovery_document (void *cls,
paid_until).rel_value_us == 0)
{
rollback (pg);
- return ANASTASIS_DB_STATUS_PAYMENT_EXPIRED;
+ return ANASTASIS_EC_DB_STATUS_PAYMENT_EXPIRED;
}
// lookup if the user has enough uploads left and decrement
@@ -329,7 +330,7 @@ postgres_store_recovery_document (void *cls,
if (postcounter == 0 )
{
rollback (pg);
- return ANASTASIS_DB_STATUS_NOT_SUFFICIENT_POSTS;
+ return ANASTASIS_EC_DB_STATUS_NOT_SUFFICIENT_POSTS;
}
/*Decrement the postcounter by one*/
postcounter--;
diff --git a/src/backup-db/test_anastasis_db.c
b/src/backup-db/test_anastasis_db.c
index ca81b19..8fa633b 100644
--- a/src/backup-db/test_anastasis_db.c
+++ b/src/backup-db/test_anastasis_db.c
@@ -50,7 +50,7 @@ static struct ANASTASIS_DatabasePlugin *plugin;
/**
* Payment Secret for the test, set to a random value
*/
-static struct ANASTASIS_PaymentSecretP paymentSecretP;
+static struct ANASTASIS_PaymentSecretP *paymentSecretP;
/**
* UUID of the Truth to test, set to a UUID value
@@ -60,7 +60,7 @@ static struct ANASTASIS_uuid uuid;
/**
* User public key, set to a random value
*/
-static struct ANASTASIS_AccountPubP accountPubP;
+static struct ANASTASIS_AccountPubP *accountPubP;
/**
* Amount which is deposited, set to random value
@@ -90,7 +90,7 @@ const void *key_share;
/**
* Version of a Recoverydocument
*/
-const unsigned int *version;
+uint32_t *version;
/**
@@ -127,7 +127,7 @@ run (void *cls)
plugin->store_recovery_document (plugin->cls,
accountPubP,
recovery_data,
- recovery_data_size,
+ sizeof (*recovery_data),
paymentSecretP,
version));
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
@@ -141,7 +141,7 @@ run (void *cls)
plugin->store_truth (plugin->cls,
uuid,
truth_data,
- truth_data_size,
+ sizeof (*truth_data),
fake_now,
version));
diff --git a/src/include/anastasis_database_lib.h
b/src/include/anastasis_database_lib.h
index b0199ad..adf3138 100644
--- a/src/include/anastasis_database_lib.h
+++ b/src/include/anastasis_database_lib.h
@@ -40,6 +40,41 @@ ANASTASIS_DB_plugin_load (void *cls);
void
ANASTASIS_DB_plugin_unload (void *cls);
+/**
+ * Status code returned from functions running database commands.
+ * Can be combined with a function that returns the number
+ * of results, so all non-negative values indicate success.
+ */
+enum ANASTASIS_DB_QueryStatus
+{
+ /**
+ * A hard error occurred, retrying will not help.
+ */
+ ANASTASIS_DB_STATUS_HARD_ERROR = -2,
+
+ /**
+ * A soft error occurred, retrying the transaction may succeed.
+ * Includes DEADLOCKS and SERIALIZATION errors.
+ */
+ ANASTASIS_DB_STATUS_SOFT_ERROR = -1,
+
+ /**
+ * The transaction succeeded, but yielded zero results.
+ * May include the case where an INSERT failed with UNIQUE
+ * violation (i.e. row already exists) or where DELETE
+ * failed to remove anything (i.e. nothing matched).
+ */
+ ANASTASIS_DB_STATUS_SUCCESS_NO_RESULTS = 0,
+
+ /**
+ * The transaction succeeded, and yielded one result.
+ */
+ ANASTASIS_DB_STATUS_SUCCESS_ONE_RESULT = 1
+
+ /* Larger values may be returned for SELECT statements
+ that returned more than one result. */
+};
+
#endif /* ANASTASIS_DB_LIB_H */
/* end of anastasis_database_lib.h */
\ No newline at end of file
diff --git a/src/include/anastasis_error_codes.h
b/src/include/anastasis_error_codes.h
index 45ce6e8..a722ac9 100644
--- a/src/include/anastasis_error_codes.h
+++ b/src/include/anastasis_error_codes.h
@@ -18,60 +18,41 @@
SPDX-License-Identifier: AGPL3.0-or-later
*/
/**
- * @file include/ANASTASIS_DB_lib.h
- * @brief shared defintions for transactional databases
+ * @file anastasis_error_codes.h
+ * @brief error codes returned by GNU Taler
* @author Christian Grothoff
* @author Dominik Meister
+ * @author Dennis Neufeld
+ *
+ * This file should define constants for error codes returned
+ * in Anastasis APIs. We use codes above 6000 to avoid any
+ * confusing with HTTP status codes. All constants have the
+ * shared prefix "ANASTASIS_EC_" to indicate that they are error
+ * codes.
*/
-#ifndef ANASTASIS_DB_LIB_H
-#define ANASTASIS_DB_LIB_H
+#ifndef ANASTASIS_ERROR_CODES_H
+#define ANASTASIS_ERROR_CODES_H
/**
- * Status code returned from functions running database commands.
- * Can be combined with a function that returns the number
- * of results, so all non-negative values indicate success.
- */
-enum ANASTASIS_DB_QueryStatus
+ * Enumeration with all possible Anastasis error codes.
+*/
+enum ANASTASIS_ErrorCode
{
- /**
- * A hard error occurred, retrying will not help.
- */
- ANASTASIS_DB_STATUS_HARD_ERROR = -2,
-
- /**
- * A soft error occurred, retrying the transaction may succeed.
- * Includes DEADLOCKS and SERIALIZATION errors.
- */
- ANASTASIS_DB_STATUS_SOFT_ERROR = -1,
-
- /**
- * The transaction succeeded, but yielded zero results.
- * May include the case where an INSERT failed with UNIQUE
- * violation (i.e. row already exists) or where DELETE
- * failed to remove anything (i.e. nothing matched).
- */
- ANASTASIS_DB_STATUS_SUCCESS_NO_RESULTS = 0,
-
- /**
- * The transaction succeeded, and yielded one result.
- */
- ANASTASIS_DB_STATUS_SUCCESS_ONE_RESULT = 1,
-
/**
* The specified User was unknown
*/
- ANASTASIS_DB_STATUS_UNKNOWN_USER = 6000,
+ ANASTASIS_EC_DB_STATUS_UNKNOWN_USER = 6000,
/**
* The Users Payment had not sufficient posts left
*/
- ANASTASIS_DB_STATUS_NOT_SUFFICIENT_POSTS = 6001,
+ ANASTASIS_EC_DB_STATUS_NOT_SUFFICIENT_POSTS = 6001,
/**
* The Payment from the User has expired.
*/
- ANASTASIS_DB_STATUS_PAYMENT_EXPIRED = 6002
+ ANASTASIS_EC_DB_STATUS_PAYMENT_EXPIRED = 6002
};
#endif
--
To stop receiving notification emails like this one, please contact
address@hidden.
- [taler-anastasis] branch master updated: Fixed some errors,
gnunet <=