Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@ Output:
Description:
1. files: give meaningful file information
1. lost: lost file information, includes 'num' and 'size'
1. pending: pending file information, includes 'num' and 'size'
1. valid: valid file information, includes 'num' and 'size'
1. srd: give srd information
1. srd_complete: srded space volume
1. srd_remaining_task: remaining srd task
1. disk_available_for_srd: available volume for srd in current disk
1. disk_available: free space in current disk
1. disk_volume: current disk total volume
1. sys_disk_available: free space of system disk
1. srd_detail: show disks' detail information

Use '/api/v0/stop' to stop sworker
Expand Down Expand Up @@ -139,7 +141,7 @@ Output:
Use '/api/v0/file/info' to get sealed file information by cid
-------------------------------------------------------------
```
curl -XPOST http://<url:port>/api/v0/file/info?cid=xxxx
curl -XPOST http://<url:port>/api/v0/file/info?cid=QmfSQ6hNXDT5Wx5agiqkfDHtF4D4p2P3hyb1bmEDnbWp3y
```

Parameter:
Expand All @@ -148,15 +150,19 @@ Parameter:
Output (200, success):
```
{
"c_block_num" : 0,
"s_size" : 16783146,
"size" : 16781194
"QmfSQ6hNXDT5Wx5agiqkfDHtF4D4p2P3hyb1bmEDnbWp3y" : {
"c_block_num" : 110,
"s_size" : 5255889,
"size" : 5244129,
"type" : "valid"
}
}
```
Description:
1. c_block_num: chain block number when sealing the file
1. s_size: sealed file size
1. size: file real size
1. type: file status

Output (400, failed):
```
Expand Down
35 changes: 23 additions & 12 deletions src/enclave/srd/Srd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ void srd_change()
return;
}

sgx_thread_mutex_lock(&g_srd_task_mutex);
SafeLock sl_task(g_srd_task_mutex);
sl_task.lock();
if (0 == g_srd_task)
return;

// Get real srd space
long srd_change_num = 0;
if (g_srd_task > SRD_MAX_INC_PER_TURN)
Expand All @@ -72,15 +76,7 @@ void srd_change()
srd_change_num = std::max(g_srd_task, (long)-SRD_MAX_DEC_PER_TURN);
g_srd_task -= srd_change_num;
}
// Store remaining task
std::string srd_task_str = std::to_string(g_srd_task);
if (CRUST_SUCCESS != persist_set_unsafe(WL_SRD_REMAINING_TASK, reinterpret_cast<const uint8_t *>(srd_task_str.c_str()), srd_task_str.size()))
{
log_warn("Store srd remaining task failed!\n");
}
// Set srd remaining task
wl->set_srd_remaining_task(g_srd_task);
sgx_thread_mutex_unlock(&g_srd_task_mutex);
sl_task.unlock();

// Do srd
crust_status_t crust_status = CRUST_SUCCESS;
Expand All @@ -89,11 +85,26 @@ void srd_change()
ocall_srd_change(&crust_status, srd_change_num);
if (CRUST_SRD_NUMBER_EXCEED == crust_status)
{
sgx_thread_mutex_lock(&g_srd_task_mutex);
sl_task.lock();
g_srd_task = 0;
sgx_thread_mutex_unlock(&g_srd_task_mutex);
// Update srd info
wl->set_srd_remaining_task(g_srd_task);
std::string srd_info_str = wl->get_srd_info().dump();
ocall_set_srd_info(reinterpret_cast<const uint8_t *>(srd_info_str.c_str()), srd_info_str.size());
sl_task.unlock();
}
}

// Store remaining task
sl_task.lock();
std::string srd_task_str = std::to_string(g_srd_task);
if (CRUST_SUCCESS != persist_set_unsafe(WL_SRD_REMAINING_TASK, reinterpret_cast<const uint8_t *>(srd_task_str.c_str()), srd_task_str.size()))
{
log_warn("Store srd remaining task failed!\n");
}
// Set srd remaining task
wl->set_srd_remaining_task(g_srd_task);
sl_task.unlock();
}

/**
Expand Down