summaryrefslogtreecommitdiff
path: root/src/stasis/plugin_anastasis_postgres.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-01-19 14:38:57 +0100
committerChristian Grothoff <christian@grothoff.org>2022-01-19 14:38:57 +0100
commit21e28d6d049a948fe71817da7cb3e3b0f1639eb6 (patch)
tree40dc5e591676cf64d67d4986ab580402d5db498b /src/stasis/plugin_anastasis_postgres.c
parent18c53ce9ac45efbf6bcb53995eb5d10a357c5846 (diff)
downloadanastasis-21e28d6d049a948fe71817da7cb3e3b0f1639eb6.tar.gz
anastasis-21e28d6d049a948fe71817da7cb3e3b0f1639eb6.tar.bz2
anastasis-21e28d6d049a948fe71817da7cb3e3b0f1639eb6.zip
implement routine to download meta data and decrypt to libanastasis; improve API to include timestamp
Diffstat (limited to 'src/stasis/plugin_anastasis_postgres.c')
-rw-r--r--src/stasis/plugin_anastasis_postgres.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/stasis/plugin_anastasis_postgres.c b/src/stasis/plugin_anastasis_postgres.c
index ef13c6c..bfe86da 100644
--- a/src/stasis/plugin_anastasis_postgres.c
+++ b/src/stasis/plugin_anastasis_postgres.c
@@ -334,9 +334,10 @@ prepare_statements (void *cls)
",recovery_data_hash"
",recovery_data"
",recovery_meta_data"
+ ",creation_date"
") VALUES "
- "($1, $2, $3, $4, $5, $6);",
- 6),
+ "($1, $2, $3, $4, $5, $6, $7);",
+ 7),
GNUNET_PQ_make_prepare ("truth_select",
"SELECT "
" method_name"
@@ -348,6 +349,7 @@ prepare_statements (void *cls)
GNUNET_PQ_make_prepare ("recoverydocument_select_meta",
"SELECT "
" version"
+ ",creation_date"
",recovery_meta_data"
" FROM anastasis_recoverydocument"
" WHERE user_id=$1"
@@ -1019,6 +1021,8 @@ postgres_store_recovery_document (
/* finally, actually insert the recovery document */
{
+ struct GNUNET_TIME_Timestamp now
+ = GNUNET_TIME_timestamp_get ();
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (account_pub),
GNUNET_PQ_query_param_uint32 (version),
@@ -1030,6 +1034,7 @@ postgres_store_recovery_document (
? GNUNET_PQ_query_param_null ()
: GNUNET_PQ_query_param_fixed_size (recovery_meta_data,
recovery_meta_data_size),
+ GNUNET_PQ_query_param_timestamp (&now),
GNUNET_PQ_query_param_end
};
@@ -2248,10 +2253,13 @@ meta_iterator (void *cls,
uint32_t version;
void *meta_data = NULL;
size_t meta_data_size = 0;
+ struct GNUNET_TIME_Timestamp ts;
bool unused = false;
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_uint32 ("version",
&version),
+ GNUNET_PQ_result_spec_timestamp ("creation_date",
+ &ts),
GNUNET_PQ_result_spec_allow_null (
GNUNET_PQ_result_spec_variable_size ("recovery_meta_data",
&meta_data,
@@ -2272,6 +2280,7 @@ meta_iterator (void *cls,
}
ret = ctx->cb (ctx->cb_cls,
version,
+ ts,
meta_data,
meta_data_size);
GNUNET_PQ_cleanup_result (rs);