Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
4f0cda67
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,发现更多精彩内容 >>
提交
4f0cda67
编写于
4月 23, 2019
作者:
B
big4david
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix some issue
上级
a4662032
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
43 addition
and
18 deletion
+43
-18
contracts/hdddata/hdddata.cpp
contracts/hdddata/hdddata.cpp
+40
-17
contracts/hdddata/hdddata.hpp
contracts/hdddata/hdddata.hpp
+3
-1
未找到文件。
contracts/hdddata/hdddata.cpp
浏览文件 @
4f0cda67
...
...
@@ -16,6 +16,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
int64_t
useconds_per_day
=
24
*
3600
*
int64_t
(
1000000
);
const
uint32_t
one_gb
=
1024
*
1024
*
1024
;
//1GB
const
uint32_t
data_slice_size
=
8
*
1024
;
// among 4k-32k,set it as 8k
...
...
@@ -86,43 +87,65 @@ void hdddata::gethbalance(name owner) {
print
(
"A gethbalance : "
,
owner
,
" is new ...
\n
"
);
row
.
owner
=
owner
;
row
.
last_hdd_balance
=
10
;
row
.
hdd_per_cycle_fee
=
10
;
row
.
hdd_per_cycle_fee
=
5
;
row
.
hdd_per_cycle_profit
=
10
;
row
.
hdd_space
=
10
;
row
.
last_hdd_time
=
current_time
();
});
}
else
{
uint64_t
tmp_t
=
current_time
();
_hbalance
.
modify
(
hbalance_itr
,
_self
,
[
&
](
auto
&
row
)
{
print
(
"gethbalance modify last_hdd_balance : "
,
hbalance_itr
->
get_last_hdd_balance
(),
"
\n
"
);
uint64_t
slot_t
=
(
tmp_t
-
hbalance_itr
->
last_hdd_time
)
/
1000000ll
;
//convert to seconds
print
(
"gethbalance modify slot_t : "
,
slot_t
,
"
\n
"
);
//todo check overflow and time cycle
print
(
"A gethbalance last_hdd_balance : "
,
hbalance_itr
->
get_last_hdd_balance
(),
"
\n
"
);
row
.
last_hdd_balance
=
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
()
);
slot_t
*
(
hbalance_itr
->
get_hdd_per_cycle_profit
()
-
hbalance_itr
->
get_hdd_per_cycle_fee
()
)
*
seconds_in_one_day
;
print
(
"B gethbalance .last_hdd_balance : "
,
row
.
last_hdd_balance
,
"
\n
"
);
row
.
last_hdd_time
=
current_time
()
;
row
.
last_hdd_time
=
tmp_t
;
});
}
}
void
hdddata
::
update_hddofficial
(
hbalance_table
&
_hbalance
,
const
uint64_t
_hb
,
const
uint64_t
time
)
{
auto
hbalance_itr
=
_hbalance
.
find
(
HDD_OFFICIAL
.
value
);
eosio_assert
(
hbalance_itr
!=
_hbalance
.
end
(),
"no HDD_OFFICIAL exists in hbalance table"
);
_hbalance
.
modify
(
hbalance_itr
,
_self
,
[
&
](
auto
&
row
)
{
//todo check overflow and time cycle
row
.
last_hdd_balance
+=
_hb
;
row
.
last_hdd_time
=
time
;
});
}
void
hdddata
::
gethsum
()
{
require_auth
(
_self
);
hbalance_table
_hbalance
(
_self
,
_self
.
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
)
{
//todo check overflow and time cycle
row
.
last_hdd_balance
=
hbalance_itr
->
get_last_hdd_balance
()
+
// todo ((uint64_t)( 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
();
});
}
eosio_assert
(
hbalance_itr
!=
_hbalance
.
end
(),
"no HDD_OFFICIAL exists in hbalance table"
);
//todo check the 1st time insert
uint64_t
tmp_t
=
current_time
();
_hbalance
.
modify
(
hbalance_itr
,
_self
,
[
&
](
auto
&
row
)
{
print
(
"gethbalance modify last_hdd_balance : "
,
hbalance_itr
->
get_last_hdd_balance
(),
"
\n
"
);
uint64_t
slot_t
=
(
tmp_t
-
hbalance_itr
->
last_hdd_time
)
/
1000000ll
;
//convert to seconds
print
(
"gethbalance modify slot_t : "
,
slot_t
,
"
\n
"
);
//todo check overflow and time cycle
row
.
last_hdd_balance
=
hbalance_itr
->
get_last_hdd_balance
()
+
slot_t
*
(
hbalance_itr
->
get_hdd_per_cycle_profit
()
-
hbalance_itr
->
get_hdd_per_cycle_fee
()
)
*
seconds_in_one_day
;
print
(
"B gethbalance .last_hdd_balance : "
,
row
.
last_hdd_balance
,
"
\n
"
);
row
.
last_hdd_time
=
tmp_t
;
});
}
//@abi action
void
hdddata
::
sethfee
(
name
owner
,
uint64_t
fee
)
{
...
...
contracts/hdddata/hdddata.hpp
浏览文件 @
4f0cda67
...
...
@@ -107,7 +107,7 @@ private:
uint64_t
hdd_per_cycle_fee
=
0
;
uint64_t
hdd_per_cycle_profit
=
0
;
uint64_t
hdd_space
=
0
;
uint64_t
last_hdd_time
=
current_time
();
uint64_t
last_hdd_time
=
current_time
();
//microseconds from 1970
uint64_t
primary_key
()
const
{
return
owner
.
value
;
}
uint64_t
get_last_hdd_balance
()
const
{
return
last_hdd_balance
;
}
uint64_t
get_hdd_per_cycle_fee
()
const
{
return
hdd_per_cycle_fee
;
}
...
...
@@ -144,6 +144,8 @@ private:
typedef
multi_index
<
"producer"
_n
,
producer
>
producer_table
;
private:
void
update_hddofficial
(
hbalance_table
&
_hblance
,
const
uint64_t
_hb
,
const
uint64_t
time
);
//hbalance_table _hbalance;
maccount_table
_maccount
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录