Skip to content

Commit cd1bf53

Browse files
authored
Format annotation (#333)
1 parent ca7e1d5 commit cd1bf53

File tree

23 files changed

+209
-73
lines changed

23 files changed

+209
-73
lines changed

src/app/chain/Chain.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ Chain::~Chain()
5151

5252
/**
5353
* @description: get laster block header from chain
54+
* @param block_header -> Reference to block_header
5455
* @return: the point of block header
5556
*/
5657
bool Chain::get_block_header(BlockHeader &block_header)

src/app/ecalls/ECalls.cpp

Lines changed: 73 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ EnclaveQueue *eq = EnclaveQueue::get_instance();
44

55
/**
66
* @description: A wrapper function, seal one G srd files under directory, can be called from multiple threads
7-
* @param path -> the directory path
7+
* @param eid -> Enclave id
8+
* @return: Invoking ecall return status
89
*/
910
sgx_status_t Ecall_srd_increase(sgx_enclave_id_t eid)
1011
{
@@ -23,8 +24,10 @@ sgx_status_t Ecall_srd_increase(sgx_enclave_id_t eid)
2324

2425
/**
2526
* @description: A wrapper function, decrease srd files under directory
26-
* @param path -> the directory path
27+
* @param eid -> Enclave id
28+
* @param size (out) -> Pointer to decreased srd size
2729
* @param change -> reduction
30+
* @return: Invoking ecall return status
2831
*/
2932
sgx_status_t Ecall_srd_decrease(sgx_enclave_id_t eid, size_t *size, size_t change)
3033
{
@@ -43,6 +46,8 @@ sgx_status_t Ecall_srd_decrease(sgx_enclave_id_t eid, size_t *size, size_t chang
4346

4447
/**
4548
* @description: A wrapper function, ecall main loop
49+
* @param eid -> Enclave id
50+
* @return: Invoking ecall return status
4651
*/
4752
sgx_status_t Ecall_main_loop(sgx_enclave_id_t eid)
4853
{
@@ -61,6 +66,8 @@ sgx_status_t Ecall_main_loop(sgx_enclave_id_t eid)
6166

6267
/**
6368
* @description: A wrapper function, ecall stop all
69+
* @param eid -> Enclave id
70+
* @return: Invoking ecall return status
6471
*/
6572
sgx_status_t Ecall_stop_all(sgx_enclave_id_t eid)
6673
{
@@ -79,7 +86,9 @@ sgx_status_t Ecall_stop_all(sgx_enclave_id_t eid)
7986

8087
/**
8188
* @description: A wrapper function, Restore enclave data from file
82-
* @param status -> Pointer to restore result status
89+
* @param eid -> Enclave id
90+
* @param status (out) -> Pointer to restore result status
91+
* @return: Invoking ecall return status
8392
*/
8493
sgx_status_t Ecall_restore_metadata(sgx_enclave_id_t eid, crust_status_t *status)
8594
{
@@ -98,9 +107,11 @@ sgx_status_t Ecall_restore_metadata(sgx_enclave_id_t eid, crust_status_t *status
98107

99108
/**
100109
* @description: A wrapper function, Compare chain account with enclave's
101-
* @param status -> Pointer to compare result status
110+
* @param eid -> Enclave id
111+
* @param status (out) -> Pointer to compare result status
102112
* @param account_id (in) -> Pointer to account id
103113
* @param len -> account id length
114+
* @return: Invoking ecall return status
104115
*/
105116
sgx_status_t Ecall_cmp_chain_account_id(sgx_enclave_id_t eid, crust_status_t *status, const char *account_id, size_t len)
106117
{
@@ -119,9 +130,11 @@ sgx_status_t Ecall_cmp_chain_account_id(sgx_enclave_id_t eid, crust_status_t *st
119130

120131
/**
121132
* @description: A wrapper function, Get signed validation report
122-
* @param status -> Pointer to get result status
133+
* @param eid -> Enclave id
134+
* @param status (out) -> Pointer to get result status
123135
* @param block_hash (in) -> block hash
124-
* @param block_height (in) -> block height
136+
* @param block_height -> block height
137+
* @return: Invoking ecall return status
125138
*/
126139
sgx_status_t Ecall_gen_and_upload_work_report(sgx_enclave_id_t eid, crust_status_t *status, const char *block_hash, size_t block_height)
127140
{
@@ -140,6 +153,11 @@ sgx_status_t Ecall_gen_and_upload_work_report(sgx_enclave_id_t eid, crust_status
140153

141154
/**
142155
* @description: A wrapper function, generate ecc key pair and store it in enclave
156+
* @param eid -> Enclave id
157+
* @param status (out) -> Pointer to result status
158+
* @param account_id (in) -> Pointer to account id
159+
* @param len -> Account id length
160+
* @return: Invoking ecall return status
143161
*/
144162
sgx_status_t Ecall_gen_key_pair(sgx_enclave_id_t eid, sgx_status_t *status, const char *account_id, size_t len)
145163
{
@@ -159,8 +177,11 @@ sgx_status_t Ecall_gen_key_pair(sgx_enclave_id_t eid, sgx_status_t *status, cons
159177
/**
160178
* @description: A wrapper function, get sgx report, our generated public key contained
161179
* in report data
180+
* @param eid -> Enclave id
181+
* @param status (out) -> Pointer to result status
162182
* @param report (out) -> Pointer to SGX report
163183
* @param target_info (in) -> Data used to generate report
184+
* @return: Invoking ecall return status
164185
*/
165186
sgx_status_t Ecall_get_quote_report(sgx_enclave_id_t eid, sgx_status_t *status, sgx_report_t *report, sgx_target_info_t *target_info)
166187
{
@@ -179,6 +200,9 @@ sgx_status_t Ecall_get_quote_report(sgx_enclave_id_t eid, sgx_status_t *status,
179200

180201
/**
181202
* @description: A wrapper function, generate current code measurement
203+
* @param eid -> Enclave id
204+
* @param status (out) -> Pointer to result status
205+
* @return: Invoking ecall return status
182206
*/
183207
sgx_status_t Ecall_gen_sgx_measurement(sgx_enclave_id_t eid, sgx_status_t *status)
184208
{
@@ -197,9 +221,11 @@ sgx_status_t Ecall_gen_sgx_measurement(sgx_enclave_id_t eid, sgx_status_t *statu
197221

198222
/**
199223
* @description: A wrapper function, verify IAS report
200-
* @param status -> Pointer to verify result status
224+
* @param eid -> Enclave id
225+
* @param status (out) -> Pointer to verify result status
201226
* @param IASReport (in) -> Vector first address
202227
* @param len -> Count of Vector IASReport
228+
* @return: Invoking ecall return status
203229
*/
204230
sgx_status_t Ecall_verify_and_upload_identity(sgx_enclave_id_t eid, crust_status_t *status, char **IASReport, size_t len)
205231
{
@@ -218,9 +244,10 @@ sgx_status_t Ecall_verify_and_upload_identity(sgx_enclave_id_t eid, crust_status
218244

219245
/**
220246
* @description: A wrapper function, Seal file according to given path and return new MerkleTree
221-
* @param status -> Pointer to seal result status
222-
* @param cid -> Ipfs content id
223-
* @param file_size -> Pointer to sealed file size
247+
* @param eid -> Enclave id
248+
* @param status (out) -> Pointer to seal result status
249+
* @param cid (in) -> Ipfs content id
250+
* @return: Invoking ecall return status
224251
*/
225252
sgx_status_t Ecall_seal_file(sgx_enclave_id_t eid, crust_status_t *status, const char *cid)
226253
{
@@ -239,12 +266,11 @@ sgx_status_t Ecall_seal_file(sgx_enclave_id_t eid, crust_status_t *status, const
239266

240267
/**
241268
* @description: A wrapper function, Unseal file according to given path
242-
* @param status -> Pointer to unseal result status
243-
* @param files (in) -> Files in root directory
244-
* @param files_num -> Files number in root directory
245-
* @param p_dir (in) -> Root directory path
246-
* @param p_new_path (out) -> Pointer to unsealed data path
247-
* @param path_len -> Root dir path length
269+
* @param eid -> Enclave id
270+
* @param status (out) -> Pointer to unseal result status
271+
* @param data (in) -> Pointer to sealed data
272+
* @param data_size -> Sealed data size
273+
* @return: Invoking ecall return status
248274
*/
249275
sgx_status_t Ecall_unseal_file(sgx_enclave_id_t eid, crust_status_t *status, const char *data, size_t data_size)
250276
{
@@ -263,7 +289,11 @@ sgx_status_t Ecall_unseal_file(sgx_enclave_id_t eid, crust_status_t *status, con
263289

264290
/**
265291
* @description: Change srd number
292+
* @param eid -> Enclave id
293+
* @param status (out) -> Pointer to result status
266294
* @param change -> Will be changed srd number
295+
* @param real_change (out) -> Pointer to real changed srd size
296+
* @return: Invoking ecall return status
267297
*/
268298
sgx_status_t Ecall_change_srd_task(sgx_enclave_id_t eid, crust_status_t *status, long change, long *real_change)
269299
{
@@ -282,8 +312,9 @@ sgx_status_t Ecall_change_srd_task(sgx_enclave_id_t eid, crust_status_t *status,
282312

283313
/**
284314
* @description: Update srd_g_hashs
285-
* @param hashs -> Pointer to the address of to be deleted hashs array
286-
* @param hashs_len -> Hashs array length
315+
* @param eid -> Enclave id
316+
* @param change -> To be deleted srd size
317+
* @return: Invoking ecall return status
287318
*/
288319
sgx_status_t Ecall_srd_remove_space(sgx_enclave_id_t eid, size_t change)
289320
{
@@ -302,8 +333,10 @@ sgx_status_t Ecall_srd_remove_space(sgx_enclave_id_t eid, size_t change)
302333

303334
/**
304335
* @description: Delete file
305-
* @param status -> Pointer to delete result status
306-
* @param hash -> File root hash
336+
* @param eid -> Enclave id
337+
* @param status (out) -> Pointer to delete result status
338+
* @param hash (in) -> File root hash
339+
* @return: Invoking ecall return status
307340
*/
308341
sgx_status_t Ecall_delete_file(sgx_enclave_id_t eid, crust_status_t *status, const char *hash)
309342
{
@@ -322,7 +355,10 @@ sgx_status_t Ecall_delete_file(sgx_enclave_id_t eid, crust_status_t *status, con
322355

323356
/**
324357
* @description: Generate upgrade metadata
325-
* @param status -> Pointer to generate result status
358+
* @param eid -> Enclave id
359+
* @param status (out) -> Pointer to generate result status
360+
* @param block_height -> Chain block height
361+
* @return: Invoking ecall return status
326362
*/
327363
sgx_status_t Ecall_gen_upgrade_data(sgx_enclave_id_t eid, crust_status_t *status, size_t block_height)
328364
{
@@ -341,7 +377,13 @@ sgx_status_t Ecall_gen_upgrade_data(sgx_enclave_id_t eid, crust_status_t *status
341377

342378
/**
343379
* @description: Generate upgrade metadata
344-
* @param status -> Pointer to metadata
380+
* @param eid -> Enclave id
381+
* @param status (out) -> Pointer to result status
382+
* @param meta (in) -> Pointer to metadata
383+
* @param meta_len -> Meta length
384+
* @param total_size -> Metadata total size
385+
* @param transfer_end -> Indicate transfer end or not
386+
* @return: Invoking ecall return status
345387
*/
346388
sgx_status_t Ecall_restore_from_upgrade(sgx_enclave_id_t eid, crust_status_t *status, const char *meta, size_t meta_len, size_t total_size, bool transfer_end)
347389
{
@@ -360,7 +402,10 @@ sgx_status_t Ecall_restore_from_upgrade(sgx_enclave_id_t eid, crust_status_t *st
360402

361403
/**
362404
* @description: Enable upgrade
405+
* @param eid -> Enclave id
406+
* @param status (out) -> Pointer to result status
363407
* @param block_height -> Current block height
408+
* @return: Invoking ecall return status
364409
*/
365410
sgx_status_t Ecall_enable_upgrade(sgx_enclave_id_t eid, crust_status_t *status, size_t block_height)
366411
{
@@ -379,6 +424,8 @@ sgx_status_t Ecall_enable_upgrade(sgx_enclave_id_t eid, crust_status_t *status,
379424

380425
/**
381426
* @description: Disable upgrade
427+
* @param eid -> Enclave id
428+
* @return: Invoking ecall return status
382429
*/
383430
sgx_status_t Ecall_disable_upgrade(sgx_enclave_id_t eid)
384431
{
@@ -397,6 +444,8 @@ sgx_status_t Ecall_disable_upgrade(sgx_enclave_id_t eid)
397444

398445
/**
399446
* @description: Get enclave id information
447+
* @param eid -> Enclave id
448+
* @return: Invoking ecall return status
400449
*/
401450
sgx_status_t Ecall_id_get_info(sgx_enclave_id_t eid)
402451
{
@@ -415,6 +464,8 @@ sgx_status_t Ecall_id_get_info(sgx_enclave_id_t eid)
415464

416465
/**
417466
* @description: Get workload
467+
* @param eid -> Enclave id
468+
* @return: Invoking ecall return status
418469
*/
419470
sgx_status_t Ecall_get_workload(sgx_enclave_id_t eid)
420471
{

src/app/ecalls/EnclaveQueue.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ std::string EnclaveQueue::get_running_ecalls_info()
127127

128128
/**
129129
* @description: Get higher priority task number
130-
* @param cur_prio -> current priority
130+
* @param priority -> current priority
131131
* @return: The higher task number
132132
*/
133133
int EnclaveQueue::get_higher_prio_waiting_task_num(int priority)

src/app/http/HttpClient.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ http::response<http::string_body> HttpClient::SSLPost(std::string url, std::stri
145145
* @param body -> Request body
146146
* @param content_type -> Indicates content type
147147
* @param headers -> Poniter to header
148+
* @param type -> Request type
148149
* @return: Json result
149150
*/
150151
http::response<http::string_body> HttpClient::request_sync_ssl(http::verb method, std::string url,

src/app/ipfs/Ipfs.cpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ crust::Log *p_log = crust::Log::get_instance();
44
HttpClient *ipfs_client = NULL;
55
Ipfs *Ipfs::ipfs = NULL;
66

7-
std::string block_get_timeout = "1s";
8-
std::string cat_timeout = "6s";
9-
std::string add_timeout = "600s";
7+
const std::string block_get_timeout = "1s";
8+
const std::string cat_timeout = "6s";
9+
const std::string add_timeout = "600s";
1010

1111
/**
1212
* @desination: single instance class function to get instance
@@ -16,7 +16,7 @@ Ipfs *Ipfs::get_instance()
1616
{
1717
if (Ipfs::ipfs == NULL)
1818
{
19-
Ipfs::ipfs = new Ipfs("http://127.0.0.1:5001/api/v0");
19+
Ipfs::ipfs = new Ipfs(Config::get_instance()->ipfs_url);
2020
}
2121

2222
return Ipfs::ipfs;
@@ -48,7 +48,7 @@ Ipfs::~Ipfs()
4848
/**
4949
* @description: Test if there is usable IPFS
5050
* @return: Test result
51-
* */
51+
*/
5252
bool Ipfs::online()
5353
{
5454
std::string path = this->url + "/version";
@@ -63,8 +63,10 @@ bool Ipfs::online()
6363

6464
/**
6565
* @description: Get block from ipfs
66+
* @param cid -> File content id
67+
* @param p_data_out -> Pointer to pointer to data output
6668
* @return: size of block, 0 for error
67-
* */
69+
*/
6870
size_t Ipfs::block_get(const char *cid, unsigned char **p_data_out)
6971
{
7072
std::string path = this->url + "/block/get?arg=" + cid + "&timeout=" + block_get_timeout;
@@ -96,8 +98,10 @@ size_t Ipfs::block_get(const char *cid, unsigned char **p_data_out)
9698

9799
/**
98100
* @description: Cat file
101+
* @param cid -> File content id
102+
* @param p_data_out -> Pointer to pointer to data output
99103
* @return: size of file, 0 for error
100-
* */
104+
*/
101105
size_t Ipfs::cat(const char *cid, unsigned char **p_data_out)
102106
{
103107
std::string path = this->url + "/cat?arg=" + cid + "&timeout=" + cat_timeout;
@@ -118,8 +122,10 @@ size_t Ipfs::cat(const char *cid, unsigned char **p_data_out)
118122

119123
/**
120124
* @description: Add file to ipfs
125+
* @param p_data_in -> Pointer to data to be added
126+
* @param size -> Size of added data
121127
* @return: Hash of the file
122-
* */
128+
*/
123129
std::string Ipfs::add(unsigned char *p_data_in, size_t size)
124130
{
125131
std::string path = this->url + "/add" + "?timeout=" + add_timeout;
@@ -141,8 +147,9 @@ std::string Ipfs::add(unsigned char *p_data_in, size_t size)
141147

142148
/**
143149
* @description: Delete file
150+
* @param cid -> File content id
144151
* @return: Delete result
145-
* */
152+
*/
146153
bool Ipfs::del(std::string cid)
147154
{
148155
std::string path = this->url + "/pin/rm?arg=" + cid;

src/app/ocalls/IpfsOCalls.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ crust_status_t ocall_ipfs_cat(const char *cid, uint8_t **p_data, size_t *data_si
5959
* @param p_data -> Pointer to be added data
6060
* @param len -> Added data length
6161
* @param cid -> Pointer to returned ipfs content id
62+
* @param cid_len -> File content id length
6263
* @return: Status
6364
*/
6465
crust_status_t ocall_ipfs_add(uint8_t *p_data, size_t len, char *cid, size_t /*cid_len*/)

0 commit comments

Comments
 (0)