Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
f5d30504
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,发现更多精彩内容 >>
提交
f5d30504
编写于
7月 26, 2019
作者:
W
Wang Zhi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update hdddeposit contract -- N/A
上级
3fcaeb3e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
60 addition
and
58 deletion
+60
-58
contracts/hdddeposit/hdddeposit.cpp
contracts/hdddeposit/hdddeposit.cpp
+60
-58
未找到文件。
contracts/hdddeposit/hdddeposit.cpp
浏览文件 @
f5d30504
...
@@ -32,11 +32,20 @@ void hdddeposit::paydeposit(account_name user, uint64_t minerid, asset quant) {
...
@@ -32,11 +32,20 @@ void hdddeposit::paydeposit(account_name user, uint64_t minerid, asset quant) {
real_balance
.
amount
-=
acc
->
deposit
.
amount
;
real_balance
.
amount
-=
acc
->
deposit
.
amount
;
real_balance
.
amount
-=
acc
->
forfeit
.
amount
;
real_balance
.
amount
-=
acc
->
forfeit
.
amount
;
}
}
//to do : also need sub lock_token in futuer( 也可能不需要,取决于需求)
//......
eosio_assert
(
real_balance
.
amount
>=
quant
.
amount
,
"user balance not enough."
);
eosio_assert
(
real_balance
.
amount
>=
quant
.
amount
,
"user balance not enough."
);
//insert or update accdeposit table
if
(
acc
==
_deposit
.
end
()
)
{
_deposit
.
emplace
(
_self
,
[
&
](
auto
&
a
){
a
.
account_name
=
name
{
user
};
a
.
deposit
=
quant
;
});
}
else
{
_deposit
.
modify
(
acc
,
0
,
[
&
](
auto
&
a
)
{
a
.
deposit
+=
quant
;
});
}
//insert or update minerdeposit table
//insert or update minerdeposit table
minerdeposit_table
_mdeposit
(
_self
,
_self
);
minerdeposit_table
_mdeposit
(
_self
,
_self
);
auto
miner
=
_mdeposit
.
find
(
minerid
);
auto
miner
=
_mdeposit
.
find
(
minerid
);
...
@@ -54,18 +63,6 @@ void hdddeposit::paydeposit(account_name user, uint64_t minerid, asset quant) {
...
@@ -54,18 +63,6 @@ void hdddeposit::paydeposit(account_name user, uint64_t minerid, asset quant) {
a
.
dep_total
+=
quant
;
a
.
dep_total
+=
quant
;
});
});
}
}
//insert or update accdeposit table
if
(
acc
==
_deposit
.
end
()
)
{
_deposit
.
emplace
(
_self
,
[
&
](
auto
&
a
){
a
.
account_name
=
name
{
user
};
a
.
deposit
=
quant
;
});
}
else
{
_deposit
.
modify
(
acc
,
0
,
[
&
](
auto
&
a
)
{
a
.
deposit
+=
quant
;
});
}
}
}
void
hdddeposit
::
undeposit
(
name
user
,
uint64_t
minerid
,
asset
quant
)
{
void
hdddeposit
::
undeposit
(
name
user
,
uint64_t
minerid
,
asset
quant
)
{
...
@@ -119,13 +116,54 @@ void hdddeposit::payforfeit(name user, uint64_t minerid, asset quant, uint8_t ac
...
@@ -119,13 +116,54 @@ void hdddeposit::payforfeit(name user, uint64_t minerid, asset quant, uint8_t ac
_deposit
.
modify
(
acc
,
0
,
[
&
](
auto
&
a
)
{
_deposit
.
modify
(
acc
,
0
,
[
&
](
auto
&
a
)
{
a
.
deposit
.
amount
-=
quant
.
amount
;
a
.
deposit
.
amount
-=
quant
.
amount
;
a
.
forfeit
.
amount
+=
quant
.
amount
;
//
a.forfeit.amount += quant.amount;
});
});
action
(
permission_level
{
user
,
active_permission
},
token_account
,
N
(
transfer
),
std
::
make_tuple
(
user
,
hdd_deposit_account
,
quant
,
std
::
string
(
"draw forfeit"
)))
.
send
();
}
}
void
hdddeposit
::
drawforfeit
(
name
user
,
uint8_t
acc_type
,
name
caller
)
{
void
hdddeposit
::
delminer
(
uint64_t
minerid
)
{
require_auth
(
_self
);
minerdeposit_table
_mdeposit
(
_self
,
_self
);
auto
miner
=
_mdeposit
.
find
(
minerid
);
if
(
miner
==
_mdeposit
.
end
())
return
;
accdeposit_table
_deposit
(
_self
,
miner
->
account_name
.
value
);
auto
acc
=
_deposit
.
find
(
miner
->
account_name
.
value
);
if
(
acc
!=
_deposit
.
end
())
{
if
(
acc
->
deposit
.
amount
>=
miner
->
deposit
.
amount
)
{
_deposit
.
modify
(
acc
,
0
,
[
&
](
auto
&
a
)
{
a
.
deposit
.
amount
-=
miner
->
deposit
.
amount
;
});
}
}
_mdeposit
.
erase
(
miner
);
}
void
hdddeposit
::
setrate
(
int64_t
rate
)
{
require_auth
(
_self
);
grate_singleton
_rate
(
_self
,
_self
);
deposit_rate
_rateState
;
if
(
_rate
.
exists
())
_rateState
=
_rate
.
get
();
else
_rateState
=
deposit_rate
{};
_rateState
.
rate
=
rate
;
_rate
.
set
(
_rateState
,
_self
);
}
void
hdddeposit
::
drawforfeit
(
name
user
,
uint8_t
acc_type
,
name
caller
)
{
/*
if(acc_type == 2) {
if(acc_type == 2) {
eosio_assert(is_account(caller), "caller not a account.");
eosio_assert(is_account(caller), "caller not a account.");
eosio_assert(is_bp_account(caller.value), "caller not a BP account.");
eosio_assert(is_bp_account(caller.value), "caller not a BP account.");
...
@@ -147,14 +185,14 @@ void hdddeposit::drawforfeit(name user, uint8_t acc_type, name caller) {
...
@@ -147,14 +185,14 @@ void hdddeposit::drawforfeit(name user, uint8_t acc_type, name caller) {
_deposit.modify( acc, 0, [&]( auto& a ) {
_deposit.modify( acc, 0, [&]( auto& a ) {
a.forfeit.amount = 0;
a.forfeit.amount = 0;
});
});
*/
}
}
void
hdddeposit
::
cutvote
(
name
user
,
uint8_t
acc_type
,
name
caller
)
{
void
hdddeposit
::
cutvote
(
name
user
,
uint8_t
acc_type
,
name
caller
)
{
return
;
/*
if(acc_type == 2) {
if(acc_type == 2) {
eosio_assert(is_account(caller), "caller not a account.");
eosio_assert(is_account(caller), "caller not a account.");
eosio_assert(is_bp_account(caller.value), "caller not a BP account.");
eosio_assert(is_bp_account(caller.value), "caller not a BP account.");
...
@@ -170,50 +208,14 @@ void hdddeposit::cutvote(name user, uint8_t acc_type, name caller) {
...
@@ -170,50 +208,14 @@ void hdddeposit::cutvote(name user, uint8_t acc_type, name caller) {
asset quantb{acc.forfeit.amount/2, CORE_SYMBOL};
asset quantb{acc.forfeit.amount/2, CORE_SYMBOL};
asset quantw{acc.forfeit.amount/2, CORE_SYMBOL};
asset quantw{acc.forfeit.amount/2, CORE_SYMBOL};
//asset quantb{10000, CORE_SYMBOL};
//asset quantw{10000, CORE_SYMBOL};
action(
action(
permission_level{user, active_permission},
permission_level{user, active_permission},
system_account, N(undelegatebw),
system_account, N(undelegatebw),
std::make_tuple(user, user, quantb, quantw))
std::make_tuple(user, user, quantb, quantw))
.send();
.send();
*/
}
}
void
hdddeposit
::
delminer
(
uint64_t
minerid
)
{
require_auth
(
_self
);
minerdeposit_table
_mdeposit
(
_self
,
_self
);
auto
miner
=
_mdeposit
.
find
(
minerid
);
if
(
miner
==
_mdeposit
.
end
())
return
;
accdeposit_table
_deposit
(
_self
,
miner
->
account_name
.
value
);
auto
acc
=
_deposit
.
find
(
miner
->
account_name
.
value
);
if
(
acc
!=
_deposit
.
end
())
{
if
(
acc
->
deposit
.
amount
>=
miner
->
deposit
.
amount
)
{
_deposit
.
modify
(
acc
,
0
,
[
&
](
auto
&
a
)
{
a
.
deposit
.
amount
-=
miner
->
deposit
.
amount
;
});
}
}
_mdeposit
.
erase
(
miner
);
}
void
hdddeposit
::
setrate
(
int64_t
rate
)
{
require_auth
(
_self
);
grate_singleton
_rate
(
_self
,
_self
);
deposit_rate
_rateState
;
if
(
_rate
.
exists
())
_rateState
=
_rate
.
get
();
else
_rateState
=
deposit_rate
{};
_rateState
.
rate
=
rate
;
_rate
.
set
(
_rateState
,
_self
);
}
bool
hdddeposit
::
is_bp_account
(
uint64_t
uservalue
)
bool
hdddeposit
::
is_bp_account
(
uint64_t
uservalue
)
{
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录