summaryrefslogtreecommitdiff
path: root/src/bank-lib/fakebank.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-01-11 15:19:56 +0100
committerChristian Grothoff <christian@grothoff.org>2020-01-11 15:20:17 +0100
commit9443c10d7feb0d91323869dd08ec61ca781564f4 (patch)
treefd617ea56cc1d2ea370ce7e5467574a536b52d28 /src/bank-lib/fakebank.h
parent554da10133eb491b352a106b98ebeaed797133bb (diff)
downloadexchange-9443c10d7feb0d91323869dd08ec61ca781564f4.tar.gz
exchange-9443c10d7feb0d91323869dd08ec61ca781564f4.tar.bz2
exchange-9443c10d7feb0d91323869dd08ec61ca781564f4.zip
major refactoring, eliminating wire-plugins and moving towards new bank API. main code compiles, testcases known to fail, code sure not to fully work yet
Diffstat (limited to 'src/bank-lib/fakebank.h')
-rw-r--r--src/bank-lib/fakebank.h283
1 files changed, 2 insertions, 281 deletions
diff --git a/src/bank-lib/fakebank.h b/src/bank-lib/fakebank.h
index cc2359014..c52902f14 100644
--- a/src/bank-lib/fakebank.h
+++ b/src/bank-lib/fakebank.h
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- (C) 2016, 2017, 2018 Inria and GNUnet e.V.
+ (C) 2016-2020 Taler Systems SA
TALER is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
@@ -19,7 +19,7 @@
/**
* @file bank-lib/fakebank.h
- * @brief definitions for the "/history[-range]" layer.
+ * @brief definitions for the "/history" layer.
* @author Marcello Stanisci <stanisci.m@gmail.com>
*/
@@ -29,283 +29,4 @@
#include <gnunet/gnunet_util_lib.h>
#include "taler_bank_service.h"
-/**
- * Details about a transcation we (as the simulated bank) received.
- */
-struct Transaction
-{
- /**
- * We store transactions in a DLL.
- */
- struct Transaction *next;
-
- /**
- * We store transactions in a DLL.
- */
- struct Transaction *prev;
-
- /**
- * Amount to be transferred.
- */
- struct TALER_Amount amount;
-
- /**
- * Account to debit.
- */
- uint64_t debit_account;
-
- /**
- * Account to credit.
- */
- uint64_t credit_account;
-
- /**
- * Subject of the transfer.
- */
- char *subject;
-
- /**
- * Base URL of the exchange.
- */
- char *exchange_base_url;
-
- /**
- * When did the transaction happen?
- */
- struct GNUNET_TIME_Absolute date;
-
- /**
- * Number of this transaction.
- */
- long long unsigned int row_id;
-
- /**
- * Flag set if the transfer was rejected.
- */
- int rejected;
-
- /**
- * Has this transaction been subjected to #TALER_FAKEBANK_check()
- * and should thus no longer be counted in
- * #TALER_FAKEBANK_check_empty()?
- */
- int checked;
-};
-
-
-/******************************************
- * Definitions for "/history" start here. *
- ******************************************/
-
-/**
- * Needed to implement ascending/descending ordering
- * of /history results.
- */
-struct HistoryElement
-{
-
- /**
- * History JSON element.
- */
- json_t *element;
-
- /**
- * Previous element.
- */
- struct HistoryElement *prev;
-
- /**
- * Next element.
- */
- struct HistoryElement *next;
-};
-
-
-/**
- * Values to implement the "/history-range" range.
- */
-struct HistoryRangeDates
-{
- /**
- * Oldest row in the results.
- */
- struct GNUNET_TIME_Absolute start;
-
- /**
- * Youngest row in the results.
- */
- struct GNUNET_TIME_Absolute end;
-};
-
-/**
- * Values to implement the "/history" range.
- */
-struct HistoryRangeIds
-{
-
- /**
- * (Exclusive) row ID for the result set.
- */
- unsigned long long start;
-
- /**
- * How many transactions we want in the result set. If
- * negative/positive, @a start will be strictly younger/older
- * of any element in the result set.
- */
- long long count;
-};
-
-
-/**
- * This is the "base" structure for both the /history and the
- * /history-range API calls.
- */
-struct HistoryArgs
-{
-
- /**
- * Direction asked by the client: CREDIT / DEBIT / BOTH / CANCEL.
- */
- enum TALER_BANK_Direction direction;
-
- /**
- * Bank account number of the requesting client.
- */
- unsigned long long account_number;
-
- /**
- * Ordering of the results.
- */
- unsigned int ascending;
-
- /**
- * Overloaded type that indicates the "range" to be returned
- * in the results; this can be either a date range, or a
- * starting row id + the count.
- */
- void *range;
-};
-
-
-/**
- * Type for a function that decides whether or not
- * the history-building loop should iterate once again.
- * Typically called from inside the 'while' condition.
- *
- * @param ha history argument.
- * @param pos current position.
- * @return GNUNET_YES if the iteration shuold go on.
- */
-typedef int (*CheckAdvance)(const struct HistoryArgs *ha,
- const struct Transaction *pos);
-
-/**
- * Type for a function that steps over the next element
- * in the list of all transactions, after the current @a pos
- * _got_ included in the result.
- */
-typedef struct Transaction * (*Step)(const struct HistoryArgs *ha,
- const struct Transaction *pos);
-
-/*
- * Type for a function that steps over the next element
- * in the list of all transactions, after the current @a pos
- * did _not_ get included in the result.
- */
-typedef struct Transaction * (*Skip)(const struct HistoryArgs *ha,
- const struct Transaction *pos);
-
-/**
- * Actual history response builder.
- *
- * @param pos first (included) element in the result set.
- * @param ha history arguments.
- * @param caller_name which function is building the history.
- * @return MHD_YES / MHD_NO, after having enqueued the response
- * object into MHD.
- */
-int
-TFH_build_history_response (struct MHD_Connection *connection,
- struct Transaction *pos,
- struct HistoryArgs *ha,
- Skip skip,
- Step step,
- CheckAdvance advance);
-
-
-/**
- * Parse URL history arguments, of _both_ APIs:
- * /history and /history-range.
- *
- * @param connection MHD connection.
- * @param function_name name of the caller.
- * @param ha[out] will contain the parsed values.
- * @return GNUNET_OK only if the parsing succeedes.
- */
-int
-TFH_parse_history_common_args (struct MHD_Connection *connection,
- struct HistoryArgs *ha);
-
-
-/**
- * Decides whether the history builder will advance or not
- * to the next element.
- *
- * @param ha history args
- * @return GNUNET_YES/NO to advance/not-advance.
- */
-int
-TFH_handle_history_advance (const struct HistoryArgs *ha,
- const struct Transaction *pos);
-
-/**
- * Iterates on the "next" element to be processed. To
- * be used when the current element does not get inserted in
- * the result.
- *
- * @param ha history arguments.
- * @param pos current element being processed.
- * @return the next element to be processed.
- */
-struct Transaction *
-TFH_handle_history_skip (const struct HistoryArgs *ha,
- const struct Transaction *pos);
-
-/**
- * Iterates on the "next" element to be processed. To
- * be used when the current element _gets_ inserted in the result.
- *
- * @param ha history arguments.
- * @param pos current element being processed.
- * @return the next element to be processed.
- */
-struct Transaction *
-TFH_handle_history_step (const struct HistoryArgs *ha,
- const struct Transaction *pos);
-
-/**
- * Decides whether the history builder will advance or not
- * to the next element.
- *
- * @param ha history args
- * @return GNUNET_YES/NO to advance/not-advance.
- */
-int
-TFH_handle_history_range_advance (const struct HistoryArgs *ha,
- const struct Transaction *pos);
-
-/**
- * Iterates towards the "next" element to be processed. To
- * be used when the current element does not get inserted in
- * the result.
- *
- * @param ha history arguments.
- * @param pos current element being processed.
- * @return the next element to be processed.
- */
-struct Transaction *
-TFH_handle_history_range_skip (const struct HistoryArgs *ha,
- const struct Transaction *pos);
-
#endif