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

Commit f21b69c

Browse files
committed
Merge branch 'develop'
2 parents 00f173d + dc2180d commit f21b69c

34 files changed

+363
-1226
lines changed

.travis.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
dist: bionic
2+
13
env:
24
global:
35
# The next declaration is the encrypted COVERITY_SCAN_TOKEN, created
@@ -14,6 +16,15 @@ before_install:
1416
- echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
1517
# Install and update Bazel
1618
- sudo apt update && sudo apt install bazel
19+
# Install UUID library
20+
- sudo apt install uuid-dev
21+
# Install Cassandra C client library
22+
- wget https://downloads.datastax.com/cpp-driver/ubuntu/18.04/dependencies/libuv/v1.35.0/libuv1_1.35.0-1_amd64.deb
23+
- sudo dpkg -i libuv1_1.35.0-1_amd64.deb
24+
- wget https://downloads.datastax.com/cpp-driver/ubuntu/18.04/cassandra/v2.15.1/cassandra-cpp-driver_2.15.1-1_amd64.deb
25+
- sudo dpkg -i cassandra-cpp-driver_2.15.1-1_amd64.deb
26+
- wget https://downloads.datastax.com/cpp-driver/ubuntu/18.04/cassandra/v2.15.1/cassandra-cpp-driver-dev_2.15.1-1_amd64.deb
27+
- sudo dpkg -i cassandra-cpp-driver-dev_2.15.1-1_amd64.deb
1728

1829
addons:
1930
coverity_scan:
@@ -25,4 +36,4 @@ addons:
2536
build_command: "bash tests/coverity_analysis.sh"
2637
branch_pattern: develop
2738

28-
script: if [ "${COVERITY_SCAN_BRANCH}" != 1 ]; then make ; fi
39+
script: if [ "${COVERITY_SCAN_BRANCH}" != 1 ]; then bash -e tests/coverity_analysis.sh; fi

Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
DCURL_DIR := third_party/dcurl
22
DCURL_LIB := $(DCURL_DIR)/build/libdcurl.so
3-
MOSQITTO_DIR := third_party/mosquitto
4-
MOSQITTO_LIB := $(MOSQITTO_DIR)/lib/libmosquitto.so.1
3+
MOSQUITTO_DIR := third_party/mosquitto
4+
MOSQUITTO_LIB := $(MOSQUITTO_DIR)/lib/libmosquitto.so.1
55
DEPS += $(DCURL_LIB)
66

77
all: $(DEPS)
88

9-
.PHONY: $(DCURL_LIB) $(MOSQITTO_LIB)
9+
.PHONY: $(DCURL_LIB) $(MOSQUITTO_LIB)
1010

1111
$(DCURL_LIB): $(DCURL_DIR)
1212
git submodule update --init $^
@@ -15,15 +15,15 @@ $(DCURL_LIB): $(DCURL_DIR)
1515
$(info Modify $^/build/local.mk for your environments.)
1616
$(MAKE) -C $^ all
1717

18-
MQTT: $(DCURL_LIB) $(MOSQITTO_LIB)
19-
$(MOSQITTO_LIB): $(MOSQITTO_DIR)
18+
MQTT: $(DCURL_LIB) $(MOSQUITTO_LIB)
19+
$(MOSQUITTO_LIB): $(MOSQUITTO_DIR)
2020
git submodule update --init $^
2121
@echo
2222
$(MAKE) -C $^ WITH_DOCS=no
2323

2424
clean:
2525
$(MAKE) -C $(DCURL_DIR) clean
26-
$(MAKE) -C $(MOSQITTO_DIR) clean
26+
$(MAKE) -C $(MOSQUITTO_DIR) clean
2727

2828
distclean: clean
2929
$(RM) -r $(DCURL_DIR)

