Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
207e81e2
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,发现更多精彩内容 >>
提交
207e81e2
编写于
5月 08, 2019
作者:
W
Wang Zhi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update for hdd unit issue
上级
b0d266df
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
13 addition
and
11 deletion
+13
-11
contracts/hddpool/hddpool.cpp
contracts/hddpool/hddpool.cpp
+13
-11
未找到文件。
contracts/hddpool/hddpool.cpp
浏览文件 @
207e81e2
...
@@ -28,7 +28,7 @@ const uint32_t one_gb = 1024*1024*1024; //1GB
...
@@ -28,7 +28,7 @@ const uint32_t one_gb = 1024*1024*1024; //1GB
const
uint32_t
data_slice_size
=
16
*
1024
;
// among 4k-32k,set it as 16k
const
uint32_t
data_slice_size
=
16
*
1024
;
// among 4k-32k,set it as 16k
const
name
HDD_OFFICIAL
=
"hddofficial"
_n
;
const
name
HDD_OFFICIAL
=
"hddofficial"
_n
;
const
uint64_t
inc_hdd_amount
=
1000000
;
const
uint64_t
inc_hdd_amount
=
1000000
000
;
hddpool
::
hddpool
(
name
s
,
name
code
,
datastream
<
const
char
*>
ds
)
hddpool
::
hddpool
(
name
s
,
name
code
,
datastream
<
const
char
*>
ds
)
...
@@ -61,6 +61,7 @@ ACTION hddpool::getbalance(name user)
...
@@ -61,6 +61,7 @@ ACTION hddpool::getbalance(name user)
{
{
//require_auth( user );
//require_auth( user );
//require_auth(_self);
//require_auth(_self);
//require_auth2(user.value, "active"_n);
userhdd_index
_userhdd
(
_self
,
_self
.
value
);
userhdd_index
_userhdd
(
_self
,
_self
.
value
);
auto
it
=
_userhdd
.
find
(
user
.
value
);
auto
it
=
_userhdd
.
find
(
user
.
value
);
if
(
it
==
_userhdd
.
end
()){
if
(
it
==
_userhdd
.
end
()){
...
@@ -153,7 +154,7 @@ ACTION hddpool::buyhdd( name user , asset quant)
...
@@ -153,7 +154,7 @@ ACTION hddpool::buyhdd( name user , asset quant)
{
{
require_auth
(
user
);
require_auth
(
user
);
eosio_assert
(
is_account
(
user
),
"
from
not a account"
);
eosio_assert
(
is_account
(
user
),
"
user
not a account"
);
eosio_assert
(
is_account
(
hdd_account
),
"to not a account"
);
eosio_assert
(
is_account
(
hdd_account
),
"to not a account"
);
eosio_assert
(
quant
.
is_valid
(),
"asset is invalid"
);
eosio_assert
(
quant
.
is_valid
(),
"asset is invalid"
);
eosio_assert
(
quant
.
symbol
==
yta_symbol
,
"must use YTA to buy HDD"
);
eosio_assert
(
quant
.
symbol
==
yta_symbol
,
"must use YTA to buy HDD"
);
...
@@ -167,12 +168,13 @@ ACTION hddpool::buyhdd( name user , asset quant)
...
@@ -167,12 +168,13 @@ ACTION hddpool::buyhdd( name user , asset quant)
std::make_tuple(user, hdd_account, quant, std::string("buy hdd"))
std::make_tuple(user, hdd_account, quant, std::string("buy hdd"))
).send();*/
).send();*/
uint64_t
_hdd_amount
=
quant
.
amount
*
10000
;
userhdd_index
_userhdd
(
_self
,
_self
.
value
);
userhdd_index
_userhdd
(
_self
,
_self
.
value
);
auto
it
=
_userhdd
.
find
(
user
.
value
);
auto
it
=
_userhdd
.
find
(
user
.
value
);
if
(
it
==
_userhdd
.
end
()){
if
(
it
==
_userhdd
.
end
()){
_userhdd
.
emplace
(
_self
,
[
&
](
auto
&
row
)
{
_userhdd
.
emplace
(
_self
,
[
&
](
auto
&
row
)
{
row
.
account_name
=
user
;
row
.
account_name
=
user
;
//row.hdd_balance =
quant.
amount;
//row.hdd_balance =
_hdd_
amount;
row
.
hdd_balance
=
inc_hdd_amount
;
row
.
hdd_balance
=
inc_hdd_amount
;
row
.
hdd_per_cycle_fee
=
0
;
row
.
hdd_per_cycle_fee
=
0
;
row
.
hdd_per_cycle_profit
=
0
;
row
.
hdd_per_cycle_profit
=
0
;
...
@@ -182,12 +184,12 @@ ACTION hddpool::buyhdd( name user , asset quant)
...
@@ -182,12 +184,12 @@ ACTION hddpool::buyhdd( name user , asset quant)
}
}
else
{
else
{
_userhdd
.
modify
(
it
,
_self
,
[
&
](
auto
&
row
)
{
_userhdd
.
modify
(
it
,
_self
,
[
&
](
auto
&
row
)
{
//row.hdd_balance +=
quant.
amount;
//row.hdd_balance +=
_hdd_
amount;
row
.
hdd_balance
+=
inc_hdd_amount
;
row
.
hdd_balance
+=
inc_hdd_amount
;
});
});
}
}
//update_hddofficial(_userhdd,
quant.
amount , 0, 0, 0);
//update_hddofficial(_userhdd,
_hdd_
amount , 0, 0, 0);
update_hddofficial
(
_userhdd
,
inc_hdd_amount
,
0
,
0
,
0
);
update_hddofficial
(
_userhdd
,
inc_hdd_amount
,
0
,
0
,
0
);
}
}
...
@@ -205,8 +207,10 @@ ACTION hddpool::sellhdd (name user, int64_t amount)
...
@@ -205,8 +207,10 @@ ACTION hddpool::sellhdd (name user, int64_t amount)
row
.
hdd_balance
-=
inc_hdd_amount
;
row
.
hdd_balance
-=
inc_hdd_amount
;
});
});
uint64_t
_yta_amount
=
(
double
)
amount
/
10000
;
/*
/*
asset quant{amount, yta_symbol};
asset quant{_yta_amount, yta_symbol};
action(
action(
permission_level{hdd_account, active_permission},
permission_level{hdd_account, active_permission},
"eosio.token"_n, "transfer"_n,
"eosio.token"_n, "transfer"_n,
...
@@ -214,7 +218,7 @@ ACTION hddpool::sellhdd (name user, int64_t amount)
...
@@ -214,7 +218,7 @@ ACTION hddpool::sellhdd (name user, int64_t amount)
).send();
).send();
*/
*/
//update_hddofficial(_userhdd, -
quant.
amount , 0, 0, 0);
//update_hddofficial(_userhdd, -amount , 0, 0, 0);
update_hddofficial
(
_userhdd
,
-
inc_hdd_amount
,
0
,
0
,
0
);
update_hddofficial
(
_userhdd
,
-
inc_hdd_amount
,
0
,
0
,
0
);
}
}
...
@@ -356,7 +360,6 @@ ACTION hddpool::addmprofit(uint64_t minderid, uint64_t space)
...
@@ -356,7 +360,6 @@ ACTION hddpool::addmprofit(uint64_t minderid, uint64_t space)
ACTION
hddpool
::
clearall
()
ACTION
hddpool
::
clearall
()
{
{
/*
userhdd_index
_userhdd
(
_self
,
_self
.
value
);
userhdd_index
_userhdd
(
_self
,
_self
.
value
);
while
(
_userhdd
.
begin
()
!=
_userhdd
.
end
())
while
(
_userhdd
.
begin
()
!=
_userhdd
.
end
())
_userhdd
.
erase
(
_userhdd
.
begin
());
_userhdd
.
erase
(
_userhdd
.
begin
());
...
@@ -364,9 +367,8 @@ ACTION hddpool::clearall()
...
@@ -364,9 +367,8 @@ ACTION hddpool::clearall()
maccount_index
_maccount
(
_self
,
_self
.
value
);
maccount_index
_maccount
(
_self
,
_self
.
value
);
while
(
_maccount
.
begin
()
!=
_maccount
.
end
())
while
(
_maccount
.
begin
()
!=
_maccount
.
end
())
_maccount
.
erase
(
_maccount
.
begin
());
_maccount
.
erase
(
_maccount
.
begin
());
*/
//_gstate.hdd_total_balance += 100000;
_gstate
.
hdd_total_balance
+=
100000
;
}
}
bool
hddpool
::
is_bp_account
(
uint64_t
uservalue
)
bool
hddpool
::
is_bp_account
(
uint64_t
uservalue
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录