introduce pq functions form abs time in NBO

This commit is contained in:
Christian Grothoff 2015-06-12 21:29:17 +02:00
parent b1e0dd8b7e
commit 5c01da52b1
3 changed files with 66 additions and 12 deletions

View File

@ -201,6 +201,16 @@ struct TALER_PQ_QueryParam
TALER_PQ_query_param_absolute_time(const struct GNUNET_TIME_Absolute *x); TALER_PQ_query_param_absolute_time(const struct GNUNET_TIME_Absolute *x);
/**
* Generate query parameter for an absolute time value.
* The database must store a 64-bit integer.
*
* @param x pointer to the query parameter to pass
*/
struct TALER_PQ_QueryParam
TALER_PQ_query_param_absolute_time_nbo(const struct GNUNET_TIME_AbsoluteNBO *x);
/** /**
* Generate query parameter for an uint16_t in host byte order. * Generate query parameter for an uint16_t in host byte order.
* *
@ -452,6 +462,18 @@ TALER_PQ_result_spec_absolute_time (const char *name,
struct GNUNET_TIME_Absolute *at); struct GNUNET_TIME_Absolute *at);
/**
* Absolute time expected.
*
* @param name name of the field in the table
* @param[out] at where to store the result
* @return array entry for the result specification to use
*/
struct TALER_PQ_ResultSpec
TALER_PQ_result_spec_absolute_time_nbo (const char *name,
struct GNUNET_TIME_AbsoluteNBO *at);
/** /**
* uint16_t expected. * uint16_t expected.
* *

View File

@ -1057,10 +1057,10 @@ postgres_insert_denomination_info (void *cls,
TALER_PQ_query_param_rsa_public_key (denom_pub->rsa_public_key), TALER_PQ_query_param_rsa_public_key (denom_pub->rsa_public_key),
TALER_PQ_query_param_auto_from_type (&issue->master), TALER_PQ_query_param_auto_from_type (&issue->master),
TALER_PQ_query_param_auto_from_type (&issue->signature), TALER_PQ_query_param_auto_from_type (&issue->signature),
TALER_PQ_query_param_auto_from_type (&issue->start.abs_value_us__), TALER_PQ_query_param_absolute_time_nbo (&issue->start),
TALER_PQ_query_param_auto_from_type (&issue->expire_withdraw.abs_value_us__), TALER_PQ_query_param_absolute_time_nbo (&issue->expire_withdraw),
TALER_PQ_query_param_auto_from_type (&issue->expire_spend.abs_value_us__), TALER_PQ_query_param_absolute_time_nbo (&issue->expire_spend),
TALER_PQ_query_param_auto_from_type (&issue->expire_legal.abs_value_us__), TALER_PQ_query_param_absolute_time_nbo (&issue->expire_legal),
TALER_PQ_query_param_amount_nbo (&issue->value), TALER_PQ_query_param_amount_nbo (&issue->value),
TALER_PQ_query_param_amount_nbo (&issue->fee_withdraw), TALER_PQ_query_param_amount_nbo (&issue->fee_withdraw),
TALER_PQ_query_param_amount_nbo (&issue->fee_deposit), TALER_PQ_query_param_amount_nbo (&issue->fee_deposit),
@ -1147,14 +1147,14 @@ postgres_get_denomination_info (void *cls,
&issue->master), &issue->master),
TALER_PQ_result_spec_auto_from_type ("master_sig", TALER_PQ_result_spec_auto_from_type ("master_sig",
&issue->signature), &issue->signature),
TALER_PQ_result_spec_auto_from_type ("valid_from", TALER_PQ_result_spec_absolute_time_nbo ("valid_from",
&issue->start.abs_value_us__), &issue->start),
TALER_PQ_result_spec_auto_from_type ("expire_withdraw", TALER_PQ_result_spec_absolute_time_nbo ("expire_withdraw",
&issue->expire_withdraw.abs_value_us__), &issue->expire_withdraw),
TALER_PQ_result_spec_auto_from_type ("expire_spend", TALER_PQ_result_spec_absolute_time_nbo ("expire_spend",
&issue->expire_spend.abs_value_us__), &issue->expire_spend),
TALER_PQ_result_spec_auto_from_type ("expire_legal", TALER_PQ_result_spec_absolute_time_nbo ("expire_legal",
&issue->expire_legal.abs_value_us__), &issue->expire_legal),
TALER_PQ_result_spec_amount_nbo ("coin", TALER_PQ_result_spec_amount_nbo ("coin",
&issue->value), &issue->value),
TALER_PQ_result_spec_amount_nbo ("fee_withdraw", TALER_PQ_result_spec_amount_nbo ("fee_withdraw",

View File

@ -107,6 +107,21 @@ TALER_PQ_query_param_absolute_time (const struct GNUNET_TIME_Absolute *x)
} }
/**
* Generate query parameter for an absolute time value.
* The database must store a 64-bit integer.
*
* @param x pointer to the query parameter to pass
*/
struct TALER_PQ_QueryParam
TALER_PQ_query_param_absolute_time_nbo(const struct GNUNET_TIME_AbsoluteNBO *x)
{
struct TALER_PQ_QueryParam res =
TALER_PQ_query_param_auto_from_type (&x->abs_value_us__);
return res;
}
/** /**
* Generate query parameter for an uint16_t in host byte order. * Generate query parameter for an uint16_t in host byte order.
* *
@ -268,6 +283,23 @@ TALER_PQ_result_spec_absolute_time (const char *name,
} }
/**
* Absolute time expected.
*
* @param name name of the field in the table
* @param[out] at where to store the result
* @return array entry for the result specification to use
*/
struct TALER_PQ_ResultSpec
TALER_PQ_result_spec_absolute_time_nbo (const char *name,
struct GNUNET_TIME_AbsoluteNBO *at)
{
struct TALER_PQ_ResultSpec res =
TALER_PQ_result_spec_auto_from_type(name, &at->abs_value_us__);
return res;
}
/** /**
* uint16_t expected. * uint16_t expected.
* *