From 6a98b07ff2e75a429982eaf6b00ce54c95a28e8e Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 18 Mar 2017 03:44:59 +0100 Subject: add wire_out tracking to exchangedb, including deferred constraint, and to aggregator --- src/exchange/taler-exchange-aggregator.c | 50 +++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 7 deletions(-) (limited to 'src/exchange') diff --git a/src/exchange/taler-exchange-aggregator.c b/src/exchange/taler-exchange-aggregator.c index ae4ee24fd..44154d200 100644 --- a/src/exchange/taler-exchange-aggregator.c +++ b/src/exchange/taler-exchange-aggregator.c @@ -705,8 +705,8 @@ run_aggregation (void *cls) return; } if (GNUNET_OK != - db_plugin->start (db_plugin->cls, - session)) + db_plugin->start_deferred_wire_out (db_plugin->cls, + session)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to start database transaction!\n"); @@ -908,11 +908,6 @@ prepare_cb (void *cls, { struct TALER_EXCHANGEDB_Session *session = au->session; - if (NULL != au->wire) - { - json_decref (au->wire); - au->wire = NULL; - } GNUNET_free_non_null (au->additional_rows); if (NULL == buf) { @@ -922,6 +917,11 @@ prepare_cb (void *cls, /* start again */ task = GNUNET_SCHEDULER_add_now (&run_aggregation, NULL); + if (NULL != au->wire) + { + json_decref (au->wire); + au->wire = NULL; + } GNUNET_free (au); au = NULL; return; @@ -941,10 +941,46 @@ prepare_cb (void *cls, /* start again */ task = GNUNET_SCHEDULER_add_now (&run_aggregation, NULL); + if (NULL != au->wire) + { + json_decref (au->wire); + au->wire = NULL; + } + GNUNET_free (au); + au = NULL; + return; + } + + /* Commit the WTID data to 'wire_out' to finally satisfy aggregation + table constraints */ + if (GNUNET_OK != + db_plugin->store_wire_transfer_out (db_plugin->cls, + session, + au->execution_time, + &au->wtid, + au->wire, + &au->total_amount)) + { + GNUNET_break (0); /* why? how to best recover? */ + db_plugin->rollback (db_plugin->cls, + session); + /* start again */ + task = GNUNET_SCHEDULER_add_now (&run_aggregation, + NULL); + if (NULL != au->wire) + { + json_decref (au->wire); + au->wire = NULL; + } GNUNET_free (au); au = NULL; return; } + if (NULL != au->wire) + { + json_decref (au->wire); + au->wire = NULL; + } GNUNET_free (au); au = NULL; -- cgit v1.2.3