sync

Backup service to store encrypted wallet databases (experimental)
Log | Files | Refs | Submodules | README | LICENSE

commit 29877ddfcc811c75bd6b11ec91dc2ad235ac77ae
parent d3a649c4507ee6283f36af3d10136650ed29ba45
Author: Christian Grothoff <christian@grothoff.org>
Date:   Thu, 14 Nov 2019 19:54:10 +0100

ignores

Diffstat:
M.gitignore | 2++
Msrc/include/sync_database_plugin.h | 14+++++++-------
Msrc/include/sync_service.h | 6+++---
Asrc/syncdb/.gitignore | 4++++
Msrc/syncdb/plugin_syncdb_postgres.c | 30++++++++++++++----------------
Msrc/syncdb/test_sync_db.c | 6+++---
6 files changed, 33 insertions(+), 29 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -61,3 +61,5 @@ src/include/Makefile.in A A +sync_config.h +sync_config.h.in diff --git a/src/include/sync_database_plugin.h b/src/include/sync_database_plugin.h @@ -126,8 +126,8 @@ struct SYNC_DatabasePlugin */ enum SYNC_DB_QueryStatus (*store_backup_TR)(void *cls, - const struct SYNC_AccountPublicKey *account_pub, - const struct SYNC_AccountSignature *account_sig, + const struct SYNC_AccountPublicKeyP *account_pub, + const struct SYNC_AccountSignatureP *account_sig, const struct GNUNET_HashCode *backup_hash, size_t backup_size, const void *backup); @@ -146,9 +146,9 @@ struct SYNC_DatabasePlugin */ enum SYNC_DB_QueryStatus (*update_backup_TR)(void *cls, - const struct SYNC_AccountPublicKey *account_pub, + const struct SYNC_AccountPublicKeyP *account_pub, const struct GNUNET_HashCode *old_backup_hash, - const struct SYNC_AccountSignature *account_sig, + const struct SYNC_AccountSignatureP *account_sig, const struct GNUNET_HashCode *backup_hash, size_t backup_size, const void *backup); @@ -165,8 +165,8 @@ struct SYNC_DatabasePlugin */ enum SYNC_DB_QueryStatus (*lookup_backup_TR)(void *cls, - const struct SYNC_AccountPublicKey *account_pub, - struct SYNC_AccountSignature *account_sig, + const struct SYNC_AccountPublicKeyP *account_pub, + struct SYNC_AccountSignatureP *account_sig, struct GNUNET_HashCode *backup_hash, size_t *backup_size, void **backup); @@ -181,7 +181,7 @@ struct SYNC_DatabasePlugin */ enum SYNC_DB_QueryStatus (*increment_lifetime_TR)(void *cls, - const struct SYNC_AccountPublicKey *account_pub, + const struct SYNC_AccountPublicKeyP *account_pub, struct GNUNET_TIME_Relative lifetime); }; diff --git a/src/include/sync_service.h b/src/include/sync_service.h @@ -29,7 +29,7 @@ /** * Private key identifying an account. */ -struct SYNC_AccountPrivateKey +struct SYNC_AccountPrivateKeyP { /** * We use EdDSA. @@ -41,7 +41,7 @@ struct SYNC_AccountPrivateKey /** * Public key identifying an account. */ -struct SYNC_AccountPublicKey +struct SYNC_AccountPublicKeyP { /** * We use EdDSA. @@ -53,7 +53,7 @@ struct SYNC_AccountPublicKey /** * Signature made with an account's public key. */ -struct SYNC_AccountSignature +struct SYNC_AccountSignatureP { /** * We use EdDSA. diff --git a/src/syncdb/.gitignore b/src/syncdb/.gitignore @@ -0,0 +1,4 @@ +test_sync_db-postgres +.deps +.libs +test-suite.log diff --git a/src/syncdb/plugin_syncdb_postgres.c b/src/syncdb/plugin_syncdb_postgres.c @@ -249,8 +249,8 @@ postgres_gc (void *cls, */ static enum SYNC_DB_QueryStatus postgres_store_backup (void *cls, - const struct SYNC_AccountPublicKey *account_pub, - const struct SYNC_AccountSignature *account_sig, + const struct SYNC_AccountPublicKeyP *account_pub, + const struct SYNC_AccountSignatureP *account_sig, const struct GNUNET_HashCode *backup_hash, size_t backup_size, const void *backup) @@ -387,9 +387,9 @@ postgres_store_backup (void *cls, */ static enum SYNC_DB_QueryStatus postgres_update_backup (void *cls, - const struct SYNC_AccountPublicKey *account_pub, + const struct SYNC_AccountPublicKeyP *account_pub, const struct GNUNET_HashCode *old_backup_hash, - const struct SYNC_AccountSignature *account_sig, + const struct SYNC_AccountSignatureP *account_sig, const struct GNUNET_HashCode *backup_hash, size_t backup_size, const void *backup) @@ -531,8 +531,8 @@ postgres_update_backup (void *cls, */ static enum SYNC_DB_QueryStatus postgres_lookup_backup (void *cls, - const struct SYNC_AccountPublicKey *account_pub, - struct SYNC_AccountSignature *account_sig, + const struct SYNC_AccountPublicKeyP *account_pub, + struct SYNC_AccountSignatureP *account_sig, struct GNUNET_HashCode *backup_hash, size_t *backup_size, void **backup) @@ -588,7 +588,7 @@ postgres_lookup_backup (void *cls, */ static enum SYNC_DB_QueryStatus postgres_increment_lifetime (void *cls, - const struct SYNC_AccountPublicKey *account_pub, + const struct SYNC_AccountPublicKeyP *account_pub, struct GNUNET_TIME_Relative lifetime) { struct PostgresClosure *pg = cls; @@ -753,14 +753,14 @@ libsync_plugin_db_postgres_init (void *cls) "SELECT" " expiration_date " "FROM" - " account" + " accounts " "WHERE" " account_pub=$1;", 1), GNUNET_PQ_make_prepare ("gc", "DELETE FROM accounts " "WHERE" - " expiration_data<$1;", + " expiration_date < $1;", 1), GNUNET_PQ_make_prepare ("backup_insert", "INSERT INTO backups " @@ -780,15 +780,13 @@ libsync_plugin_db_postgres_init (void *cls) " WHERE" " account_pub=$4" " AND" - " backup_hash=$5" - ") VALUES " - "($1,$2,$3,$4,$5);", + " backup_hash=$5;", 5), GNUNET_PQ_make_prepare ("backup_select_hash", "SELECT " - " backup_hash" + " backup_hash " "FROM" - " backups" + " backups " "WHERE" " account_pub=$1;", 1), @@ -796,9 +794,9 @@ libsync_plugin_db_postgres_init (void *cls) "SELECT " " account_sig" ",backup_hash" - ",data" + ",data " "FROM" - " backups" + " backups " "WHERE" " account_pub=$1;", 1), diff --git a/src/syncdb/test_sync_db.c b/src/syncdb/test_sync_db.c @@ -22,10 +22,9 @@ #include "platform.h" #include <gnunet/gnunet_util_lib.h> #include <taler/taler_util.h> +#include "sync_service.h" #include "sync_database_plugin.h" #include "sync_database_lib.h" -#include "sync_error_codes.h" -#include <uuid/uuid.h> #define FAILIF(cond) \ @@ -52,7 +51,7 @@ static struct SYNC_DatabasePlugin *plugin; /** * User public key, set to a random value */ -static struct SYNC_AccountPubP accountPubP; +static struct SYNC_AccountPublicKeyP accountPubP; /** @@ -85,6 +84,7 @@ run (void *cls) } // FIXME: test logic here! + result = 0; GNUNET_break (GNUNET_OK == plugin->drop_tables (plugin->cls));