make libfakebank scale

This commit is contained in:
Christian Grothoff 2021-06-19 08:36:17 +02:00
parent 036e711779
commit 50749c462b
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
4 changed files with 795 additions and 373 deletions

View File

@ -67,4 +67,5 @@ libtalerfakebank_la_LIBADD = \
-ljansson \
$(LIBGNURLCURL_LIBS) \
-lmicrohttpd \
-lpthread \
$(XLIB)

File diff suppressed because it is too large Load Diff

View File

@ -59,6 +59,7 @@ run (void *cls,
const struct GNUNET_CONFIGURATION_Handle *cfg)
{
unsigned long long port = 8082;
unsigned long long ram = 1024 * 1024 * 128; /* 128 M entries */
char *currency_string;
(void) cls;
@ -81,9 +82,20 @@ run (void *cls,
"Listening on default port %llu\n",
port);
}
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_number (cfg,
"bank",
"RAM_LIMIT",
&ram))
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Maximum transaction history in RAM set to default of %llu\n",
ram);
}
if (NULL ==
TALER_FAKEBANK_start2 ((uint16_t) port,
currency_string,
ram,
num_threads,
(0 != connection_close) ))
ret = 1;

View File

@ -64,6 +64,7 @@ TALER_FAKEBANK_start (uint16_t port,
*
* @param port port to listen to
* @param currency which currency should the bank offer
* @param ram_limit how much memory do we use at most
* @param num_threads size of the thread pool, 0 to use the GNUnet scheduler
* @param close_connections true to force closing a connection after each request (no HTTP keep-alive)
* @return NULL on error
@ -71,6 +72,7 @@ TALER_FAKEBANK_start (uint16_t port,
struct TALER_FAKEBANK_Handle *
TALER_FAKEBANK_start2 (uint16_t port,
const char *currency,
uint64_t ram_limit,
unsigned int num_threads,
bool close_connections);
@ -81,6 +83,9 @@ TALER_FAKEBANK_start2 (uint16_t port,
* or #TALER_FAKEBANK_check_credit()).
* If any transactions are onrecord, return #GNUNET_SYSERR.
*
* Note that this function only works in
* single-threaded mode while nothing else is happening.
*
* @param h bank instance
* @return #GNUNET_OK on success
*/
@ -139,6 +144,9 @@ TALER_FAKEBANK_make_admin_transfer (
* to the transfer identifier and remove the transaction from the
* list. If the transaction was not recorded, return #GNUNET_SYSERR.
*
* Note that this function only works in
* single-threaded mode while nothing else is happening.
*
* @param h bank instance
* @param want_amount transfer amount desired
* @param want_debit account that should have been debited
@ -162,6 +170,9 @@ TALER_FAKEBANK_check_debit (struct TALER_FAKEBANK_Handle *h,
* @a want_credit account with the @a subject. If so, remove the transaction
* from the list. If the transaction was not recorded, return #GNUNET_SYSERR.
*
* Note that this function only works in
* single-threaded mode while nothing else is happening.
*
* @param h bank instance
* @param want_amount transfer amount desired
* @param want_debit account that should have been debited