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

Commit b651b1d

Browse files
committed
feat(README): Add description of Proxy API
1 parent 1330a7f commit b651b1d

File tree

3 files changed

+35
-8
lines changed

3 files changed

+35
-8
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,20 @@ clang-format can be installed by command:
172172
- macOS: `$ brew install clang-format`
173173

174174

175+
## Usage
176+
`Tangle-accelerator` currently supports two categories of APIs
177+
* direct API: check [wiki page](https://github.com/DLTcollab/tangle-accelerator/wiki) for details.
178+
* Proxy API to IRI core functionalities
179+
180+
### IRI Porxy API
181+
`tangle-accelerator` allows the use of IRI core APIs. The calling process does not have to be aware of the destination machine running IRI. With the exactly same format of IRI API, `tangle-accelerator` would help user forward the request to IRI and forward the the response back to user. The followings are currently supporting Proxy APIs:
182+
* checkConsistency
183+
* findTransactions
184+
* getBalances
185+
* getInclusionStates
186+
* getNodeInfo
187+
* getTrytes
188+
175189
## Licensing
176190
`Tangle-accelerator` is freely redistributable under the MIT License. Use of this source
177191
code is governed by a MIT-style license that can be found in the `LICENSE` file.

accelerator/apis.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ int apis_logger_release() {
2727
return 0;
2828
}
2929

30-
status_t api_get_ta_info(char** json_result, ta_config_t* const info, iota_config_t* const tangle,
31-
ta_cache_t* const cache, iota_client_service_t* const service) {
30+
status_t api_get_ta_info(ta_config_t* const info, iota_config_t* const tangle, ta_cache_t* const cache,
31+
iota_client_service_t* const service, char** json_result) {
3232
return ta_get_info_serialize(json_result, info, tangle, cache, service);
3333
}
3434

@@ -481,7 +481,7 @@ status_t api_mam_send_message(const iota_config_t* const iconf, const iota_clien
481481
// Destroying MAM API
482482
if (ret != SC_MAM_FAILED_INIT) {
483483
// If `seed` is not assigned, then the local MAM file will be used. Therefore, we need to close the MAM file.
484-
if (!req->seed[0] && mam_api_save(&mam, iconf->mam_file_path, NULL, 0) != RC_OK) {
484+
if (!req->seed && mam_api_save(&mam, iconf->mam_file_path, NULL, 0) != RC_OK) {
485485
ta_log_error("%s\n", "SC_MAM_FILE_SAVE");
486486
}
487487
if (mam_api_destroy(&mam)) {

tests/driver.c

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,18 +195,31 @@ void test_find_transactions_obj_by_tag(void) {
195195

196196
void test_send_mam_message(void) {
197197
double sum = 0;
198-
const char* json = "{\"message\":\"" TEST_PAYLOAD "\"}";
199-
char* json_result;
198+
const char* json =
199+
"{\"seed\":\"" TRYTES_81_1
200+
"\",\"channel_ord\":" STR(TEST_CHANNEL_ORD) ",\"message\":\"" TEST_PAYLOAD "\",\"ch_mss_depth\":" STR(
201+
TEST_CH_DEPTH) ",\"ep_mss_depth\":" STR(TEST_EP_DEPTH) ",\"ntru_pk\":\"" TEST_NTRU_PK
202+
"\",\"psk\":\"" TRYTES_81_2 "\"}";
203+
char* json_result = NULL;
200204
res = send_mam_res_new();
205+
status_t ret = SC_OK;
206+
bool result = false;
201207

202208
for (size_t count = 0; count < TEST_COUNT; count++) {
203209
test_time_start(&start_time);
204-
TEST_ASSERT_EQUAL_INT32(SC_OK, api_mam_send_message(&ta_core.iconf, &ta_core.service, json, &json_result));
210+
ret = api_mam_send_message(&ta_core.iconf, &ta_core.service, json, &json_result);
211+
if (ret == SC_OK || ret == SC_MAM_ALL_MSS_KEYS_USED) {
212+
result = true;
213+
}
214+
TEST_ASSERT_TRUE(result);
215+
205216
send_mam_res_deserialize(json_result, res);
206217

207218
test_time_end(&start_time, &end_time, &sum);
208219
free(json_result);
220+
json_result = NULL;
209221
}
222+
free(json_result);
210223
printf("Average time of send_mam_message: %lf\n", sum / TEST_COUNT);
211224
}
212225

@@ -217,8 +230,8 @@ void test_receive_mam_message(void) {
217230
for (size_t count = 0; count < TEST_COUNT; count++) {
218231
test_time_start(&start_time);
219232

220-
TEST_ASSERT_EQUAL_INT32(
221-
SC_OK, api_receive_mam_message(&ta_core.iconf, &ta_core.service, (char*)res->channel_id, &json_result));
233+
TEST_ASSERT_EQUAL_INT32(SC_OK,
234+
api_receive_mam_message(&ta_core.iconf, &ta_core.service, (char*)res->chid, &json_result));
222235
test_time_end(&start_time, &end_time, &sum);
223236
free(json_result);
224237
}

0 commit comments

Comments
 (0)