implementing #3851
This commit is contained in:
parent
253d220ea5
commit
f948a10f71
@ -742,6 +742,7 @@ struct TALER_MINTDB_Plugin
|
|||||||
* @param db the database connection handle
|
* @param db the database connection handle
|
||||||
* @param reserve_pub public key of the reserve
|
* @param reserve_pub public key of the reserve
|
||||||
* @param balance the amount that has to be added to the reserve
|
* @param balance the amount that has to be added to the reserve
|
||||||
|
* @param execution_time when was the amount added
|
||||||
* @param details bank transaction details justifying the increment,
|
* @param details bank transaction details justifying the increment,
|
||||||
* must be unique for each incoming transaction
|
* must be unique for each incoming transaction
|
||||||
* @return #GNUNET_OK upon success; #GNUNET_NO if the given
|
* @return #GNUNET_OK upon success; #GNUNET_NO if the given
|
||||||
@ -753,6 +754,7 @@ struct TALER_MINTDB_Plugin
|
|||||||
struct TALER_MINTDB_Session *db,
|
struct TALER_MINTDB_Session *db,
|
||||||
const struct TALER_ReservePublicKeyP *reserve_pub,
|
const struct TALER_ReservePublicKeyP *reserve_pub,
|
||||||
const struct TALER_Amount *balance,
|
const struct TALER_Amount *balance,
|
||||||
|
struct GNUNET_TIME_Absolute execution_time,
|
||||||
const json_t *details);
|
const json_t *details);
|
||||||
|
|
||||||
|
|
||||||
|
@ -172,10 +172,12 @@ main (int argc, char *const *argv)
|
|||||||
error.source);
|
error.source);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
/* FIXME: maybe allow passing timestamp via command-line? */
|
||||||
ret = plugin->reserves_in_insert (plugin->cls,
|
ret = plugin->reserves_in_insert (plugin->cls,
|
||||||
session,
|
session,
|
||||||
&reserve_pub,
|
&reserve_pub,
|
||||||
&add_value,
|
&add_value,
|
||||||
|
GNUNET_TIME_absolute_get (),
|
||||||
jdetails);
|
jdetails);
|
||||||
json_decref (jdetails);
|
json_decref (jdetails);
|
||||||
if (GNUNET_SYSERR == ret)
|
if (GNUNET_SYSERR == ret)
|
||||||
|
@ -1393,8 +1393,33 @@ TMH_DB_execute_admin_add_incoming (struct MHD_Connection *connection,
|
|||||||
struct GNUNET_TIME_Absolute execution_time,
|
struct GNUNET_TIME_Absolute execution_time,
|
||||||
json_t *wire)
|
json_t *wire)
|
||||||
{
|
{
|
||||||
GNUNET_break (0); // FIXME: #3851!
|
struct TALER_MINTDB_Session *session;
|
||||||
return MHD_NO;
|
int ret;
|
||||||
|
|
||||||
|
if (NULL == (session = TMH_plugin->get_session (TMH_plugin->cls,
|
||||||
|
TMH_test_mode)))
|
||||||
|
{
|
||||||
|
GNUNET_break (0);
|
||||||
|
return TMH_RESPONSE_reply_internal_db_error (connection);
|
||||||
|
}
|
||||||
|
ret = TMH_plugin->reserves_in_insert (TMH_plugin->cls,
|
||||||
|
session,
|
||||||
|
reserve_pub,
|
||||||
|
amount,
|
||||||
|
execution_time,
|
||||||
|
wire);
|
||||||
|
if (GNUNET_SYSERR == ret)
|
||||||
|
{
|
||||||
|
GNUNET_break (0);
|
||||||
|
return TMH_RESPONSE_reply_internal_db_error (connection);
|
||||||
|
}
|
||||||
|
return TMH_RESPONSE_reply_json_pack (connection,
|
||||||
|
MHD_HTTP_OK,
|
||||||
|
"{s:s}",
|
||||||
|
"status",
|
||||||
|
(GNUNET_OK == ret)
|
||||||
|
? "NEW"
|
||||||
|
: "DUP");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1284,6 +1284,7 @@ reserves_update (void *cls,
|
|||||||
* @param session the database connection handle
|
* @param session the database connection handle
|
||||||
* @param reserve_pub public key of the reserve
|
* @param reserve_pub public key of the reserve
|
||||||
* @param balance the amount that has to be added to the reserve
|
* @param balance the amount that has to be added to the reserve
|
||||||
|
* @param execution_time when was the amount added
|
||||||
* @param details bank transaction details justifying the increment,
|
* @param details bank transaction details justifying the increment,
|
||||||
* must be unique for each incoming transaction
|
* must be unique for each incoming transaction
|
||||||
* @return #GNUNET_OK upon success; #GNUNET_NO if the given
|
* @return #GNUNET_OK upon success; #GNUNET_NO if the given
|
||||||
@ -1295,12 +1296,12 @@ postgres_reserves_in_insert (void *cls,
|
|||||||
struct TALER_MINTDB_Session *session,
|
struct TALER_MINTDB_Session *session,
|
||||||
const struct TALER_ReservePublicKeyP *reserve_pub,
|
const struct TALER_ReservePublicKeyP *reserve_pub,
|
||||||
const struct TALER_Amount *balance,
|
const struct TALER_Amount *balance,
|
||||||
|
struct GNUNET_TIME_Absolute execution_time,
|
||||||
const json_t *details)
|
const json_t *details)
|
||||||
{
|
{
|
||||||
PGresult *result;
|
PGresult *result;
|
||||||
int reserve_exists;
|
int reserve_exists;
|
||||||
struct TALER_MINTDB_Reserve reserve;
|
struct TALER_MINTDB_Reserve reserve;
|
||||||
struct GNUNET_TIME_Absolute now;
|
|
||||||
struct GNUNET_TIME_Absolute expiry;
|
struct GNUNET_TIME_Absolute expiry;
|
||||||
|
|
||||||
if (GNUNET_OK != postgres_start (cls,
|
if (GNUNET_OK != postgres_start (cls,
|
||||||
@ -1318,8 +1319,7 @@ postgres_reserves_in_insert (void *cls,
|
|||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
goto rollback;
|
goto rollback;
|
||||||
}
|
}
|
||||||
now = GNUNET_TIME_absolute_get ();
|
expiry = GNUNET_TIME_absolute_add (execution_time,
|
||||||
expiry = GNUNET_TIME_absolute_add (now,
|
|
||||||
TALER_IDLE_RESERVE_EXPIRATION_TIME);
|
TALER_IDLE_RESERVE_EXPIRATION_TIME);
|
||||||
if (GNUNET_NO == reserve_exists)
|
if (GNUNET_NO == reserve_exists)
|
||||||
{
|
{
|
||||||
@ -1358,7 +1358,7 @@ postgres_reserves_in_insert (void *cls,
|
|||||||
TALER_PQ_query_param_auto_from_type (&reserve.pub),
|
TALER_PQ_query_param_auto_from_type (&reserve.pub),
|
||||||
TALER_PQ_query_param_amount (balance),
|
TALER_PQ_query_param_amount (balance),
|
||||||
TALER_PQ_query_param_json (details),
|
TALER_PQ_query_param_json (details),
|
||||||
TALER_PQ_query_param_absolute_time (&now),
|
TALER_PQ_query_param_absolute_time (&execution_time),
|
||||||
TALER_PQ_query_param_end
|
TALER_PQ_query_param_end
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user