Skip to content
This repository was archived by the owner on Dec 26, 2022. It is now read-only.

Commit e900bf5

Browse files
committed
feat(api): Implement IRI Proxy API
1 parent afff715 commit e900bf5

File tree

7 files changed

+537
-65
lines changed

7 files changed

+537
-65
lines changed

accelerator/BUILD

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ cc_binary(
99
copts = ["-DLOGGER_ENABLE"],
1010
deps = [
1111
":apis",
12+
":proxy_apis",
1213
":ta_config",
1314
":ta_errors",
1415
"@served",
@@ -80,13 +81,28 @@ cc_library(
8081
],
8182
)
8283

84+
cc_library(
85+
name = "proxy_apis",
86+
srcs = ["proxy_apis.c"],
87+
hdrs = ["proxy_apis.h"],
88+
visibility = ["//visibility:public"],
89+
deps = [
90+
":ta_errors",
91+
"@entangled//cclient/api",
92+
"@entangled//cclient/request:requests",
93+
"@entangled//cclient/response:responses",
94+
"@entangled//utils:logger_helper",
95+
],
96+
)
97+
8398
cc_library(
8499
name = "http",
85100
srcs = ["http.c"],
86101
hdrs = ["http.h"],
87102
visibility = ["//visibility:public"],
88103
deps = [
89104
":apis",
105+
":proxy_apis",
90106
":ta_config",
91107
":ta_errors",
92108
"@libmicrohttpd",

accelerator/apis.c

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -154,55 +154,6 @@ status_t api_generate_address(const iota_config_t* const iconf, const iota_clien
154154
return ret;
155155
}
156156

157-
status_t api_find_transactions(const iota_client_service_t* const service, const char* const obj, char** json_result) {
158-
status_t ret = SC_OK;
159-
find_transactions_req_t* req = find_transactions_req_new();
160-
find_transactions_res_t* res = find_transactions_res_new();
161-
char_buffer_t* res_buff = char_buffer_new();
162-
if (req == NULL || res == NULL || res_buff == NULL) {
163-
ret = SC_TA_OOM;
164-
ta_log_error("%s\n", "SC_TA_OOM");
165-
goto done;
166-
}
167-
lock_handle_lock(&cjson_lock);
168-
if (service->serializer.vtable.find_transactions_deserialize_request(obj, req) != RC_OK) {
169-
lock_handle_unlock(&cjson_lock);
170-
ret = SC_CCLIENT_JSON_PARSE;
171-
ta_log_error("%s\n", "SC_CCLIENT_JSON_PARSE");
172-
goto done;
173-
}
174-
lock_handle_unlock(&cjson_lock);
175-
176-
lock_handle_lock(&cjson_lock);
177-
if (iota_client_find_transactions(service, req, res) != RC_OK) {
178-
lock_handle_unlock(&cjson_lock);
179-
ret = SC_CCLIENT_FAILED_RESPONSE;
180-
ta_log_error("%s\n", "SC_CCLIENT_FAILED_RESPONSE");
181-
goto done;
182-
}
183-
lock_handle_unlock(&cjson_lock);
184-
185-
if (service->serializer.vtable.find_transactions_serialize_response(res, res_buff) != RC_OK) {
186-
ret = SC_CCLIENT_JSON_PARSE;
187-
ta_log_error("%s\n", "SC_CCLIENT_JSON_PARSE");
188-
goto done;
189-
}
190-
191-
*json_result = (char*)malloc((res_buff->length + 1) * sizeof(char));
192-
if (*json_result == NULL) {
193-
ret = SC_CCLIENT_JSON_PARSE;
194-
ta_log_error("%s\n", "SC_CCLIENT_JSON_PARSE");
195-
goto done;
196-
}
197-
snprintf(*json_result, (res_buff->length + 1), "%s", res_buff->data);
198-
199-
done:
200-
find_transactions_req_free(&req);
201-
find_transactions_res_free(&res);
202-
char_buffer_free(res_buff);
203-
return ret;
204-
}
205-
206157
status_t api_find_transaction_object_single(const iota_client_service_t* const service, const char* const obj,
207158
char** json_result) {
208159
status_t ret = SC_OK;

accelerator/apis.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -179,22 +179,6 @@ status_t api_mam_send_message(const iota_config_t* const iconf, const iota_clien
179179
status_t api_send_transfer(const iota_config_t* const iconf, const iota_client_service_t* const service,
180180
const char* const obj, char** json_result);
181181

182-
/**
183-
* @brief Return transaction hashes with given information such as bundle hashes, addresses, tags, or approvees.
184-
*
185-
* Explore transaction hash with given transaction related information. This would
186-
* return a list of transaction hashes in json format.
187-
*
188-
* @param[in] service IRI node end point service
189-
* @param[in] obj bundle hashes, addresses, tags, or approvees.
190-
* @param[out] json_result Result containing transaction objects in json format
191-
*
192-
* @return
193-
* - SC_OK on success
194-
* - non-zero on error
195-
*/
196-
status_t api_find_transactions(const iota_client_service_t* const service, const char* const obj, char** json_result);
197-
198182
/**
199183
* @brief Return transaction object with given single transaction hash.
200184
*

accelerator/http.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "accelerator/apis.h"
66
#include "accelerator/config.h"
77
#include "accelerator/errors.h"
8+
#include "accelerator/proxy_apis.h"
89

910
#ifdef __cplusplus
1011
extern "C" {

0 commit comments

Comments
 (0)