exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

fakebank_common_lp.h (2783B)


      1 /*
      2   This file is part of TALER
      3   (C) 2016-2023 Taler Systems SA
      4 
      5   TALER is free software; you can redistribute it and/or
      6   modify it under the terms of the GNU General Public License
      7   as published by the Free Software Foundation; either version 3,
      8   or (at your option) any later version.
      9 
     10   TALER is distributed in the hope that it will be useful,
     11   but WITHOUT ANY WARRANTY; without even the implied warranty of
     12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13   GNU General Public License for more details.
     14 
     15   You should have received a copy of the GNU General Public
     16   License along with TALER; see the file COPYING.  If not,
     17   see <http://www.gnu.org/licenses/>
     18 */
     19 /**
     20  * @file bank-lib/fakebank_common_lp.h
     21  * @brief long-polling support for fakebank
     22  * @author Christian Grothoff <christian@grothoff.org>
     23  */
     24 #ifndef FAKEBANK_COMMON_LP_H
     25 #define FAKEBANK_COMMON_LP_H
     26 #include "taler/taler_fakebank_lib.h"
     27 
     28 
     29 /**
     30  * Trigger the @a lp. Frees associated resources, except the entry of @a lp in
     31  * the timeout heap.  Must be called while the ``big lock`` is held.
     32  *
     33  * @param[in] lp long poller to trigger
     34  */
     35 void
     36 TALER_FAKEBANK_lp_trigger_ (struct LongPoller *lp);
     37 
     38 
     39 /**
     40  * Trigger long pollers that might have been waiting
     41  * for @a t.
     42  *
     43  * @param h fakebank handle
     44  * @param t transaction to notify on
     45  */
     46 void
     47 TALER_FAKEBANK_notify_transaction_ (
     48   struct TALER_FAKEBANK_Handle *h,
     49   struct Transaction *t);
     50 
     51 
     52 /**
     53  * Notify long pollers that a @a wo was updated.
     54  * Must be called with the "big_lock" still held.
     55  *
     56  * @param h fakebank handle
     57  * @param wo withdraw operation that finished
     58  */
     59 void
     60 TALER_FAKEBANK_notify_withdrawal_ (
     61   struct TALER_FAKEBANK_Handle *h,
     62   const struct WithdrawalOperation *wo);
     63 
     64 
     65 /**
     66  * Start long-polling for @a connection and @a acc
     67  * for transfers in @a dir. Must be called with the
     68  * "big lock" held.
     69  *
     70  * @param[in,out] h fakebank handle
     71  * @param[in,out] connection to suspend
     72  * @param[in,out] acc account affected
     73  * @param lp_timeout how long to suspend
     74  * @param dir direction of transfers to watch for
     75  * @param wo withdraw operation to watch, only
     76  *        if @a dir is #LP_WITHDRAW
     77  */
     78 void
     79 TALER_FAKEBANK_start_lp_ (
     80   struct TALER_FAKEBANK_Handle *h,
     81   struct MHD_Connection *connection,
     82   struct Account *acc,
     83   struct GNUNET_TIME_Relative lp_timeout,
     84   enum LongPollType dir,
     85   const struct WithdrawalOperation *wo);
     86 
     87 
     88 /**
     89  * Main routine of a thread that is run to wake up connections that have hit
     90  * their timeout. Runs until in_shutdown is set to true. Must be send signals
     91  * via lp_event on shutdown and/or whenever the heap changes to an earlier
     92  * timeout.
     93  *
     94  * @param cls a `struct TALER_FAKEBANK_Handle *`
     95  * @return NULL
     96  */
     97 void *
     98 TALER_FAKEBANK_lp_expiration_thread_ (void *cls);
     99 
    100 #endif