Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
8a4fcea9
Y
YTBP
项目概览
YottaChain
/
YTBP
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
YTBP
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8a4fcea9
编写于
4月 15, 2019
作者:
B
big4david
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update contract
上级
c75e2bd0
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
28 addition
and
10 deletion
+28
-10
contracts/hdddata/hdddata.cpp
contracts/hdddata/hdddata.cpp
+28
-10
未找到文件。
contracts/hdddata/hdddata.cpp
浏览文件 @
8a4fcea9
...
...
@@ -12,7 +12,7 @@ const uint32_t minutes_in_one_day = hours_in_one_day * 60;
const
uint32_t
seconds_in_one_day
=
minutes_in_one_day
*
60
;
const
uint32_t
seconds_in_one_week
=
seconds_in_one_day
*
7
;
const
uint32_t
seconds_in_one_year
=
seconds_in_one_day
*
365
;
const
name
HDD_
ACCOUNT
=
"hddofficial"
_n
;
const
name
HDD_
OFFICIAL
=
"hddofficial"
_n
;
// constructor
hdddata
::
hdddata
(
name
s
,
name
code
,
datastream
<
const
char
*>
ds
)
...
...
@@ -23,15 +23,16 @@ hdddata::hdddata( name s, name code, datastream<const char*> ds )
_producer
(
_self
,
_self
.
value
)
{
//todo initialize produers ?
print
(
"construct system
\n
"
);
auto
hbalance_itr
=
_hbalance
.
find
(
HDD_
ACCOUNT
.
value
);
print
(
"construct system
\n
"
);
auto
hbalance_itr
=
_hbalance
.
find
(
HDD_
OFFICIAL
.
value
);
if
(
hbalance_itr
==
_hbalance
.
end
())
{
_hbalance
.
emplace
(
_self
,
[
&
](
auto
&
row
)
{
//todo check the 1st time insert
row
.
last_hdd_balance
=
0
;
row
.
hdd_per_cycle_fee
=
0
;
row
.
hdd_per_cycle_profit
=
0
;
row
.
hdd_space
=
0
;
row
.
owner
=
HDD_OFFICIAL
;
row
.
last_hdd_balance
=
10
;
row
.
hdd_per_cycle_fee
=
10
;
row
.
hdd_per_cycle_profit
=
10
;
row
.
hdd_space
=
20
;
row
.
last_hdd_time
=
current_time
();
});
}
...
...
@@ -59,6 +60,7 @@ hdddata::hdddata( name s, name code, datastream<const char*> ds )
hdddata
::
~
hdddata
()
{
}
symbol
hdddata
::
core_symbol
()
const
{
const
static
auto
sym
=
get_core_symbol
(
_hmarket
);
return
sym
;
...
...
@@ -86,6 +88,7 @@ void hdddata::gethbalance(name owner) {
hbalance_itr
->
get_last_hdd_balance
()
+
//( current_time() - (hbalance_itr->last_hdd_time) )
10
*
(
hbalance_itr
->
get_hdd_per_cycle_profit
()
-
hbalance_itr
->
get_hdd_per_cycle_fee
()
);
row
.
last_hdd_time
=
current_time
();
});
}
...
...
@@ -95,7 +98,7 @@ void hdddata::gethbalance(name owner) {
void
hdddata
::
gethsum
()
{
require_auth
(
_self
);
auto
hbalance_itr
=
_hbalance
.
find
(
HDD_
ACCOUNT
.
value
);
auto
hbalance_itr
=
_hbalance
.
find
(
HDD_
OFFICIAL
.
value
);
if
(
hbalance_itr
!=
_hbalance
.
end
())
{
//todo check the 1st time insert
_hbalance
.
modify
(
hbalance_itr
,
_self
,
[
&
](
auto
&
row
)
{
...
...
@@ -121,7 +124,11 @@ void hdddata::sethfee(name owner, uint64_t fee) {
//todo check overflow
row
.
hdd_per_cycle_fee
-=
fee
;
});
}
}
else
{
print
(
"no owner in _hbalance : "
,
owner
,
"
\n
"
);
}
//每周期费用 <= (占用存储空间*数据分片大小/1GB)*(记账周期/ 1年)
}
...
...
@@ -136,6 +143,9 @@ void hdddata::subhbalance(name owner, uint64_t balance){
//todo check overflow
row
.
last_hdd_balance
-=
balance
;
});
}
else
{
print
(
"no owner in _hbalance : "
,
owner
,
"
\n
"
);
}
}
...
...
@@ -150,6 +160,9 @@ void hdddata::addhspace(name owner, name hddaccount, uint64_t space){
//todo check overflow
row
.
hdd_space
+=
space
;
});
}
else
{
print
(
"no owner in _hbalance : "
,
owner
,
"
\n
"
);
}
}
...
...
@@ -164,6 +177,9 @@ void hdddata::subhspace(name owner, name hddaccount, uint64_t space){
//todo check overflow
row
.
hdd_space
-=
space
;
});
}
else
{
print
(
"no owner in _hbalance : "
,
owner
,
"
\n
"
);
}
}
...
...
@@ -178,6 +194,7 @@ void hdddata::newmaccount(name mname, name owner) {
row
.
owner
=
owner
;
});
}
else
{
print
(
"owner : "
,
owner
,
" already exist in _hbalance
\n
"
);
return
;
}
...
...
@@ -210,6 +227,7 @@ void hdddata::addmprofit(name mname, uint64_t space){
});
}
else
{
//todo
print
(
"no owner in _hbalance : "
,
owner_id
,
"
\n
"
);
}
}
//每周期收益 += (预采购空间*数据分片大小/1GB)*(记账周期/ 1年)
...
...
@@ -261,7 +279,7 @@ extern "C" {
EOSIO_DISPATCH_HELPER
(
hdddata
,
(
gethbalance
)(
gethsum
)(
sethfee
)(
newmaccount
)(
addmprofit
)(
subhbalance
)(
buyhdd
)(
sellhdd
)(
addhspace
)(
subhspace
)
)
}
}
else
if
(
code
==
HDD_
ACCOUNT
.
value
&&
action
==
"transfer"
_n
.
value
)
{
else
if
(
code
==
HDD_
OFFICIAL
.
value
&&
action
==
"transfer"
_n
.
value
)
{
//execute_action( name(receiver), name(code), &hdddata::deposithdd );
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录