Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
0ab4a604
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,发现更多精彩内容 >>
提交
0ab4a604
编写于
6月 26, 2019
作者:
W
Wang Zhi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
sourcecode reformat : remove some no used code
上级
d9a6ce25
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
1 addition
and
189 deletion
+1
-189
contracts/hddpool/hddpool.cpp
contracts/hddpool/hddpool.cpp
+1
-184
contracts/hddpool/hddpool.hpp
contracts/hddpool/hddpool.hpp
+0
-5
未找到文件。
contracts/hddpool/hddpool.cpp
浏览文件 @
0ab4a604
...
...
@@ -26,8 +26,6 @@ const uint32_t fee_cycle = seconds_in_one_day; //计费周期(秒为单位)
const
uint32_t
one_gb
=
1024
*
1024
*
1024
;
//1GB
const
uint32_t
data_slice_size
=
16
*
1024
;
// among 4k-32k,set it as 16k
static
constexpr
eosio
::
name
HDD_OFFICIAL
{
N
(
hddofficial
)};
static
constexpr
eosio
::
name
active_permission
{
N
(
active
)};
static
constexpr
eosio
::
name
token_account
{
N
(
eosio
.
token
)};
static
constexpr
eosio
::
name
hdd_account
{
N
(
hddpool12345
)};
...
...
@@ -39,7 +37,7 @@ static constexpr eosio::name hdd_deposit{N(hdddeposit12)};
const
int64_t
inc_hdd_amount
=
0
;
//1000000000;
const
int64_t
price_delta
=
1
;
//
const int64_t price_delta = 1;
hddpool
::
hddpool
(
account_name
s
)
:
contract
(
s
),
...
...
@@ -210,58 +208,6 @@ void hddpool::update_total_hdd_balance(int64_t _balance_delta)
_gstate
.
hdd_total_balance
=
0
;
}
void
hddpool
::
update_hddofficial
(
const
int64_t
_balance
,
const
int64_t
_fee
,
const
int64_t
_profit
,
const
int64_t
_space
)
{
return
;
//userhdd_index _hbalance(_self, _self);
userhdd_index
_hbalance
(
_self
,
HDD_OFFICIAL
.
value
);
auto
hbalance_itr
=
_hbalance
.
find
(
HDD_OFFICIAL
.
value
);
if
(
hbalance_itr
==
_hbalance
.
end
())
{
_hbalance
.
emplace
(
_self
,
[
&
](
auto
&
row
)
{
row
.
account_name
=
HDD_OFFICIAL
;
row
.
hdd_balance
=
inc_hdd_amount
;
row
.
hdd_per_cycle_fee
=
_fee
;
row
.
hdd_per_cycle_profit
=
_profit
;
if
(
_space
>=
0
)
row
.
hdd_space
=
(
uint64_t
)
_space
;
else
row
.
hdd_space
=
0
;
row
.
last_hdd_time
=
current_time
();
});
}
else
{
_hbalance
.
modify
(
hbalance_itr
,
_self
,
[
&
](
auto
&
row
)
{
//todo check overflow and time cycle
row
.
hdd_balance
+=
_balance
;
if
(
_fee
!=
0
||
_profit
!=
0
)
{
uint64_t
tmp_t
=
current_time
();
int64_t
tmp_last_balance
=
hbalance_itr
->
hdd_balance
;
int64_t
new_balance
;
if
(
calculate_balance
(
tmp_last_balance
,
hbalance_itr
->
hdd_per_cycle_fee
,
hbalance_itr
->
hdd_per_cycle_profit
,
hbalance_itr
->
last_hdd_time
,
tmp_t
,
new_balance
))
{
row
.
hdd_balance
=
new_balance
;
row
.
last_hdd_time
=
tmp_t
;
}
}
row
.
hdd_per_cycle_fee
+=
_fee
;
row
.
hdd_per_cycle_profit
+=
_profit
;
if
(
_space
>=
0
)
row
.
hdd_space
+=
(
uint64_t
)
_space
;
else
row
.
hdd_space
-=
(
uint64_t
)(
-
_space
);
});
}
}
void
hddpool
::
buyhdd
(
name
from
,
name
receiver
,
asset
quant
)
{
require_auth
(
from
);
...
...
@@ -314,9 +260,6 @@ void hddpool::buyhdd(name from, name receiver, asset quant)
});
}
update_hddofficial
(
_hdd_amount
,
0
,
0
,
0
);
//update_hddofficial(inc_hdd_amount , 0, 0, 0);
update_total_hdd_balance
(
_hdd_amount
);
}
...
...
@@ -353,102 +296,9 @@ void hddpool::sellhdd(name user, int64_t amount)
std
::
make_tuple
(
hdd_account
,
user
,
quant
,
std
::
string
(
"sell hdd"
)))
.
send
();
update_hddofficial
(
-
amount
,
0
,
0
,
0
);
//update_hddofficial(-inc_hdd_amount , 0, 0, 0);
update_total_hdd_balance
(
-
amount
);
}
/*
void hddpool::buyhdd( name user , int64_t amount)
{
require_auth( user );
eosio_assert(is_account(user), "user not a account");
eosio_assert(is_account(hdd_account), "to not a account");
eosio_assert(amount > 0, "must transfer positive quantity");
asset quant;
quant.symbol = CORE_SYMBOL;
//quant.amount = amount/10000;
quant.amount = ((amount/10000)*_ghddpriceState.price)/100;
action(
permission_level{user, active_permission},
token_account, N(transfer),
std::make_tuple(user, hdd_account, quant, std::string("buy hdd"))
).send();
//userhdd_index _userhdd(_self, _self);
userhdd_index _userhdd(_self, user.value);
auto it = _userhdd.find(user.value);
if(it == _userhdd.end()){
_userhdd.emplace(_self, [&](auto &row) {
row.account_name = user;
row.hdd_balance = amount;
//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();
});
}
else {
_userhdd.modify(it, _self, [&](auto &row) {
row.hdd_balance += amount;
//row.hdd_balance += inc_hdd_amount;
});
}
update_hddofficial(amount , 0, 0, 0);
//update_hddofficial(inc_hdd_amount , 0, 0, 0);
update_total_hdd_balance(amount);
_ghddpriceState.price += price_delta;
if(_ghddpriceState.price > 85)
_ghddpriceState.price = 85;
}
void hddpool::sellhdd (name user, int64_t amount)
{
require_auth( user );
//userhdd_index _userhdd(_self, _self);
userhdd_index _userhdd(_self, user.value);
auto it = _userhdd.find(user.value);
eosio_assert( it != _userhdd.end(), "user not exists in userhdd table." );
eosio_assert( it->hdd_balance >= amount, "hdd overdrawn." );
_userhdd.modify(it, _self, [&](auto &row) {
row.hdd_balance -= amount;
//row.hdd_balance -= inc_hdd_amount;
});
//int64_t _yta_amount = (int64_t)((double)amount/10000);
int64_t _yta_amount = (int64_t)( (((double)amount/10000)*_ghddpriceState.price)/100 );
asset quant{_yta_amount, CORE_SYMBOL};
action(
permission_level{hdd_account, active_permission},
token_account, N(transfer),
std::make_tuple(hdd_account, user, quant, std::string("sell hdd"))
).send();
update_hddofficial(-amount , 0, 0, 0);
//update_hddofficial(-inc_hdd_amount , 0, 0, 0);
update_total_hdd_balance(-amount);
_ghddpriceState.price -= price_delta;
if(_ghddpriceState.price < 70)
_ghddpriceState.price = 70;
}
*/
void
hddpool
::
sethfee
(
name
user
,
int64_t
fee
,
name
caller
)
{
...
...
@@ -480,8 +330,6 @@ void hddpool::sethfee(name user, int64_t fee, name caller)
row
.
hdd_per_cycle_fee
=
fee
;
});
//变更总账户的每周期费用
update_hddofficial
(
0
,
delta_fee
,
0
,
0
);
}
void
hddpool
::
subbalance
(
name
user
,
int64_t
balance
)
...
...
@@ -498,8 +346,6 @@ void hddpool::subbalance(name user, int64_t balance)
row
.
hdd_balance
-=
balance
;
});
update_hddofficial
(
-
balance
,
0
,
0
,
0
);
update_total_hdd_balance
(
-
balance
);
}
...
...
@@ -519,7 +365,6 @@ void hddpool::addhspace(name user, uint64_t space, name caller)
row
.
hdd_space
+=
space
;
});
update_hddofficial
(
0
,
0
,
0
,
(
int64_t
)
space
);
}
void
hddpool
::
subhspace
(
name
user
,
uint64_t
space
,
name
caller
)
...
...
@@ -538,7 +383,6 @@ void hddpool::subhspace(name user, uint64_t space, name caller)
row
.
hdd_space
-=
space
;
});
update_hddofficial
(
0
,
0
,
0
,
(
int64_t
)(
-
space
));
}
/*
void hddpool::newmaccount(name owner, uint64_t minerid, name caller)
...
...
@@ -660,8 +504,6 @@ void hddpool::addmprofit(name owner, uint64_t minerid, uint64_t space, name call
row
.
hdd_per_cycle_profit
=
0
;
});
//变更总账户的每周期费用
update_hddofficial
(
0
,
0
,
profit_delta
,
0
);
}
void
hddpool
::
calcmbalance
(
name
owner
,
uint64_t
minerid
)
...
...
@@ -717,31 +559,6 @@ void hddpool::clearall(name owner)
}
*/
/*
if(is_bp_account(N(producer1))) {
print( "procuder1 is bp account\n" );
}
if(is_bp_account(N(producer2))) {
print( "procuder2 is bp account\n" );
}
if(is_bp_account(N(producer4))) {
print( "procuder4 is bp account\n" );
}
if(is_bp_account(N(producer3))) {
print( "procuder3 is bp account\n" );
}
return;
*/
/*
userhdd_index _userhdd( _self , _self );
while (_userhdd.begin() != _userhdd.end())
_userhdd.erase(_userhdd.begin());
maccount_index _maccount( _self , _self );
while (_maccount.begin() != _maccount.end())
_maccount.erase(_maccount.begin());
*/
/*
auto itr = _hmarket.find(HDDCORE_SYMBOL_BANCOR);
...
...
contracts/hddpool/hddpool.hpp
浏览文件 @
0ab4a604
...
...
@@ -74,7 +74,6 @@ public:
void
regstrpool
(
name
pool_id
,
name
pool_owner
,
uint64_t
max_space
);
void
addm2pool
(
uint64_t
minerid
,
name
pool_id
,
name
minerowner
,
uint64_t
max_space
);
//store pool related actions -- end
private:
struct
userhdd
{
...
...
@@ -179,9 +178,5 @@ private:
int64_t
hdd_per_cycle_profit
,
uint64_t
last_hdd_time
,
uint64_t
current_time
,
int64_t
&
new_balance
);
void
update_hddofficial
(
const
int64_t
_balance
,
const
int64_t
_fee
,
const
int64_t
_profit
,
const
int64_t
_space
);
void
update_total_hdd_balance
(
int64_t
_balance_delta
);
};
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录