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

Commit

Permalink
feat(README): Add description of Proxy API
Browse files Browse the repository at this point in the history
  • Loading branch information
howjmay committed Oct 29, 2019
1 parent 1330a7f commit b651b1d
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 8 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,20 @@ clang-format can be installed by command:
- macOS: `$ brew install clang-format`


## Usage
`Tangle-accelerator` currently supports two categories of APIs
* direct API: check [wiki page](https://github.com/DLTcollab/tangle-accelerator/wiki) for details.
* Proxy API to IRI core functionalities

### IRI Porxy API
`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:
* checkConsistency
* findTransactions
* getBalances
* getInclusionStates
* getNodeInfo
* getTrytes

## Licensing
`Tangle-accelerator` is freely redistributable under the MIT License. Use of this source
code is governed by a MIT-style license that can be found in the `LICENSE` file.
6 changes: 3 additions & 3 deletions accelerator/apis.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ int apis_logger_release() {
return 0;
}

status_t api_get_ta_info(char** json_result, ta_config_t* const info, iota_config_t* const tangle,
ta_cache_t* const cache, iota_client_service_t* const service) {
status_t api_get_ta_info(ta_config_t* const info, iota_config_t* const tangle, ta_cache_t* const cache,
iota_client_service_t* const service, char** json_result) {
return ta_get_info_serialize(json_result, info, tangle, cache, service);
}

Expand Down Expand Up @@ -481,7 +481,7 @@ status_t api_mam_send_message(const iota_config_t* const iconf, const iota_clien
// Destroying MAM API
if (ret != SC_MAM_FAILED_INIT) {
// If `seed` is not assigned, then the local MAM file will be used. Therefore, we need to close the MAM file.
if (!req->seed[0] && mam_api_save(&mam, iconf->mam_file_path, NULL, 0) != RC_OK) {
if (!req->seed && mam_api_save(&mam, iconf->mam_file_path, NULL, 0) != RC_OK) {
ta_log_error("%s\n", "SC_MAM_FILE_SAVE");
}
if (mam_api_destroy(&mam)) {
Expand Down
23 changes: 18 additions & 5 deletions tests/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,18 +195,31 @@ void test_find_transactions_obj_by_tag(void) {

void test_send_mam_message(void) {
double sum = 0;
const char* json = "{\"message\":\"" TEST_PAYLOAD "\"}";
char* json_result;
const char* json =
"{\"seed\":\"" TRYTES_81_1
"\",\"channel_ord\":" STR(TEST_CHANNEL_ORD) ",\"message\":\"" TEST_PAYLOAD "\",\"ch_mss_depth\":" STR(
TEST_CH_DEPTH) ",\"ep_mss_depth\":" STR(TEST_EP_DEPTH) ",\"ntru_pk\":\"" TEST_NTRU_PK
"\",\"psk\":\"" TRYTES_81_2 "\"}";
char* json_result = NULL;
res = send_mam_res_new();
status_t ret = SC_OK;
bool result = false;

for (size_t count = 0; count < TEST_COUNT; count++) {
test_time_start(&start_time);
TEST_ASSERT_EQUAL_INT32(SC_OK, api_mam_send_message(&ta_core.iconf, &ta_core.service, json, &json_result));
ret = api_mam_send_message(&ta_core.iconf, &ta_core.service, json, &json_result);
if (ret == SC_OK || ret == SC_MAM_ALL_MSS_KEYS_USED) {
result = true;
}
TEST_ASSERT_TRUE(result);

send_mam_res_deserialize(json_result, res);

test_time_end(&start_time, &end_time, &sum);
free(json_result);
json_result = NULL;
}
free(json_result);
printf("Average time of send_mam_message: %lf\n", sum / TEST_COUNT);
}

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

TEST_ASSERT_EQUAL_INT32(
SC_OK, api_receive_mam_message(&ta_core.iconf, &ta_core.service, (char*)res->channel_id, &json_result));
TEST_ASSERT_EQUAL_INT32(SC_OK,
api_receive_mam_message(&ta_core.iconf, &ta_core.service, (char*)res->chid, &json_result));
test_time_end(&start_time, &end_time, &sum);
free(json_result);
}
Expand Down

0 comments on commit b651b1d

Please sign in to comment.