Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
8e8baf23
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,发现更多精彩内容 >>
提交
8e8baf23
编写于
7月 04, 2019
作者:
W
Wang Zhi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update hdd price precision
上级
558ba7d7
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
46 addition
and
65 deletion
+46
-65
contracts/eosio.system/eosio.system.abi
contracts/eosio.system/eosio.system.abi
+27
-4
contracts/hddpool/hddpool.cpp
contracts/hddpool/hddpool.cpp
+19
-61
未找到文件。
contracts/eosio.system/eosio.system.abi
浏览文件 @
8e8baf23
...
...
@@ -272,11 +272,19 @@
{"name":"total_producer_vote_weight", "type":"float64"},
{"name":"last_name_close", "type":"block_timestamp_type"}
]
},{
"name": "eosio_global_state2",
"base": "",
"fields": [
{"name":"perbase_bucket", "type":"int64"},
{"name":"total_unpaid_base_cnt", "type":"uint32"},
{"name":"last_claim_time", "type":"uint64"}
]
},{
"name": "eosio_global_count",
"base": "",
"fields": [
{"name":"total_accounts",
"type":"uint64"}
{"name":"total_accounts", "type":"uint64"}
]
},{
"name": "producer_info",
...
...
@@ -295,9 +303,10 @@
"name": "producer_info_ext",
"base": "",
"fields": [
{"name":"owner", "type":"account_name"},
{"name":"seq_num", "type":"uint16"},
{"name":"out_votes", "type":"int64"}
{"name":"owner", "type":"account_name"},
{"name":"seq_num", "type":"uint16"},
{"name":"out_votes", "type":"int64"},
{"name":"unpaid_base_cnt", "type":"uint32"}
]
},{
"name": "producers_seq",
...
...
@@ -389,6 +398,10 @@
"fields": [
{"name":"owner", "type":"account_name"}
]
},{
"name": "rewardprods",
"base": "",
"fields": []
},{
"name": "setpriv",
"base": "",
...
...
@@ -572,6 +585,10 @@
"name": "claimrewards",
"type": "claimrewards",
"ricardian_contract": ""
},{
"name": "rewardprods",
"type": "rewardprods",
"ricardian_contract": ""
},{
"name": "setpriv",
"type": "setpriv",
...
...
@@ -625,6 +642,12 @@
"index_type": "i64",
"key_names" : [],
"key_types" : []
},{
"name": "globalext",
"type": "eosio_global_state2",
"index_type": "i64",
"key_names" : [],
"key_types" : []
},{
"name": "gcount",
"type": "eosio_global_count",
...
...
contracts/hddpool/hddpool.cpp
浏览文件 @
8e8baf23
...
...
@@ -238,8 +238,11 @@ void hddpool::buyhdd(name from, name receiver, asset quant)
_hmarket
.
modify
(
market
,
0
,
[
&
](
auto
&
es
)
{
_hdd_amount
=
(
es
.
convert
(
quant
,
HDD_SYMBOL_BANCOR
).
amount
)
*
10000
;
});
print
(
"_hdd_amount: "
,
_hdd_amount
,
"
\n
"
);
_ghddpriceState
.
price
=
(
quant
.
amount
*
100
)
/
(
_hdd_amount
/
10000
);
//print("_hdd_amount: ", _hdd_amount, "\n");
//_ghddpriceState.price = (quant.amount * 100 ) / (_hdd_amount/10000);
_ghddpriceState
.
price
=
(
quant
.
amount
*
10000
*
100000000
)
/
(
_hdd_amount
);
print
(
"_hdd_amount: "
,
_hdd_amount
,
" price: "
,
_ghddpriceState
.
price
,
"
\n
"
);
//userhdd_index _userhdd(_self, _self);
userhdd_index
_userhdd
(
_self
,
receiver
.
value
);
auto
it
=
_userhdd
.
find
(
receiver
.
value
);
...
...
@@ -282,15 +285,16 @@ void hddpool::sellhdd(name user, int64_t amount)
});
int64_t
_yta_amount
=
(
int64_t
)((
double
)
amount
/
10000
);
//int64_t _yta_amount = (int64_t)( (((double)amount/10000)*_ghddpriceState.price)/100 );
//asset tokens_out;
auto
itr
=
_hmarket
.
find
(
HDDCORE_SYMBOL_BANCOR
);
_hmarket
.
modify
(
itr
,
0
,
[
&
](
auto
&
es
)
{
/// the cast to int64_t of quant is safe because we certify quant is <= quota which is limited by prior purchases
_yta_amount
=
es
.
convert
(
asset
(
amount
/
10000
,
HDD_SYMBOL_BANCOR
),
CORE_SYMBOL
).
amount
;
});
print
(
"_yta_amount: "
,
_yta_amount
,
"
\n
"
);
_ghddpriceState
.
price
=
(
_yta_amount
*
100
)
/
(
amount
/
10000
);
//print("_yta_amount: ", _yta_amount, "\n");
//_ghddpriceState.price = (_yta_amount * 100 ) / (amount/10000);
_ghddpriceState
.
price
=
(
_yta_amount
*
10000
*
100000000
)
/
(
amount
);
print
(
"_yta_amount: "
,
_yta_amount
,
" price: "
,
_ghddpriceState
.
price
,
"
\n
"
);
asset
quant
{
_yta_amount
,
CORE_SYMBOL
};
action
(
...
...
@@ -397,60 +401,6 @@ void hddpool::subhspace(name user, uint64_t space, name caller, uint64_t userid)
});
}
/*
void hddpool::newmaccount(name owner, uint64_t minerid, name caller)
{
eosio_assert(is_account(owner), "owner invalidate");
eosio_assert(is_account(caller), "caller not an account");
eosio_assert(is_bp_account(caller.value), "caller not a BP account");
require_auth( caller );
miner2acc_index _miner2acc(_self, minerid);
auto itminer2acc = _miner2acc.find(minerid);
eosio_assert(itminer2acc == _miner2acc.end(), "minerid already registered \n");
_miner2acc.emplace(_self, [&](auto &row) {
row.minerid = minerid;
row.owner = owner;
});
//maccount_index _maccount(_self, _self);
maccount_index _maccount(_self, owner.value);
if (_maccount.begin() == _maccount.end())
{
//miner pool inc
_gstate3.hdd_macc_user += 1;
}
auto it = _maccount.find(minerid);
eosio_assert(it == _maccount.end(), "minerid already exist in maccount table");
_maccount.emplace(_self, [&](auto &row) {
row.minerid = minerid;
row.owner = owner;
row.space = 0;
row.hdd_per_cycle_profit = 0;
row.hdd_balance = 0;
row.last_hdd_time = current_time();
});
//userhdd_index _userhdd(_self, _self);
userhdd_index _userhdd(_self, owner.value);
auto userhdd_itr = _userhdd.find(owner.value);
if (userhdd_itr == _userhdd.end())
{
_userhdd.emplace(_self, [&](auto &row) {
row.account_name = owner;
row.hdd_balance = inc_hdd_amount;
row.hdd_per_cycle_fee = 0;
row.hdd_per_cycle_profit = 0;
row.hdd_space = 0;
row.last_hdd_time = current_time();
_gstate2.hdd_total_user += 1;
});
}
}
*/
void
hddpool
::
addmprofit
(
name
owner
,
uint64_t
minerid
,
uint64_t
space
,
name
caller
)
{
...
...
@@ -728,8 +678,16 @@ void hddpool::addm2pool(uint64_t minerid, name pool_id, name minerowner, uint64_
require_auth
(
itminerinfo
->
admin
);
eosio_assert
(
itminerinfo
->
pool_id
.
value
==
0
,
"miner already join to a pool
\n
"
);
eosio_assert
(
itminerinfo
->
pool_id
.
value
==
0
,
"miner already join to a pool(@@err:alreadyinpool@@)
\n
"
);
/*
if(itminerinfo->pool_id.value != 0) {
if(itminerinfo->pool_id.value != pool_id.value || itminerinfo->max_space != max_space) {
eosio_assert(false, "miner already join to another pool\n");
}
}
*/
eosio_assert
((
itstorepool
->
space_left
>
0
&&
itstorepool
->
space_left
>
max_space
),
"pool space not enough"
);
_minerinfo
.
modify
(
itminerinfo
,
_self
,
[
&
](
auto
&
row
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录