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

Commit 6a2ee2d

Browse files
committed
refactor: Use node instead of IRI
`IRI` is not an appropriate wording for IOTA full node, since there are different IOTA full node implementation now. Therefore, we are going to use IOTA full node to replace `IRI`.
1 parent c39a48f commit 6a2ee2d

File tree

23 files changed

+151
-148
lines changed

23 files changed

+151
-148
lines changed

README.md

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use scenarios such as MAM and [TangleID](https://tangleid.github.io/).
1919

2020
At the moment, it is not feasible to host fully-functioned full nodes on Raspberry Pi class
2121
Arm devices, but Raspberry Pi 3 is known to be capable to execute `Tangle-accelerator`
22-
without problems. Since it is written in C/C++ with [entangled](https://github.com/iotaledger/entangled),
22+
without problems. Since it is written in C/C++ with [iota.c](https://github.com/iotaledger/iota.c),
2323
both footprint and startup time are behaved pretty well.
2424

2525
## Architecture
@@ -90,27 +90,30 @@ Tangle-accelerator is built and launched through Bazel, it also requires Redis t
9090

9191
## Build from Source
9292

93-
Before running tangle-accelerator, please edit binding address/port of accelerator instance, IRI, and redis server in `accelerator/config.h` unless they are all localhost and/or you don't want to provide external connection. With dependency of [entangled](https://github.com/iotaledger/entangled), IRI address doesn't support https at the moment. Here are some configurations and command you might need to change and use:
93+
Before running tangle-accelerator, please edit binding address/port of accelerator instance, IOTA full node, and redis server in `accelerator/config.h` unless they are all localhost and/or you don't want to provide external connection. With dependency of [iota.c](https://github.com/iotaledger/iota.c), IOTA full node address doesn't support https at the moment. Here are some configurations and command you might need to change and use:
9494

95-
* `TA_HOST`: binding address of accelerator instance
96-
* `TA_PORT`: port of accelerator instance
97-
* `IRI_HOST`: binding address of IRI
98-
* `IRI_PORT`: port of IRI
99-
* `HTTP_THREADS`: Determine thread pool size to process HTTP connections.
100-
* `quiet`: Turn off logging message
95+
* `ta_host`: Binding address of accelerator instance.
96+
* `ta_port`: Port of accelerator instance.
97+
* `node_host`: Binding address of IOTA full node which includes IRI and Hornet or other community implementation.
98+
* `node_port`: Port of IOTA full node.
99+
* `http_threads`: Determine thread pool size to process HTTP connections.
100+
* `quiet`: Turn off logging message.
101101

102102
```
103103
$ make && bazel run //accelerator
104104
```
105+
105106
### Building Options
107+
106108
Tangle-accelerator supports several different build time options.
107109

108110
* Docker images
109111
* MQTT connectivity
110112
* External database
111113
* Debug Mode
112114

113-
Debug mode enables tangle-accelerator to display extra `debug` logs.
115+
Debug mode enables tangle-accelerator to display extra `debug` logs.
116+
114117
```
115118
bazel run --define build_type=debug //accelerator
116119
```
@@ -160,13 +163,13 @@ clang-format can be installed by command:
160163
## Usage
161164
`Tangle-accelerator` currently supports two categories of APIs
162165
* Direct API: check [wiki page](https://github.com/DLTcollab/tangle-accelerator/wiki) for details.
163-
* Proxy API to IRI core functionalities
166+
* Proxy API to IOTA core functionalities
164167

165-
### IRI Proxy API
166-
`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 users forward the request to IRI and forward the response back to users.
167-
We support two way to forward Proxy APIs to IRI:
168-
1. Bypass Proxy APIs directly to IRI.
169-
2. Process the Proxy APIs, then transmit them to IRI.
168+
### Full Node Proxy API
169+
`tangle-accelerator` allows the use of IOTA core APIs. The calling process does not have to be aware of the destination machine running IOTA full node. With the exactly same format of IOTA core APIs, `tangle-accelerator` would help users forward the request to IOTA full node and forward the response back to users.
170+
We support two way to forward Proxy APIs to IOTA full node:
171+
1. Bypass Proxy APIs directly to IOTA full node.
172+
2. Process the Proxy APIs, then transmit them to IOTA full node.
170173

171174
The user can choose which way they want with CLI argument `--proxy_passthrough`.
172175
All the Proxy APIs are supported with the first way.

accelerator/cli_info.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ extern "C" {
2222
*/
2323

2424
typedef enum ta_cli_arg_value_e {
25-
/** TA */
25+
/** tangle-accelerator */
2626
TA_HOST_CLI = 127,
2727
TA_PORT_CLI,
2828

29-
/** IRI */
30-
IRI_HOST_CLI,
31-
IRI_PORT_CLI,
32-
IRI_ADDRESS_CLI,
29+
/** IOTA full node */
30+
NODE_HOST_CLI,
31+
NODE_PORT_CLI,
32+
NODE_ADDRESS_CLI,
3333

3434
/** MQTT */
3535
MQTT_HOST_CLI,
@@ -75,23 +75,23 @@ static struct ta_cli_argument_s {
7575
{"ta_port", required_argument, NULL, TA_PORT_CLI, "TA listening port"},
7676
{"http_threads", required_argument, NULL, HTTP_THREADS_CLI,
7777
"Determine thread pool size to process HTTP connections."},
78-
{"iri_host", required_argument, NULL, IRI_HOST_CLI, "IRI listening host"},
79-
{"iri_port", required_argument, NULL, IRI_PORT_CLI, "IRI listening port"},
78+
{"node_host", required_argument, NULL, NODE_HOST_CLI, "IOTA full node listening host"},
79+
{"node_port", required_argument, NULL, NODE_PORT_CLI, "IOTA full node listening port"},
8080
{"CA_PEM", required_argument, NULL, CA_PEM, "The path to CA PEM file"},
8181
{"mqtt_host", required_argument, NULL, MQTT_HOST_CLI, "MQTT listening host"},
8282
{"mqtt_root", required_argument, NULL, MQTT_ROOT_CLI, "MQTT listening topic root"},
83-
{"iri_address", required_argument, NULL, IRI_ADDRESS_CLI, " List of IRI listening URL"},
83+
{"node_address", required_argument, NULL, NODE_ADDRESS_CLI, " List of IOTA full node listening URL"},
8484
{"redis_host", required_argument, NULL, REDIS_HOST_CLI, "Redis server listening host"},
8585
{"redis_port", required_argument, NULL, REDIS_PORT_CLI, "Redis server listening port"},
8686
{"db_host", required_argument, NULL, DB_HOST_CLI, "DB server listening host"},
87-
{"milestone_depth", optional_argument, NULL, MILESTONE_DEPTH_CLI, "IRI milestone depth"},
87+
{"milestone_depth", optional_argument, NULL, MILESTONE_DEPTH_CLI, "IOTA full node milestone depth"},
8888
{"mwm", optional_argument, NULL, MWM_CLI, "minimum weight magnitude"},
8989
{"seed", optional_argument, NULL, SEED_CLI, "IOTA seed"},
9090
{"cache", required_argument, NULL, CACHE, "Enable/Disable cache server. It defaults to off"},
9191
{"config", required_argument, NULL, CONF_CLI, "Read configuration file"},
92-
{"proxy_passthrough", no_argument, NULL, PROXY_API, "Pass proxy API directly to IRI without processing"},
92+
{"proxy_passthrough", no_argument, NULL, PROXY_API, "Pass proxy API directly to IOTA full node without processing"},
9393
{"health_track_period", no_argument, NULL, HEALTH_TRACK_PERIOD,
94-
"The period for checking IRI host connection status"},
94+
"The period for checking IOTA full node host connection status"},
9595
{"no-gtta", no_argument, NULL, NO_GTTA, "Disable getTransactionToConfirm (gTTA) when sending transaction"},
9696
{"buffer_list", required_argument, NULL, BUFFER_LIST, "Set the value of `buffer_list_name`"},
9797
{"done_list", required_argument, NULL, DONE_LIST, "Set the value of `done_list_name`"},

accelerator/config.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -106,17 +106,17 @@ status_t cli_core_set(ta_core_t* const core, int key, char* const value) {
106106
}
107107
break;
108108

109-
// IRI configuration
110-
case IRI_HOST_CLI:
109+
// IOTA full node configuration
110+
case NODE_HOST_CLI:
111111
idx = 0;
112-
for (char* p = strtok(value, ","); p && idx < MAX_IRI_LIST_ELEMENTS; p = strtok(NULL, ","), idx++) {
112+
for (char* p = strtok(value, ","); p && idx < MAX_NODE_LIST_ELEMENTS; p = strtok(NULL, ","), idx++) {
113113
ta_conf->iota_host_list[idx] = p;
114114
}
115115
strncpy(iota_service->http.host, ta_conf->iota_host_list[0], HOST_MAX_LEN);
116116
break;
117-
case IRI_PORT_CLI:
117+
case NODE_PORT_CLI:
118118
idx = 0;
119-
for (char* p = strtok(value, ","); p && idx < MAX_IRI_LIST_ELEMENTS; p = strtok(NULL, ","), idx++) {
119+
for (char* p = strtok(value, ","); p && idx < MAX_NODE_LIST_ELEMENTS; p = strtok(NULL, ","), idx++) {
120120
strtol_temp = strtol(p, &strtol_p, 10);
121121
if (strtol_p != p && errno != ERANGE && strtol_temp >= 0 && strtol_temp <= USHRT_MAX) {
122122
ta_conf->iota_port_list[idx] = (uint16_t)strtol_temp;
@@ -133,9 +133,9 @@ status_t cli_core_set(ta_core_t* const core, int key, char* const value) {
133133
ta_log_error("%s\n", ta_error_to_string(SC_CONF_FOPEN_ERROR));
134134
return SC_CONF_FOPEN_ERROR;
135135
}
136-
char* temp_ca_pem_path = (char*)malloc(sizeof(char) * (CA_PEM_LEN + 1));
137-
fread(temp_ca_pem_path, CA_PEM_LEN, 1, file);
138-
iota_service->http.ca_pem = temp_ca_pem_path;
136+
char* temp_ca_pem = (char*)malloc(sizeof(char) * (CA_PEM_LEN + 1));
137+
fread(temp_ca_pem, CA_PEM_LEN, 1, file);
138+
iota_service->http.ca_pem = temp_ca_pem;
139139
fclose(file);
140140
break;
141141

@@ -285,8 +285,8 @@ status_t ta_core_default_init(ta_core_t* const core) {
285285
ta_conf->host = TA_HOST;
286286
ta_conf->port = TA_PORT;
287287
memset(ta_conf->iota_host_list, 0, sizeof(ta_conf->iota_host_list));
288-
for (int i = 0; i < MAX_IRI_LIST_ELEMENTS; i++) {
289-
ta_conf->iota_port_list[i] = IRI_PORT;
288+
for (int i = 0; i < MAX_NODE_LIST_ELEMENTS; i++) {
289+
ta_conf->iota_port_list[i] = NODE_PORT;
290290
}
291291
ta_conf->http_tpool_size = DEFAULT_HTTP_TPOOL_SIZE;
292292
ta_conf->proxy_passthrough = false;
@@ -304,21 +304,21 @@ status_t ta_core_default_init(ta_core_t* const core) {
304304
cache->done_list_name = DONE_LIST_NAME;
305305
cache->capacity = CACHE_MAX_CAPACITY;
306306

307-
ta_log_info("Initializing IRI configuration\n");
307+
ta_log_info("Initializing IOTA full node configuration\n");
308308
iota_conf->milestone_depth = MILESTONE_DEPTH;
309309
iota_conf->mwm = MWM;
310310
iota_conf->seed = SEED;
311311
char mam_file_path[] = MAM_FILE_PREFIX;
312312
mkstemp(mam_file_path);
313313
iota_conf->mam_file_path = strdup(mam_file_path);
314314

315-
ta_log_info("Initializing IRI connection\n");
315+
ta_log_info("Initializing IOTA full node connection\n");
316316
strncpy(iota_service->http.path, "/", CONTENT_TYPE_MAX_LEN);
317317
strncpy(iota_service->http.content_type, "application/json", CONTENT_TYPE_MAX_LEN);
318318
strncpy(iota_service->http.accept, "application/json", CONTENT_TYPE_MAX_LEN);
319-
strncpy(iota_service->http.host, IRI_HOST, HOST_MAX_LEN);
319+
strncpy(iota_service->http.host, NODE_HOST, HOST_MAX_LEN);
320320
iota_service->http.ca_pem = DEFAULT_CA_PEM;
321-
iota_service->http.port = IRI_PORT;
321+
iota_service->http.port = NODE_PORT;
322322
iota_service->http.api_version = 1;
323323
iota_service->serializer_type = SR_JSON;
324324
#ifdef DB_ENABLE
@@ -478,7 +478,7 @@ status_t ta_core_set(ta_core_t* core) {
478478
db_client_service_t* const db_service = &core->db_service;
479479
#endif
480480
if (iota_client_service_init(iota_service)) {
481-
ta_log_error("Initializing IRI connection failed!\n");
481+
ta_log_error("Initializing IOTA full node connection failed!\n");
482482
ret = SC_OOM;
483483
goto exit;
484484
}
@@ -504,7 +504,7 @@ status_t ta_core_set(ta_core_t* core) {
504504
}
505505

506506
void ta_core_destroy(ta_core_t* const core) {
507-
ta_log_info("Destroying IRI connection\n");
507+
ta_log_info("Destroying IOTA full node connection\n");
508508
#ifdef DB_ENABLE
509509
ta_log_info("Destroying DB connection\n");
510510
db_client_service_free(&core->db_service);

accelerator/config.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ extern "C" {
4949
#define DEFAULT_HTTP_TPOOL_SIZE 4 /**< Thread number of MHD thread pool */
5050
#define MAX_HTTP_TPOOL_SIZE \
5151
(get_nprocs_conf() - get_nthds_per_phys_proc()) /** < Preserve at least one physical processor */
52-
#define IRI_HOST "localhost"
53-
#define IRI_PORT 443
54-
#define MAX_IRI_LIST_ELEMENTS 5
52+
#define NODE_HOST "localhost"
53+
#define NODE_PORT 443
54+
#define MAX_NODE_LIST_ELEMENTS 5
5555
#define DB_HOST "localhost"
5656
#define MILESTONE_DEPTH 3
5757
#define MWM 14
@@ -73,12 +73,12 @@ extern "C" {
7373

7474
/** struct type of accelerator configuration */
7575
typedef struct ta_config_s {
76-
char* version; /**< Binding version of tangle-accelerator */
77-
char* host; /**< Binding address of tangle-accelerator */
78-
int port; /**< Binding port of tangle-accelerator */
79-
char* iota_host_list[MAX_IRI_LIST_ELEMENTS]; /**< List of binding hosts of IOTA services */
80-
uint16_t iota_port_list[MAX_IRI_LIST_ELEMENTS]; /**< List of binding ports of IOTA services */
81-
int health_track_period; /**< The period for checking IRI host connection status */
76+
char* version; /**< Binding version of tangle-accelerator */
77+
char* host; /**< Binding address of tangle-accelerator */
78+
int port; /**< Binding port of tangle-accelerator */
79+
char* iota_host_list[MAX_NODE_LIST_ELEMENTS]; /**< List of binding hosts of IOTA services */
80+
uint16_t iota_port_list[MAX_NODE_LIST_ELEMENTS]; /**< List of binding ports of IOTA services */
81+
int health_track_period; /**< The period for checking full node connection status */
8282
#ifdef MQTT_ENABLE
8383
char* mqtt_host; /**< Address of MQTT broker host */
8484
char* mqtt_topic_root; /**< The topic root of MQTT topic */

accelerator/core/apis.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -343,30 +343,30 @@ status_t api_send_trytes(const ta_config_t* const info, const iota_config_t* con
343343
return ret;
344344
}
345345

346-
status_t api_get_iri_status(const iota_client_service_t* const service, char** json_result) {
346+
status_t api_get_node_status(const iota_client_service_t* const service, char** json_result) {
347347
status_t ret = SC_OK;
348348

349-
ret = ta_get_iri_status(service);
349+
ret = ta_get_node_status(service);
350350
switch (ret) {
351351
/*
352352
* The values of each status_t are listed as the following. Not listed status code are unexpected errors which
353353
* would cause TA return error.
354354
*
355-
* SC_CCLIENT_FAILED_RESPONSE: Can't connect to IRI host
356-
* SC_CORE_IRI_UNSYNC: IRI host is not at the latest milestone
357-
* SC_OK: IRI host works fine.
355+
* SC_CCLIENT_FAILED_RESPONSE: Can't connect to IOTA full node
356+
* SC_CORE_NODE_UNSYNC: IOTA full node is not at the latest milestone
357+
* SC_OK: IOTA full node works fine.
358358
**/
359359
case SC_CCLIENT_FAILED_RESPONSE:
360-
case SC_CORE_IRI_UNSYNC:
360+
case SC_CORE_NODE_UNSYNC:
361361
case SC_OK:
362-
ret = get_iri_status_res_serialize(ret, json_result);
362+
ret = get_node_status_res_serialize(ret, json_result);
363363
if (ret) {
364364
ta_log_error("failed to serialize. status code: %d\n", ret);
365365
}
366366
break;
367367

368368
default:
369-
ta_log_error("check IRI connection failed. status code: %d\n", ret);
369+
ta_log_error("check IOTA full node connection failed. status code: %d\n", ret);
370370
break;
371371
}
372372

accelerator/core/apis.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ int apis_logger_release();
4646
* @param info[in] Tangle-accelerator configuration variables
4747
* @param tangle[in] iota configuration variables
4848
* @param cache[in] redis configuration variables
49-
* @param service[in] IRI connection configuration variables
49+
* @param service[in] IOTA full node connection configuration variables
5050
* @param json_result[out] Result containing tangle accelerator information in json format
5151
*
5252
* @return
@@ -204,7 +204,7 @@ status_t api_send_trytes(const ta_config_t* const info, const iota_config_t* con
204204
const iota_client_service_t* const service, const char* const obj, char** json_result);
205205

206206
/**
207-
* @brief Check the connection status between tangle-accelerator and IRI host.
207+
* @brief Check the connection status between tangle-accelerator and IOTA full node.
208208
*
209209
* @param[in] iota_service IOTA node service
210210
* @param[out] json_result Result containing the current connection status.
@@ -213,7 +213,7 @@ status_t api_send_trytes(const ta_config_t* const info, const iota_config_t* con
213213
* - SC_OK on success
214214
* - non-zero on error
215215
*/
216-
status_t api_get_iri_status(const iota_client_service_t* const service, char** json_result);
216+
status_t api_get_node_status(const iota_client_service_t* const service, char** json_result);
217217

218218
/**
219219
* @brief Fetch transaction information with UUID.

accelerator/core/core.c

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -499,62 +499,61 @@ status_t ta_get_bundles_by_addr(const iota_client_service_t* const service, tryt
499499
return ret;
500500
}
501501

502-
status_t ta_get_iri_status(const iota_client_service_t* const service) {
502+
status_t ta_get_node_status(const iota_client_service_t* const service) {
503503
status_t ret = SC_OK;
504504
char const* const getnodeinfo = "{\"command\": \"getNodeInfo\"}";
505-
char* iri_result = NULL;
505+
char* node_result = NULL;
506506
char_buffer_t* res_buff = char_buffer_new();
507507
char_buffer_t* req_buff = char_buffer_new();
508508
char_buffer_set(req_buff, getnodeinfo);
509509

510-
// Check IRI host connection
510+
// Check IOTA full node connection
511511
retcode_t result = iota_service_query(service, req_buff, res_buff);
512512
if (result != RC_OK) {
513513
ta_log_error("%s\n", error_2_string(result));
514514
ret = SC_CCLIENT_FAILED_RESPONSE;
515515
goto done;
516516
}
517-
str_from_char_buffer(res_buff, &iri_result);
517+
str_from_char_buffer(res_buff, &node_result);
518518

519-
// Check whether IRI host is at the latest milestone
519+
// Check whether IOTA full node is at the latest milestone
520520
int latestMilestoneIndex, latestSolidSubtangleMilestoneIndex;
521-
ret = get_iri_status_milestone_deserialize(iri_result, &latestMilestoneIndex, &latestSolidSubtangleMilestoneIndex);
521+
ret = get_node_status_milestone_deserialize(node_result, &latestMilestoneIndex, &latestSolidSubtangleMilestoneIndex);
522522
if (ret != SC_OK) {
523523
ta_log_error("check iri connection failed deserialized. status code: %d\n", ret);
524524
goto done;
525525
}
526526

527527
// The tolerant difference between latestSolidSubtangleMilestoneIndex and latestMilestoneIndex is less equal than 1.
528528
if ((latestSolidSubtangleMilestoneIndex - latestMilestoneIndex) > 1) {
529-
ret = SC_CORE_IRI_UNSYNC;
529+
ret = SC_CORE_NODE_UNSYNC;
530530
ta_log_error("%s\n", ta_error_to_string(ret));
531531
}
532532

533533
done:
534-
free(iri_result);
534+
free(node_result);
535535
char_buffer_free(req_buff);
536536
char_buffer_free(res_buff);
537537

538538
return ret;
539539
}
540540

541-
status_t ta_update_iri_connection(ta_config_t* const ta_conf, iota_client_service_t* const service) {
541+
status_t ta_update_node_connection(ta_config_t* const ta_conf, iota_client_service_t* const service) {
542542
status_t ret = SC_OK;
543-
for (int i = 0; i < MAX_IRI_LIST_ELEMENTS && ta_conf->iota_host_list[i]; i++) {
544-
// update new IRI host
545-
543+
for (int i = 0; i < MAX_NODE_LIST_ELEMENTS && ta_conf->iota_host_list[i]; i++) {
544+
// update new IOTA full node
546545
strncpy(service->http.host, ta_conf->iota_host_list[i], HOST_MAX_LEN);
547546
service->http.port = ta_conf->iota_port_list[i];
548547
ta_log_info("Try to connect to %s:%d\n", service->http.host, service->http.port);
549548

550549
// Run from the first one until found a good one.
551-
if (ta_get_iri_status(service) == SC_OK) {
550+
if (ta_get_node_status(service) == SC_OK) {
552551
ta_log_info("Connect to %s:%d\n", service->http.host, service->http.port);
553552
goto done;
554553
}
555554
}
556555
if (ret) {
557-
ta_log_error("All IRI host on priority list failed.\n");
556+
ta_log_error("All IOTA full node on priority list failed.\n");
558557
}
559558

560559
done:

0 commit comments

Comments
 (0)