summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac14
-rw-r--r--doc/Makefile.am3
-rw-r--r--src/include/sync_database_plugin.h38
-rw-r--r--src/include/sync_service.h41
-rw-r--r--src/syncdb/plugin_syncdb_postgres.c72
-rw-r--r--src/util/Makefile.am3
6 files changed, 98 insertions, 73 deletions
diff --git a/configure.ac b/configure.ac
index 1250b6d..37784fb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4,9 +4,9 @@
# This configure file is in the public domain
AC_PREREQ([2.69])
-AC_INIT([anastasis], [0.5.0], [taler-bug@gnu.org])
-AC_CONFIG_SRCDIR([src/backend/anastasis-httpd.c])
-AC_CONFIG_HEADERS([anastasis_config.h])
+AC_INIT([sync], [0.5.0], [taler-bug@gnu.org])
+AC_CONFIG_SRCDIR([src/sync/sync-httpd.c])
+AC_CONFIG_HEADERS([sync_config.h])
# support for non-recursive builds
AM_INIT_AUTOMAKE([subdir-objects 1.9 tar-pax])
@@ -17,7 +17,7 @@ AC_CONFIG_MACRO_DIR([m4])
LT_INIT
-DX_INIT_DOXYGEN([anastasis],,,
+DX_INIT_DOXYGEN([sync],,,
DX_PS_FEATURE(OFF),
DX_PDF_FEATURE(OFF),
DX_RTF_FEATURE(OFF),
@@ -300,10 +300,10 @@ AM_CONDITIONAL([HAVE_EXPERIMENTAL], [test "x$enable_experimental" = "xyes"])
AC_CONFIG_FILES([Makefile
doc/Makefile
src/Makefile
-src/util/Makefile
-src/stasis/Makefile
-src/backend/Makefile
src/include/Makefile
src/lib/Makefile
+src/sync/Makefile
+src/syncdb/Makefile
+src/util/Makefile
])
AC_OUTPUT
diff --git a/doc/Makefile.am b/doc/Makefile.am
new file mode 100644
index 0000000..737ac0c
--- /dev/null
+++ b/doc/Makefile.am
@@ -0,0 +1,3 @@
+# This Makefile is in the public domain
+AM_CPPFLAGS = -I$(top_srcdir)/src/include
+SUBDIRS = .
diff --git a/src/include/sync_database_plugin.h b/src/include/sync_database_plugin.h
index b847888..36162c6 100644
--- a/src/include/sync_database_plugin.h
+++ b/src/include/sync_database_plugin.h
@@ -22,46 +22,10 @@
#define SYNC_DATABASE_PLUGIN_H
#include <gnunet/gnunet_util_lib.h>
-#include <sync_error_codes.h>
#include "sync_service.h"
#include <jansson.h>
#include <taler/taler_util.h>
-/**
- * Private key identifying an account.
- */
-struct SYNC_AccountPrivateKey
-{
- /**
- * We use EdDSA.
- */
- struct GNUNET_EdDSAPrivateKey eddsa_priv;
-};
-
-
-/**
- * Public key identifying an account.
- */
-struct SYNC_AccountPublicKey
-{
- /**
- * We use EdDSA.
- */
- struct GNUNET_EdDSAPrivateKey eddsa_priv;
-};
-
-
-/**
- * Signature made with an account's public key.
- */
-struct SYNC_AccountSignature
-{
- /**
- * We use EdDSA.
- */
- struct GNUNET_EdDSASignature eddsa_sig;
-};
-
/**
* Possible status codes returned from the SYNC database.
@@ -76,7 +40,7 @@ enum SYNC_DB_QueryStatus
/**
* Account is unpaid.
*/
- SYNC_DB_QS_PAYMENT_REQUIRED = -3,
+ SYNC_DB_PAYMENT_REQUIRED = -3,
/**
* Hard database issue, retries futile.
diff --git a/src/include/sync_service.h b/src/include/sync_service.h
index efe46fe..d0c79af 100644
--- a/src/include/sync_service.h
+++ b/src/include/sync_service.h
@@ -21,16 +21,44 @@
#ifndef _SYNC_SERVICE_H
#define _SYNC_SERVICE_H
+#include <gnunet/gnunet_util_lib.h>
#include <gnunet/gnunet_curl_lib.h>
#include <jansson.h>
/**
- * An EdDSA public key that is used to identify a user's account.
+ * Private key identifying an account.
*/
-struct SYNC_AccountPubP
+struct SYNC_AccountPrivateKey
{
- struct GNUNET_CRYPTO_EddsaPublicKey pub;
+ /**
+ * We use EdDSA.
+ */
+ struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_priv;
+};
+
+
+/**
+ * Public key identifying an account.
+ */
+struct SYNC_AccountPublicKey
+{
+ /**
+ * We use EdDSA.
+ */
+ struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_priv;
+};
+
+
+/**
+ * Signature made with an account's public key.
+ */
+struct SYNC_AccountSignature
+{
+ /**
+ * We use EdDSA.
+ */
+ struct GNUNET_CRYPTO_EddsaSignature eddsa_sig;
};
@@ -46,19 +74,16 @@ void
SYNC_upload_cancel (struct SYNC_UploadOperation *uo);
-
struct SYNC_DownloadOperation;
struct SYNC_DownloadOperation *
SYNC_download (struct GNUNET_CURL_Context *ctx,
- const char *base_url,
- ...);
+ const char *base_url,
+ ...);
void
SYNC_download_cancel (struct SYNC_DownloadOperation *uo);
-
-
#endif /* _SYNC_SERVICE_H */
diff --git a/src/syncdb/plugin_syncdb_postgres.c b/src/syncdb/plugin_syncdb_postgres.c
index d1c3e3e..d1c49b5 100644
--- a/src/syncdb/plugin_syncdb_postgres.c
+++ b/src/syncdb/plugin_syncdb_postgres.c
@@ -20,6 +20,7 @@
*/
#include "platform.h"
#include <gnunet/gnunet_util_lib.h>
+#include <gnunet/gnunet_db_lib.h>
#include <gnunet/gnunet_pq_lib.h>
#include <taler/taler_pq_lib.h>
#include "sync_database_plugin.h"
@@ -255,7 +256,7 @@ postgres_store_backup (void *cls,
const void *backup)
{
struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryStatus qs;
+ enum GNUNET_DB_QueryStatus qs;
struct GNUNET_HashCode bh;
check_connection (pg);
@@ -282,11 +283,14 @@ postgres_store_backup (void *cls,
case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
GNUNET_break (0);
return SYNC_DB_NO_RESULTS;
- case GNUNET_DB_STATUS_SUCCESS_RESULT_ONE:
+ case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
return SYNC_DB_ONE_RESULT;
case GNUNET_DB_STATUS_HARD_ERROR:
/* handle interesting case below */
break;
+ default:
+ GNUNET_break (0);
+ return SYNC_DB_HARD_ERROR;
}
/* First, check if account exists */
@@ -316,9 +320,12 @@ postgres_store_backup (void *cls,
return SYNC_DB_SOFT_ERROR;
case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
return SYNC_DB_PAYMENT_REQUIRED;
- case GNUNET_DB_STATUS_SUCCESS_RESULT_ONE:
+ case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
/* handle interesting case below */
break;
+ default:
+ GNUNET_break (0);
+ return SYNC_DB_HARD_ERROR;
}
/* account exists, check if existing backup conflicts */
@@ -348,9 +355,12 @@ postgres_store_backup (void *cls,
case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
/* original error must have been a hard error, oddly enough */
return SYNC_DB_HARD_ERROR;
- case GNUNET_DB_STATUS_SUCCESS_RESULT_ONE:
+ case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
/* handle interesting case below */
break;
+ default:
+ GNUNET_break (0);
+ return SYNC_DB_HARD_ERROR;
}
/* had an existing backup, is it identical? */
@@ -385,7 +395,7 @@ postgres_update_backup (void *cls,
const void *backup)
{
struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryStatus qs;
+ enum GNUNET_DB_QueryStatus qs;
struct GNUNET_HashCode bh;
check_connection (pg);
@@ -413,11 +423,14 @@ postgres_update_backup (void *cls,
case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
GNUNET_break (0);
return SYNC_DB_NO_RESULTS;
- case GNUNET_DB_STATUS_SUCCESS_RESULT_ONE:
+ case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
return SYNC_DB_ONE_RESULT;
case GNUNET_DB_STATUS_HARD_ERROR:
/* handle interesting case below */
break;
+ default:
+ GNUNET_break (0);
+ return SYNC_DB_HARD_ERROR;
}
/* First, check if account exists */
@@ -447,9 +460,12 @@ postgres_update_backup (void *cls,
return SYNC_DB_SOFT_ERROR;
case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
return SYNC_DB_PAYMENT_REQUIRED;
- case GNUNET_DB_STATUS_SUCCESS_RESULT_ONE:
+ case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
/* handle interesting case below */
break;
+ default:
+ GNUNET_break (0);
+ return SYNC_DB_HARD_ERROR;
}
/* account exists, check if existing backup conflicts */
@@ -480,9 +496,12 @@ postgres_update_backup (void *cls,
/* Well, trying to update where there is no original
is a hard erorr, even though an odd one */
return SYNC_DB_HARD_ERROR;
- case GNUNET_DB_STATUS_SUCCESS_RESULT_ONE:
+ case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
/* handle interesting case below */
break;
+ default:
+ GNUNET_break (0);
+ return SYNC_DB_HARD_ERROR;
}
/* had an existing backup, is it identical? */
@@ -519,6 +538,7 @@ postgres_lookup_backup (void *cls,
void **backup)
{
struct PostgresClosure *pg = cls;
+ enum GNUNET_DB_QueryStatus qs;
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (account_pub),
GNUNET_PQ_query_param_end
@@ -529,8 +549,8 @@ postgres_lookup_backup (void *cls,
GNUNET_PQ_result_spec_auto_from_type ("backup_hash",
backup_hash),
GNUNET_PQ_result_spec_variable_size ("data",
- &backup,
- &backup_size),
+ backup,
+ backup_size),
GNUNET_PQ_result_spec_end
};
@@ -549,8 +569,11 @@ postgres_lookup_backup (void *cls,
return SYNC_DB_SOFT_ERROR;
case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
return SYNC_DB_NO_RESULTS;
- case GNUNET_DB_STATUS_SUCCESS_RESULT_ONE:
+ case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
return SYNC_DB_ONE_RESULT;
+ default:
+ GNUNET_break (0);
+ return SYNC_DB_HARD_ERROR;
}
}
@@ -570,7 +593,7 @@ postgres_increment_lifetime (void *cls,
{
struct PostgresClosure *pg = cls;
struct GNUNET_TIME_Absolute expiration;
- struct GNUNET_PQ_QueryStatus qs;
+ enum GNUNET_DB_QueryStatus qs;
check_connection (pg);
if (GNUNET_OK !=
@@ -586,12 +609,12 @@ postgres_increment_lifetime (void *cls,
GNUNET_PQ_query_param_end
};
struct GNUNET_PQ_ResultSpec rs[] = {
- TALER_PQ_result_spec_absolute_time ("wire_deadline",
- &wire_deadline),
+ TALER_PQ_result_spec_absolute_time ("expiration_date",
+ &expiration),
GNUNET_PQ_result_spec_end
};
- qs = GNUNET_PQ_eval_prepared_singleton_select (session->conn,
+ qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
"account_select",
params,
rs);
@@ -613,12 +636,13 @@ postgres_increment_lifetime (void *cls,
GNUNET_PQ_query_param_end
};
+ expiration = GNUNET_TIME_relative_to_absolute (lifetime);
qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
"account_insert",
params);
}
break;
- case GNUNET_DB_STATUS_SUCCESS_RESULT_ONE:
+ case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
{
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_absolute_time (&expiration),
@@ -626,11 +650,16 @@ postgres_increment_lifetime (void *cls,
GNUNET_PQ_query_param_end
};
+ expiration = GNUNET_TIME_absolute_add (expiration,
+ lifetime);
qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
"account_update",
params);
}
break;
+ default:
+ GNUNET_break (0);
+ return SYNC_DB_HARD_ERROR;
}
switch (qs)
{
@@ -645,8 +674,11 @@ postgres_increment_lifetime (void *cls,
GNUNET_break (0);
rollback (pg);
return SYNC_DB_NO_RESULTS;
- case GNUNET_DB_STATUS_SUCCESS_RESULT_ONE:
+ case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
break;
+ default:
+ GNUNET_break (0);
+ return SYNC_DB_HARD_ERROR;
}
qs = commit_transaction (pg);
switch (qs)
@@ -658,8 +690,11 @@ postgres_increment_lifetime (void *cls,
return SYNC_DB_SOFT_ERROR;
case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
return SYNC_DB_ONE_RESULT;
- case GNUNET_DB_STATUS_SUCCESS_RESULT_ONE:
+ case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
return SYNC_DB_ONE_RESULT;
+ default:
+ GNUNET_break (0);
+ return SYNC_DB_HARD_ERROR;
}
}
@@ -789,6 +824,7 @@ libsync_plugin_db_postgres_init (void *cls)
plugin->drop_tables = &postgres_drop_tables;
plugin->gc = &postgres_gc;
plugin->store_backup_TR = &postgres_store_backup;
+ plugin->lookup_backup_TR = &postgres_lookup_backup;
plugin->update_backup_TR = &postgres_update_backup;
plugin->increment_lifetime_TR = &postgres_increment_lifetime;
return plugin;
diff --git a/src/util/Makefile.am b/src/util/Makefile.am
index bc1291c..a8bb4d4 100644
--- a/src/util/Makefile.am
+++ b/src/util/Makefile.am
@@ -9,9 +9,6 @@ endif
pkgcfgdir = $(prefix)/share/sync/config.d/
-pkgcfg_DATA = \
- paths.conf
-
bin_SCRIPTS = \
sync-config