diff options
Diffstat (limited to 'src/include/anastasis_redux.h')
-rw-r--r-- | src/include/anastasis_redux.h | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/src/include/anastasis_redux.h b/src/include/anastasis_redux.h new file mode 100644 index 0000000..7a0ff53 --- /dev/null +++ b/src/include/anastasis_redux.h | |||
@@ -0,0 +1,127 @@ | |||
1 | /* | ||
2 | This file is part of Anastasis | ||
3 | Copyright (C) 2020, 2021 Taler Systems SA | ||
4 | |||
5 | Anastasis is free software; you can redistribute it and/or modify it under the | ||
6 | terms of the GNU Lesser General Public License as published by the Free Software | ||
7 | Foundation; either version 3, or (at your option) any later version. | ||
8 | |||
9 | Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY | ||
10 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR | ||
11 | A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
12 | |||
13 | You should have received a copy of the GNU General Public License along with | ||
14 | Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/> | ||
15 | */ | ||
16 | /** | ||
17 | * @file include/anastasis_redux.h | ||
18 | * @brief anastasis reducer api | ||
19 | * @author Christian Grothoff | ||
20 | * @author Dominik Meister | ||
21 | * @author Dennis Neufeld | ||
22 | */ | ||
23 | #ifndef ANASTASIS_REDUX_H | ||
24 | #define ANASTASIS_REDUX_H | ||
25 | |||
26 | #include <jansson.h> | ||
27 | #include "anastasis.h" | ||
28 | #include <taler/taler_mhd_lib.h> | ||
29 | #include <regex.h> | ||
30 | |||
31 | |||
32 | /** | ||
33 | * Initialize reducer subsystem. | ||
34 | * | ||
35 | * @param ctx context to use for CURL requests. | ||
36 | */ | ||
37 | void | ||
38 | ANASTASIS_redux_init (struct GNUNET_CURL_Context *ctx); | ||
39 | |||
40 | |||
41 | /** | ||
42 | * Terminate reducer subsystem. | ||
43 | */ | ||
44 | void | ||
45 | ANASTASIS_redux_done (void); | ||
46 | |||
47 | |||
48 | /** | ||
49 | * Returns an initial ANASTASIS backup state. | ||
50 | * | ||
51 | * @return NULL on failure | ||
52 | */ | ||
53 | json_t * | ||
54 | ANASTASIS_backup_start (const struct GNUNET_CONFIGURATION_Handle *cfg); | ||
55 | |||
56 | |||
57 | /** | ||
58 | * Returns an initial ANASTASIS recovery state. | ||
59 | * | ||
60 | * @return NULL on failure | ||
61 | */ | ||
62 | json_t * | ||
63 | ANASTASIS_recovery_start (const struct GNUNET_CONFIGURATION_Handle *cfg); | ||
64 | |||
65 | |||
66 | /** | ||
67 | * Returns an initial ANASTASIS recovery state. | ||
68 | * | ||
69 | * @return NULL on failure | ||
70 | */ | ||
71 | json_t * | ||
72 | ANASTASIS_recovery_start (const struct GNUNET_CONFIGURATION_Handle *cfg); | ||
73 | |||
74 | |||
75 | /** | ||
76 | * Signature of the callback passed to #ANASTASIS_backup_action and | ||
77 | * #ANASTASIS_recover_action. | ||
78 | * | ||
79 | * @param cls closure | ||
80 | * @param error error code, #TALER_EC_NONE if @a new_bs is the new successful state | ||
81 | * @param new_state the new state of the operation (client should json_incref() to keep an alias) | ||
82 | */ | ||
83 | typedef void | ||
84 | (*ANASTASIS_ActionCallback)(void *cls, | ||
85 | enum TALER_ErrorCode error, | ||
86 | json_t *new_state); | ||
87 | |||
88 | |||
89 | /** | ||
90 | * Handle to an ongoing action. Only valid until the #ANASTASIS_ActionCallback is invoked. | ||
91 | */ | ||
92 | struct ANASTASIS_ReduxAction; | ||
93 | |||
94 | |||
95 | /** | ||
96 | * Operates on a state depending on given #ANASTASIS_BackupState | ||
97 | * or #ANASTASIS_RecoveryState and #ANASTASIS_BackupAction or | ||
98 | * #ANASTASIS_RecoveryAction. | ||
99 | * The new #ANASTASIS_BackupState or #ANASTASIS_RecoveryState is returned | ||
100 | * by a callback function. | ||
101 | * This function can do network access to talk to anastasis service providers. | ||
102 | * | ||
103 | * @param state input state | ||
104 | * @param action what action to perform | ||
105 | * @param arguments data for the @a action | ||
106 | * @param cb function to call with the result | ||
107 | * @param cb_cls closure for @a cb | ||
108 | * @return failure state or new state | ||
109 | */ | ||
110 | struct ANASTASIS_ReduxAction * | ||
111 | ANASTASIS_redux_action (const json_t *state, | ||
112 | const char *action, | ||
113 | const json_t *arguments, | ||
114 | ANASTASIS_ActionCallback cb, | ||
115 | void *cb_cls); | ||
116 | |||
117 | |||
118 | /** | ||
119 | * Cancel ongoing redux action. | ||
120 | * | ||
121 | * @param ra action to cancel | ||
122 | */ | ||
123 | void | ||
124 | ANASTASIS_redux_action_cancel (struct ANASTASIS_ReduxAction *ra); | ||
125 | |||
126 | |||
127 | #endif /* _ANASTASIS_REDUX_H */ | ||