summaryrefslogtreecommitdiff
path: root/src/authorization/anastasis-helper-authorization-iban.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/authorization/anastasis-helper-authorization-iban.c')
-rw-r--r--src/authorization/anastasis-helper-authorization-iban.c60
1 files changed, 34 insertions, 26 deletions
diff --git a/src/authorization/anastasis-helper-authorization-iban.c b/src/authorization/anastasis-helper-authorization-iban.c
index 946b008..066b4cb 100644
--- a/src/authorization/anastasis-helper-authorization-iban.c
+++ b/src/authorization/anastasis-helper-authorization-iban.c
@@ -25,13 +25,14 @@
* - needs to add DB triggers to notify main service of inbound activity
*/
#include "platform.h"
+#include "anastasis_eufin_lib.h"
+#include "anastasis_database_lib.h"
+#include "anastasis_util_lib.h"
+#include <taler/taler_json_lib.h>
#include <gnunet/gnunet_util_lib.h>
#include <jansson.h>
#include <pthread.h>
#include <microhttpd.h>
-#include <taler/taler_json_lib.h>
-#include <XXX_bank_service.h>
-#include "anastasis_db_lib.h"
/**
* How long to wait for an HTTP reply if there
@@ -40,19 +41,24 @@
#define LONGPOLL_TIMEOUT GNUNET_TIME_UNIT_HOURS
/**
+ * How long to wait between HTTP requests?
+ */
+#define RETRY_TIMEOUT GNUNET_TIME_UNIT_MINUTES
+
+/**
* Authentication data needed to access the account.
*/
-static struct BANK_AccountInfo *auth;
+static struct ANASTASIS_EUFIN_AuthenticationData auth;
/**
* Bank account payto://-URI this process is monitoring.
*/
-static struct credit_account_uri;
+static char *credit_account_uri;
/**
* Active request for history.
*/
-static struct BANK_CreditHistoryHandle *hh;
+static struct ANASTASIS_EUFIN_CreditHistoryHandle *hh;
/**
* Handle to the context for interacting with the bank.
@@ -92,6 +98,12 @@ static struct GNUNET_TIME_Relative idle_sleep_interval;
static int global_ret;
/**
+ * Run in test-mode, do not background, only import currently
+ * pending transactions.
+ */
+static int test_mode;
+
+/**
* Current task waiting for execution, if any.
*/
static struct GNUNET_SCHEDULER_Task *task;
@@ -108,7 +120,7 @@ shutdown_task (void *cls)
(void) cls;
if (NULL != hh)
{
- BANK_credit_history_cancel (hh);
+ ANASTASIS_EUFIN_credit_history_cancel (hh);
hh = NULL;
}
if (NULL != ctx)
@@ -157,11 +169,10 @@ history_cb (void *cls,
unsigned int http_status,
enum TALER_ErrorCode ec,
uint64_t serial_id,
- const struct BANK_CreditDetails *details)
+ const struct ANASTASIS_EUFIN_CreditDetails *details)
{
enum GNUNET_DB_QueryStatus qs;
- (void) json;
if (NULL == details)
{
hh = NULL;
@@ -175,9 +186,9 @@ history_cb (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"End of list.\n");
GNUNET_assert (NULL == task);
- task = GNUNET_SCHEDULER_add_at (delayed_until,
- &find_transfers,
- NULL);
+ task = GNUNET_SCHEDULER_add_delayed (idle_sleep_interval,
+ &find_transfers,
+ NULL);
return GNUNET_OK; /* will be ignored anyway */
}
if (serial_id <= latest_row_off)
@@ -200,7 +211,7 @@ history_cb (void *cls,
&details->amount,
details->debit_account_uri,
details->credit_account_uri,
- details->execution_time);
+ details->execution_date);
switch (qs)
{
case GNUNET_DB_STATUS_HARD_ERROR:
@@ -234,20 +245,18 @@ history_cb (void *cls,
static void
find_transfers (void *cls)
{
- enum GNUNET_DB_QueryStatus qs;
-
(void) cls;
task = NULL;
GNUNET_assert (NULL == hh);
- hh = BANK_credit_history (ctx,
- &auth,
- latest_row_off,
- 1024,
- test_mode
- ? GNUNET_TIME_UNIT_ZERO
- : LONGPOLL_TIMEOUT,
- &history_cb,
- NULL);
+ hh = ANASTASIS_EUFIN_credit_history (ctx,
+ &auth,
+ latest_row_off,
+ 1024,
+ test_mode
+ ? GNUNET_TIME_UNIT_ZERO
+ : LONGPOLL_TIMEOUT,
+ &history_cb,
+ NULL);
if (NULL == hh)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -310,8 +319,7 @@ run (void *cls,
GNUNET_break (0);
return;
}
- latest_row_off = FIXME; // need new DB function!
-
+ idle_sleep_interval = RETRY_TIMEOUT;
task = GNUNET_SCHEDULER_add_now (&find_transfers,
NULL);
}