WORKSPACE

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ load("@io_bazel_rules_docker//repositories:repositories.bzl", container_reposito
3131
container_repositories()
3232

3333
load("@io_bazel_rules_docker//cc:image.bzl", _cc_image_repos = "repositories")
34-
3534
load("@io_bazel_rules_docker//container:pull.bzl", "container_pull")
3635

3736
container_pull(

accelerator/cli_info.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#define ACCELERATOR_CLI_INFO_H_
1111

1212
#include <stdio.h>
13+
#include "common/macros.h"
1314

1415
#ifdef __cplusplus
1516
extern "C" {
@@ -50,6 +51,7 @@ typedef enum ta_cli_arg_value_e {
5051
CONF_CLI,
5152
PROXY_API,
5253
HEALTH_TRACK_PERIOD,
54+
NO_GTTA,
5355

5456
/** LOGGER */
5557
QUIET,
@@ -83,10 +85,11 @@ static struct ta_cli_argument_s {
8385
{"proxy_passthrough", no_argument, NULL, PROXY_API, "Pass proxy API directly to IRI without processing"},
8486
{"health_track_period", no_argument, NULL, HEALTH_TRACK_PERIOD,
8587
"The period for checking IRI host connection status"},
88+
{"no-gtta", no_argument, NULL, NO_GTTA, "Disable getTransactionToConfirm (gTTA) when sending transacation"},
8689
{"quiet", no_argument, NULL, QUIET, "Disable logger"},
8790
{NULL, 0, NULL, 0, NULL}};
8891

89-
static const int cli_cmd_num = sizeof(ta_cli_arguments_g) / sizeof(struct ta_cli_argument_s);
92+
static const int cli_cmd_num = ARRAY_SIZE(ta_cli_arguments_g);
9093

9194
static inline void ta_usage() {
9295
printf("tangle-accelerator usage:\n");

accelerator/config.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static int get_conf_key(char const* const key) {
3838
}
3939

4040
status_t cli_core_set(ta_core_t* const core, int key, char* const value) {
41-
if (value == NULL && (key != CACHE && key != PROXY_API && key != QUIET)) {
41+
if (value == NULL && (key != CACHE && key != PROXY_API && key != QUIET && key != NO_GTTA)) {
4242
ta_log_error("%s\n", "SC_CONF_NULL");
4343
return SC_CONF_NULL;
4444
}
@@ -186,10 +186,12 @@ status_t cli_core_set(ta_core_t* const core, int key, char* const value) {
186186
case QUIET:
187187
quiet_mode = true;
188188
break;
189-
190189
case PROXY_API:
191190
ta_conf->proxy_passthrough = true;
192191
break;
192+
case NO_GTTA:
193+
ta_conf->gtta = false;
194+
break;
193195

194196
// File configuration
195197
case CONF_CLI: {
@@ -225,6 +227,7 @@ status_t ta_core_default_init(ta_core_t* const core) {
225227
ta_conf->thread_count = TA_THREAD_COUNT;
226228
ta_conf->proxy_passthrough = false;
227229
ta_conf->health_track_period = IRI_HEALTH_TRACK_PERIOD;
230+
ta_conf->gtta = true;
228231
#ifdef MQTT_ENABLE
229232
ta_conf->mqtt_host = MQTT_HOST;
230233
ta_conf->mqtt_topic_root = TOPIC_ROOT;

accelerator/config.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ extern "C" {
3333
* @brief Configuration of tangle-accelerator
3434
*/
3535

36-
#define TA_VERSION "tangle-accelerator/0.9.1"
36+
#define TA_VERSION "tangle-accelerator/0.9.2"
3737
#define TA_HOST "localhost"
3838

3939
#ifdef MQTT_ENABLE
@@ -68,29 +68,29 @@ typedef struct ta_config_s {
6868
int port; /**< Binding port of tangle-accelerator */
6969
char* host_list[MAX_IRI_LIST_ELEMENTS]; /**< List of binding host of tangle-accelerator */
7070
int port_list[MAX_IRI_LIST_ELEMENTS]; /**< List of binding port of tangle-accelerator */
71-
uint8_t thread_count; /**< Thread count of tangle-accelerator instance */
71+
int health_track_period; /**< The period for checking IRI host connection status */
7272
#ifdef MQTT_ENABLE
7373
char* mqtt_host; /**< Address of MQTT broker host */
7474
char* mqtt_topic_root; /**< The topic root of MQTT topic */
7575
#endif
76-
bool proxy_passthrough; /**< Pass proxy api directly without processing */
77-
int health_track_period; /**< The period for checking IRI host connection status */
76+
uint8_t thread_count; /**< Thread count of tangle-accelerator instance */
77+
bool proxy_passthrough; /**< Pass proxy api directly without processing */
78+
bool gtta; /**< The option to turn on or off GTTA. The default value is true which enabling GTTA */
7879
} ta_config_t;
7980

8081
/** struct type of iota configuration */
8182
typedef struct iota_config_s {
82-
uint8_t milestone_depth; /**< Depth of API argument */
83-
uint8_t mwm; /**< Minimum weight magnitude of API argument */
84-
/** Seed to generate address. This does not do any signature yet. */
85-
const char* seed;
83+
uint8_t milestone_depth; /**< Depth of API argument */
84+
uint8_t mwm; /**< Minimum weight magnitude of API argument */
85+
const char* seed; /**< Seed to generate address. This does not do any signature yet. */
8686
const char* mam_file_path; /**< The MAM file which records the mam config */
8787
} iota_config_t;
8888

8989
/** struct type of accelerator cache */
9090
typedef struct ta_cache_s {
91-
bool cache_state; /** set it true to turn on cache server */
9291
char* host; /**< Binding address of redis server */
9392
uint16_t port; /**< Binding port of redis server */
93+
bool cache_state; /**< Set it true to turn on cache server */
9494
} ta_cache_t;
9595

9696
/** struct type of accelerator core */

accelerator/core/apis.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,9 @@ status_t api_recv_mam_message(const iota_config_t* const iconf, const iota_clien
401401
return ret;
402402
}
403403

404-
status_t api_mam_send_message(const iota_config_t* const iconf, const iota_client_service_t* const service,
405-
char const* const payload, char** json_result) {
404+
status_t api_mam_send_message(const ta_config_t* const info, const iota_config_t* const iconf,
405+
const iota_client_service_t* const service, char const* const payload,
406+
char** json_result) {
406407
status_t ret = SC_OK;
407408
mam_api_t mam;
408409
tryte_t chid[MAM_CHANNEL_ID_TRYTE_SIZE] = {}, epid[MAM_CHANNEL_ID_TRYTE_SIZE] = {},
@@ -445,7 +446,7 @@ status_t api_mam_send_message(const iota_config_t* const iconf, const iota_clien
445446

446447
// Sending bundle
447448
lock_handle_lock(&cjson_lock);
448-
if (ta_send_bundle(iconf, service, bundle) != SC_OK) {
449+
if (ta_send_bundle(info, iconf, service, bundle) != SC_OK) {
449450
lock_handle_unlock(&cjson_lock);
450451
ret = SC_MAM_FAILED_RESPONSE;
451452
ta_log_error("%s\n", "SC_MAM_FAILED_RESPONSE");
@@ -488,7 +489,7 @@ status_t api_mam_send_message(const iota_config_t* const iconf, const iota_clien
488489
}
489490

490491
lock_handle_lock(&cjson_lock);
491-
if (ta_send_bundle(iconf, service, bundle) != SC_OK) {
492+
if (ta_send_bundle(info, iconf, service, bundle) != SC_OK) {
492493
lock_handle_unlock(&cjson_lock);
493494
ret = SC_MAM_FAILED_RESPONSE;
494495
ta_log_error("%s\n", "SC_MAM_FAILED_RESPONSE");
@@ -557,7 +558,7 @@ status_t api_send_transfer(const ta_core_t* const core, const char* const obj, c
557558
goto done;
558559
}
559560

560-
ret = ta_send_transfer(&core->iota_conf, &core->iota_service, req, res);
561+
ret = ta_send_transfer(&core->ta_conf, &core->iota_conf, &core->iota_service, req, res);
561562
if (ret == SC_CCLIENT_FAILED_RESPONSE) {
562563
lock_handle_unlock(&cjson_lock);
563564
ta_log_info("%s\n", "Caching transaction");
@@ -624,8 +625,8 @@ status_t api_send_transfer(const ta_core_t* const core, const char* const obj, c
624625
return ret;
625626
}
626627

627-
status_t api_send_trytes(const iota_config_t* const iconf, const iota_client_service_t* const service,
628-
const char* const obj, char** json_result) {
628+
status_t api_send_trytes(const ta_config_t* const info, const iota_config_t* const iconf,
629+
const iota_client_service_t* const service, const char* const obj, char** json_result) {
629630
status_t ret = SC_OK;
630631
hash8019_array_p trytes = hash8019_array_new();
631632

@@ -642,7 +643,7 @@ status_t api_send_trytes(const iota_config_t* const iconf, const iota_client_ser
642643
goto done;
643644
}
644645

645-
ret = ta_send_trytes(iconf, service, trytes);
646+
ret = ta_send_trytes(info, iconf, service, trytes);
646647
if (ret != SC_OK) {
647648
lock_handle_unlock(&cjson_lock);
648649
goto done;

accelerator/core/apis.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ status_t api_recv_mam_message(const iota_config_t* const iconf, const iota_clien
153153
* There is no need to decode the ascii payload to tryte, since the
154154
* api_mam_send_message() will take this job.
155155
*
156+
* @param[in] info Tangle-accelerator configuration variables
156157
* @param[in] iconf IOTA API parameter configurations
157158
* @param[in] service IRI node end point service
158159
* @param[in] payload message to send undecoded ascii string.
@@ -162,8 +163,9 @@ status_t api_recv_mam_message(const iota_config_t* const iconf, const iota_clien
162163
* - SC_OK on success
163164
* - non-zero on error
164165
*/
165-
status_t api_mam_send_message(const iota_config_t* const iconf, const iota_client_service_t* const service,
166-
char const* const payload, char** json_result);
166+
status_t api_mam_send_message(const ta_config_t* const info, const iota_config_t* const iconf,
167+
const iota_client_service_t* const service, char const* const payload,
168+
char** json_result);
167169

168170
/**
169171
* @brief Send transfer to tangle.
@@ -259,6 +261,7 @@ status_t api_find_transactions_obj_by_tag(const iota_client_service_t* const ser
259261
* This allows for reattachments and prevents key reuse if trytes can't
260262
* be recovered by querying the network after broadcasting.
261263
*
264+
* @param[in] info Tangle-accelerator configuration variables
262265
* @param[in] iconf IOTA API parameter configurations
263266
* @param[in] service IRI node end point service
264267
* @param[in] obj trytes to attach, store and broadcast in json array
@@ -269,8 +272,8 @@ status_t api_find_transactions_obj_by_tag(const iota_client_service_t* const ser
269272
* - SC_OK on success
270273
* - non-zero on error
271274
*/
272-
status_t api_send_trytes(const iota_config_t* const iconf, const iota_client_service_t* const service,
273-
const char* const obj, char** json_result);
275+
status_t api_send_trytes(const ta_config_t* const info, const iota_config_t* const iconf,
276+
const iota_client_service_t* const service, const char* const obj, char** json_result);
274277

275278
/**
276279
* @brief Check the connection status between tangle-accelerator and IRI host.

accelerator/core/core.c

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ status_t ta_attach_to_tangle(const attach_to_tangle_req_t* const req, attach_to_
6565
return ret;
6666
}
6767

68-
status_t ta_send_trytes(const iota_config_t* const iconf, const iota_client_service_t* const service,
69-
hash8019_array_p trytes) {
68+
status_t ta_send_trytes(const ta_config_t* const info, const iota_config_t* const iconf,
69+
const iota_client_service_t* const service, hash8019_array_p trytes) {
7070
status_t ret = SC_OK;
7171
get_transactions_to_approve_req_t* tx_approve_req = get_transactions_to_approve_req_new();
7272
get_transactions_to_approve_res_t* tx_approve_res = get_transactions_to_approve_res_new();
@@ -77,12 +77,13 @@ status_t ta_send_trytes(const iota_config_t* const iconf, const iota_client_serv
7777
ta_log_error("%s\n", "SC_CCLIENT_OOM");
7878
goto done;
7979
}
80-
81-
get_transactions_to_approve_req_set_depth(tx_approve_req, iconf->milestone_depth);
82-
if (iota_client_get_transactions_to_approve(service, tx_approve_req, tx_approve_res)) {
83-
ret = SC_CCLIENT_FAILED_RESPONSE;
84-
ta_log_error("%s\n", "SC_CCLIENT_FAILED_RESPONSE");
85-
goto done;
80+
if (info->gtta) {
81+
get_transactions_to_approve_req_set_depth(tx_approve_req, iconf->milestone_depth);
82+
if (iota_client_get_transactions_to_approve(service, tx_approve_req, tx_approve_res)) {
83+
ret = SC_CCLIENT_FAILED_RESPONSE;
84+
ta_log_error("%s\n", "SC_CCLIENT_FAILED_RESPONSE");
85+
goto done;
86+
}
8687
}
8788

8889
// copy trytes to attach_req->trytes
@@ -161,8 +162,9 @@ status_t ta_generate_address(const iota_config_t* const iconf, const iota_client
161162
return (status_t)rval;
162163
}
163164

164-
status_t ta_send_transfer(const iota_config_t* const iconf, const iota_client_service_t* const service,
165-
const ta_send_transfer_req_t* const req, ta_send_transfer_res_t* res) {
165+
status_t ta_send_transfer(const ta_config_t* const info, const iota_config_t* const iconf,
166+
const iota_client_service_t* const service, const ta_send_transfer_req_t* const req,
167+
ta_send_transfer_res_t* res) {
166168
if (req == NULL || res == NULL) {
167169
ta_log_error("%s\n", "SC_TA_NULL");
168170
return SC_TA_NULL;
@@ -221,7 +223,7 @@ status_t ta_send_transfer(const iota_config_t* const iconf, const iota_client_se
221223
free(serialized_txn);
222224
}
223225

224-
ret = ta_send_trytes(iconf, service, raw_tx);
226+
ret = ta_send_trytes(info, iconf, service, raw_tx);
225227
if (ret) {
226228
goto done;
227229
}
@@ -435,8 +437,8 @@ status_t ta_get_bundle(const iota_client_service_t* const service, tryte_t const
435437
return ret;
436438
}
437439

438-
status_t ta_send_bundle(const iota_config_t* const iconf, const iota_client_service_t* const service,
439-
bundle_transactions_t* const bundle) {
440+
status_t ta_send_bundle(const ta_config_t* const info, const iota_config_t* const iconf,
441+
const iota_client_service_t* const service, bundle_transactions_t* const bundle) {
440442
Kerl kerl;
441443
kerl_init(&kerl);
442444
bundle_finalize(bundle, &kerl);
@@ -450,7 +452,7 @@ status_t ta_send_bundle(const iota_config_t* const iconf, const iota_client_serv
450452
hash_array_push(raw_trytes, trits_8019);
451453
}
452454

453-
ta_send_trytes(iconf, service, raw_trytes);
455+
ta_send_trytes(info, iconf, service, raw_trytes);
454456

455457
hash_array_free(raw_trytes);
456458
transaction_array_free(out_tx_objs);

0 commit comments

Comments
 (0)