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

Commit

Permalink
fix: Rename ta_send_mam obj for consistency
Browse files Browse the repository at this point in the history
Other TA object all have `ta` prefix, so `send_mam` objects
are renamed to `ta_send_mam` object.
  • Loading branch information
howjmay committed Jun 5, 2019
1 parent 25e8626 commit 8eca774
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 42 deletions.
4 changes: 2 additions & 2 deletions accelerator/apis.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ status_t api_mam_send_message(const iota_config_t* const tangle,
bundle_transactions_new(&bundle);
tryte_t channel_id[MAM_CHANNEL_ID_SIZE];
trit_t msg_id[MAM_MSG_ID_SIZE];
send_mam_req_t* req = send_mam_req_new();
send_mam_res_t* res = send_mam_res_new();
ta_send_mam_req_t* req = send_mam_req_new();
ta_send_mam_res_t* res = send_mam_res_new();

// Loading and creating MAM API
if ((rc = mam_api_load(tangle->mam_file, &mam)) ==
Expand Down
8 changes: 4 additions & 4 deletions request/ta_send_mam.c
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#include "ta_send_mam.h"

send_mam_req_t* send_mam_req_new() {
send_mam_req_t* req = (send_mam_req_t*)malloc(sizeof(send_mam_req_t));
ta_send_mam_req_t* send_mam_req_new() {
ta_send_mam_req_t* req = (ta_send_mam_req_t*)malloc(sizeof(ta_send_mam_req_t));
if (req) {
req->payload_trytes = NULL;
}

return req;
}

status_t send_mam_req_set_payload(send_mam_req_t* req, const tryte_t* payload) {
status_t send_mam_req_set_payload(ta_send_mam_req_t* req, const tryte_t* payload) {
status_t ret = SC_OK;
size_t payload_size = sizeof(payload) / sizeof(tryte_t);

Expand All @@ -27,7 +27,7 @@ status_t send_mam_req_set_payload(send_mam_req_t* req, const tryte_t* payload) {
return ret;
}

void send_mam_req_free(send_mam_req_t** req) {
void send_mam_req_free(ta_send_mam_req_t** req) {
if (!req || !(*req)) {
return;
}
Expand Down
8 changes: 4 additions & 4 deletions request/ta_send_mam.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ extern "C" {
typedef struct send_mam_req_s {
tryte_t* payload_trytes;
size_t payload_trytes_size;
} send_mam_req_t;
} ta_send_mam_req_t;

send_mam_req_t* send_mam_req_new();
status_t send_mam_req_set_payload(send_mam_req_t* req, const tryte_t* payload);
void send_mam_req_free(send_mam_req_t** req);
ta_send_mam_req_t* send_mam_req_new();
status_t send_mam_req_set_payload(ta_send_mam_req_t* req, const tryte_t* payload);
void send_mam_req_free(ta_send_mam_req_t** req);

#ifdef __cplusplus
}
Expand Down
10 changes: 5 additions & 5 deletions response/ta_send_mam.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#include "ta_send_mam.h"

send_mam_res_t* send_mam_res_new() {
send_mam_res_t* res = (send_mam_res_t*)malloc(sizeof(send_mam_res_t));
ta_send_mam_res_t* send_mam_res_new() {
ta_send_mam_res_t* res = (ta_send_mam_res_t*)malloc(sizeof(ta_send_mam_res_t));

return res;
}

status_t send_mam_res_set_bundle_hash(send_mam_res_t* res,
status_t send_mam_res_set_bundle_hash(ta_send_mam_res_t* res,
const tryte_t* bundle_hash) {
if (!bundle_hash || !res) {
return SC_RES_NULL;
Expand All @@ -17,7 +17,7 @@ status_t send_mam_res_set_bundle_hash(send_mam_res_t* res,
return SC_OK;
}

status_t send_mam_res_set_channel_id(send_mam_res_t* res,
status_t send_mam_res_set_channel_id(ta_send_mam_res_t* res,
const tryte_t* channel_id) {
if (!channel_id || !res) {
return SC_RES_NULL;
Expand All @@ -28,7 +28,7 @@ status_t send_mam_res_set_channel_id(send_mam_res_t* res,
return SC_OK;
}

void send_mam_res_free(send_mam_res_t** res) {
void send_mam_res_free(ta_send_mam_res_t** res) {
if (!res || !(*res)) {
return;
}
Expand Down
22 changes: 11 additions & 11 deletions response/ta_send_mam.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ typedef struct send_mam_res_s {
char bundle_hash[NUM_TRYTES_HASH + 1];
/** ascii string channel id */
char channel_id[NUM_TRYTES_HASH + 1];
} send_mam_res_t;
} ta_send_mam_res_t;

/**
* Allocate memory of send_mam_res_t
* Allocate memory of ta_send_mam_res_t
*
* @return
* - struct of send_mam_res_t on success
* - struct of ta_send_mam_res_t on success
* - NULL on error
*/
send_mam_res_t* send_mam_res_new();
ta_send_mam_res_t* send_mam_res_new();

/**
* @brief Set the bundle_hash field of send_mam_res object.
Expand All @@ -36,14 +36,14 @@ send_mam_res_t* send_mam_res_new();
* and convert (instead of decoding) the received bundle hash to ascii string.
* After conversion, set the bundle_hash field of send_mam_res object.
*
* @param[in] res send_mam_res_t struct object
* @param[in] res ta_send_mam_res_t struct object
* @param[in] bundle_hash bundle hash decoded in trytes string
*
* @return
* - SC_OK on success
* - non-zero on error
*/
status_t send_mam_res_set_bundle_hash(send_mam_res_t* res,
status_t send_mam_res_set_bundle_hash(ta_send_mam_res_t* res,
const tryte_t* bundle_hash);

/**
Expand All @@ -53,24 +53,24 @@ status_t send_mam_res_set_bundle_hash(send_mam_res_t* res,
* and convert (instead of decoding) the received channel id to ascii string.
* After conversion, set the channel_id field of send_mam_res object.
*
* @param[in] res send_mam_res_t struct object
* @param[in] res ta_send_mam_res_t struct object
* @param[in] channel_id channel id decoded in trytes string
*
* @return
* - SC_OK on success
* - non-zero on error
*/
status_t send_mam_res_set_channel_id(send_mam_res_t* res,
status_t send_mam_res_set_channel_id(ta_send_mam_res_t* res,
const tryte_t* channel_id);

/**
* Free memory of send_mam_res_t
* Free memory of ta_send_mam_res_t
*
* @param req Data type of send_mam_res_t
* @param req Data type of ta_send_mam_res_t
*
* @return NULL
*/
void send_mam_res_free(send_mam_res_t** res);
void send_mam_res_free(ta_send_mam_res_t** res);

#ifdef __cplusplus
}
Expand Down
6 changes: 3 additions & 3 deletions serializer/serializer.c
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ status_t receive_mam_message_serialize(char** obj, char** const res) {
return ret;
}

status_t send_mam_res_serialize(char** obj, const send_mam_res_t* const res) {
status_t send_mam_res_serialize(char** obj, const ta_send_mam_res_t* const res) {
status_t ret = SC_OK;
cJSON* json_root = cJSON_CreateObject();
if (json_root == NULL) {
Expand All @@ -580,7 +580,7 @@ status_t send_mam_res_serialize(char** obj, const send_mam_res_t* const res) {
}

status_t send_mam_res_deserialize(const char* const obj,
send_mam_res_t* const res) {
ta_send_mam_res_t* const res) {
if (obj == NULL) {
return SC_SERIALIZER_NULL;
}
Expand Down Expand Up @@ -610,7 +610,7 @@ status_t send_mam_res_deserialize(const char* const obj,
return ret;
}

status_t send_mam_req_deserialize(const char* const obj, send_mam_req_t* req) {
status_t send_mam_req_deserialize(const char* const obj, ta_send_mam_req_t* req) {
if (obj == NULL) {
return SC_SERIALIZER_NULL;
}
Expand Down
18 changes: 9 additions & 9 deletions serializer/serializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,41 +153,41 @@ status_t ta_find_transactions_obj_res_serialize(
status_t receive_mam_message_serialize(char** obj, char** const res);

/**
* @brief Serialze type of send_mam_res_t to JSON string
* @brief Serialze type of ta_send_mam_res_t to JSON string
*
* @param[out] obj send mam response object in JSON
* @param[in] res Response data in type of send_mam_res_t
* @param[in] res Response data in type of ta_send_mam_res_t
*
* @return
* - SC_OK on success
* - non-zero on error
*/
status_t send_mam_res_serialize(char** obj, const send_mam_res_t* const res);
status_t send_mam_res_serialize(char** obj, const ta_send_mam_res_t* const res);

/**
* @brief Deserialze JSON string to type of send_mam_res_t
* @brief Deserialze JSON string to type of ta_send_mam_res_t
*
* @param[in] obj Input values in JSON
* @param[out] res Response data in type of send_mam_res_t
* @param[out] res Response data in type of ta_send_mam_res_t
*
* @return
* - SC_OK on success
* - non-zero on error
*/
status_t send_mam_res_deserialize(const char* const obj,
send_mam_res_t* const res);
ta_send_mam_res_t* const res);

/**
* @brief Deserialze JSON string to type of send_mam_req_t
* @brief Deserialze JSON string to type of ta_send_mam_req_t
*
* @param[in] obj Input values in JSON
* @param[out] req Request data in type of send_mam_req_t
* @param[out] req Request data in type of ta_send_mam_req_t
*
* @return
* - SC_OK on success
* - non-zero on error
*/
status_t send_mam_req_deserialize(const char* const obj, send_mam_req_t* req);
status_t send_mam_req_deserialize(const char* const obj, ta_send_mam_req_t* req);
#ifdef __cplusplus
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion tests/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ static ta_core_t ta_core;
struct timespec start_time, end_time;

char driver_tag_msg[NUM_TRYTES_TAG];
send_mam_res_t* res;
ta_send_mam_res_t* res;

#if defined(ENABLE_STAT)
#define TEST_COUNT 100
Expand Down
6 changes: 3 additions & 3 deletions tests/test_serializer.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ void test_serialize_send_mam_message(void) {
"\","
"\"bundle_hash\":\"" TRYTES_81_2 "\"}";
char* json_result;
send_mam_res_t* res = send_mam_res_new();
ta_send_mam_res_t* res = send_mam_res_new();

send_mam_res_set_bundle_hash(res, (tryte_t*)TRYTES_81_2);
send_mam_res_set_channel_id(res, (tryte_t*)TRYTES_81_1);
Expand All @@ -274,7 +274,7 @@ void test_deserialize_send_mam_message_response(void) {
const char* json = "{\"channel\":\"" TRYTES_81_1
"\","
"\"bundle_hash\":\"" TRYTES_81_2 "\"}";
send_mam_res_t* res = send_mam_res_new();
ta_send_mam_res_t* res = send_mam_res_new();

send_mam_res_deserialize(json, res);

Expand All @@ -286,7 +286,7 @@ void test_deserialize_send_mam_message_response(void) {

void test_deserialize_send_mam_message(void) {
const char* json = "{\"message\":\"" TEST_PAYLOAD "\"}";
send_mam_req_t* req = send_mam_req_new();
ta_send_mam_req_t* req = send_mam_req_new();

send_mam_req_deserialize(json, req);

Expand Down

0 comments on commit 8eca774

Please sign in to comment.