Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
db020072
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,发现更多精彩内容 >>
提交
db020072
编写于
7月 29, 2019
作者:
W
Wang Zhi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change to new method to check bp account
上级
41e34c9f
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
65 addition
and
74 deletion
+65
-74
contracts/eosio.system/eosio.system.hpp
contracts/eosio.system/eosio.system.hpp
+2
-1
contracts/hdddeposit/hdddeposit.cpp
contracts/hdddeposit/hdddeposit.cpp
+17
-51
contracts/hdddeposit/hdddeposit.hpp
contracts/hdddeposit/hdddeposit.hpp
+2
-1
contracts/hddpool/hddpool.cpp
contracts/hddpool/hddpool.cpp
+41
-18
contracts/hddpool/hddpool.hpp
contracts/hddpool/hddpool.hpp
+3
-3
未找到文件。
contracts/eosio.system/eosio.system.hpp
浏览文件 @
db020072
...
...
@@ -383,10 +383,11 @@ namespace eosiosystem {
return
true
;
}
uint16_t
getProducerSeq
(
account_name
producer
){
uint16_t
getProducerSeq
(
account_name
producer
,
account_name
&
shadow
){
producers_ext_table
_producer_ext
(
N
(
eosio
),
N
(
eosio
));
auto
prod
=
_producer_ext
.
find
(
producer
);
if
(
prod
!=
_producer_ext
.
end
())
{
shadow
=
prod
->
shadow
;
return
prod
->
seq_num
;
}
return
0
;
...
...
contracts/hdddeposit/hdddeposit.cpp
浏览文件 @
db020072
...
...
@@ -108,8 +108,9 @@ void hdddeposit::payforfeit(name user, uint64_t minerid, asset quant, uint8_t ac
if
(
acc_type
==
2
)
{
eosio_assert
(
is_account
(
caller
),
"caller not a account."
);
eosio_assert
(
is_bp_account
(
caller
.
value
),
"caller not a BP account."
);
require_auth
(
caller
);
//eosio_assert(is_bp_account(caller.value), "caller not a BP account.");
//require_auth( caller );
check_bp_account
(
caller
.
value
,
minerid
);
}
else
{
require_auth
(
_self
);
}
...
...
@@ -189,64 +190,16 @@ void hdddeposit::drawforfeit(name user, uint8_t acc_type, name caller) {
((
void
)
user
);
((
void
)
acc_type
);
((
void
)
caller
);
/*
if(acc_type == 2) {
eosio_assert(is_account(caller), "caller not a account.");
eosio_assert(is_bp_account(caller.value), "caller not a BP account.");
require_auth( caller );
} else {
require_auth( _self );
}
eosio_assert(is_account(user), "user is not an account.");
accdeposit_table _deposit(_self, user.value);
const auto& acc = _deposit.get( user.value, "no deposit record for this user.");
asset quant{acc.forfeit.amount, CORE_SYMBOL};
action(
permission_level{user, active_permission},
token_account, N(transfer),
std::make_tuple(user, hdd_deposit_account, quant, std::string("draw forfeit")))
.send();
_deposit.modify( acc, 0, [&]( auto& a ) {
a.forfeit.amount = 0;
});
*/
}
void
hdddeposit
::
cutvote
(
name
user
,
uint8_t
acc_type
,
name
caller
)
{
((
void
)
user
);
((
void
)
acc_type
);
((
void
)
caller
);
/*
if(acc_type == 2) {
eosio_assert(is_account(caller), "caller not a account.");
eosio_assert(is_bp_account(caller.value), "caller not a BP account.");
require_auth( caller );
} else {
require_auth( _self );
}
eosio_assert(is_account(user), "user is not an account.");
accdeposit_table _deposit(_self, user.value);
const auto& acc = _deposit.get( user.value, "no deposit record for this user.");
asset quantb{acc.forfeit.amount/2, CORE_SYMBOL};
asset quantw{acc.forfeit.amount/2, CORE_SYMBOL};
action(
permission_level{user, active_permission},
system_account, N(undelegatebw),
std::make_tuple(user, user, quantb, quantw))
.send();
*/
}
/*
bool hdddeposit::is_bp_account(uint64_t uservalue)
{
account_name producers[21];
...
...
@@ -259,6 +212,19 @@ bool hdddeposit::is_bp_account(uint64_t uservalue)
}
return false;
}
*/
void
hdddeposit
::
check_bp_account
(
account_name
bpacc
,
uint64_t
id
)
{
account_name
shadow
;
uint64_t
seq_num
=
eosiosystem
::
getProducerSeq
(
bpacc
,
shadow
);
eosio_assert
(
seq_num
>
0
&&
seq_num
<
22
,
"invalidate account"
);
if
(
id
!=
0
)
{
eosio_assert
(
(
id
%
21
)
==
(
seq_num
-
1
),
"can not access this id"
);
}
//require_auth(shadow);
require_auth
(
bpacc
);
}
EOSIO_ABI
(
hdddeposit
,
(
paydeposit
)(
undeposit
)(
payforfeit
)(
drawforfeit
)(
cutvote
)(
delminer
)(
setrate
))
contracts/hdddeposit/hdddeposit.hpp
浏览文件 @
db020072
...
...
@@ -31,7 +31,8 @@ class hdddeposit : public eosio::contract {
private:
bool
is_bp_account
(
uint64_t
uservalue
);
//bool is_bp_account(uint64_t uservalue);
void
check_bp_account
(
account_name
bpacc
,
uint64_t
id
);
//记录某个账户缴纳的押金总量和当前需要缴纳的罚款总量
struct
acc2deposit
{
...
...
contracts/hddpool/hddpool.cpp
浏览文件 @
db020072
...
...
@@ -7,6 +7,8 @@
#include <eosiolib/serialize.hpp>
#include <eosiolib/multi_index.hpp>
#include <eosio.token/eosio.token.hpp>
#include <eosio.system/eosio.system.hpp>
#include <cmath>
#include <string>
...
...
@@ -115,8 +117,9 @@ void hddpool::getbalance(name user, uint8_t acc_type, name caller)
}
else
if
(
acc_type
==
2
)
{
eosio_assert
(
is_account
(
caller
),
"caller not a account."
);
eosio_assert
(
is_bp_account
(
caller
.
value
),
"caller not a BP account."
);
require_auth
(
caller
);
//eosio_assert(is_bp_account(caller.value), "caller not a BP account.");
//require_auth( caller );
check_bp_account
(
caller
.
value
,
0
);
}
else
{
require_auth
(
_self
);
...
...
@@ -311,8 +314,8 @@ void hddpool::sethfee(name user, int64_t fee, name caller, uint64_t userid)
{
eosio_assert
(
is_account
(
user
),
"user 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
);
//
eosio_assert(is_bp_account(caller.value), "caller not a BP account.");
//
require_auth( caller );
//userhdd_index _userhdd(_self, _self);
userhdd_index
_userhdd
(
_self
,
user
.
value
);
...
...
@@ -321,6 +324,7 @@ void hddpool::sethfee(name user, int64_t fee, name caller, uint64_t userid)
eosio_assert
(
fee
!=
it
->
hdd_per_cycle_fee
,
" the fee is the same
\n
"
);
check_userid
(
user
.
value
,
userid
);
check_bp_account
(
caller
.
value
,
userid
);
//每周期费用 <= (占用存储空间*数据分片大小/1GB)*(记账周期/ 1年)
//bool istrue = fee <= (int64_t)(((double)(it->hdd_space * data_slice_size)/(double)one_gb) * ((double)fee_cycle/(double)seconds_in_one_year));
...
...
@@ -366,8 +370,8 @@ void hddpool::addhspace(name user, uint64_t space, name caller, uint64_t userid)
{
eosio_assert
(
is_account
(
user
),
"user 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
);
//
eosio_assert(is_bp_account(caller.value), "caller not a BP account.");
//
require_auth( caller );
//userhdd_index _userhdd(_self, _self);
userhdd_index
_userhdd
(
_self
,
user
.
value
);
...
...
@@ -375,6 +379,7 @@ void hddpool::addhspace(name user, uint64_t space, name caller, uint64_t userid)
eosio_assert
(
it
!=
_userhdd
.
end
(),
"user not exists in userhdd table"
);
check_userid
(
user
.
value
,
userid
);
check_bp_account
(
caller
.
value
,
userid
);
_userhdd
.
modify
(
it
,
_self
,
[
&
](
auto
&
row
)
{
row
.
hdd_space
+=
space
;
...
...
@@ -386,8 +391,8 @@ void hddpool::subhspace(name user, uint64_t space, name caller, uint64_t userid)
{
eosio_assert
(
is_account
(
user
),
"user 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
);
//
eosio_assert(is_bp_account(caller.value), "caller not a BP account.");
//
require_auth( caller );
//userhdd_index _userhdd(_self, _self);
userhdd_index
_userhdd
(
_self
,
user
.
value
);
...
...
@@ -395,6 +400,7 @@ void hddpool::subhspace(name user, uint64_t space, name caller, uint64_t userid)
eosio_assert
(
it
!=
_userhdd
.
end
(),
"user not exists in userhdd table"
);
check_userid
(
user
.
value
,
userid
);
check_bp_account
(
caller
.
value
,
userid
);
_userhdd
.
modify
(
it
,
_self
,
[
&
](
auto
&
row
)
{
row
.
hdd_space
-=
space
;
...
...
@@ -406,8 +412,9 @@ void hddpool::addmprofit(name owner, uint64_t minerid, uint64_t space, name call
{
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
);
//eosio_assert(is_bp_account(caller.value), "caller not a BP account.");
//require_auth( caller );
check_bp_account
(
caller
.
value
,
minerid
);
//maccount_index _maccount(_self, _self);
maccount_index
_maccount
(
_self
,
owner
.
value
);
...
...
@@ -541,8 +548,9 @@ void hddpool::mdeactive(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
);
//eosio_assert(is_bp_account(caller.value), "caller not a BP account.");
//require_auth( caller );
check_bp_account
(
caller
.
value
,
minerid
);
//maccount_index _maccount(_self, _self);
maccount_index
_maccount
(
_self
,
owner
.
value
);
...
...
@@ -583,8 +591,9 @@ void hddpool::mactive(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
);
//eosio_assert(is_bp_account(caller.value), "caller not a BP account.");
//require_auth( caller );
check_bp_account
(
caller
.
value
,
minerid
);
//maccount_index _maccount(_self, _self);
maccount_index
_maccount
(
_self
,
owner
.
value
);
...
...
@@ -646,6 +655,8 @@ void hddpool::delstrpool(name poolid)
void
hddpool
::
regstrpool
(
name
pool_id
,
name
pool_owner
,
uint64_t
max_space
)
{
((
void
)
max_space
);
eosio_assert
(
is_account
(
pool_owner
),
"pool_owner invalidate"
);
//require_auth(_self);
...
...
@@ -756,22 +767,21 @@ void hddpool::addm2pool(uint64_t minerid, name pool_id, name minerowner, uint64_
}
}
bool
hddpool
::
check_userid
(
uint64_t
namevalue
,
uint64_t
userid
)
void
hddpool
::
check_userid
(
uint64_t
namevalue
,
uint64_t
userid
)
{
userhdd2_index
_userhdd2
(
_self
,
_self
);
auto
it
=
_userhdd2
.
find
(
namevalue
);
if
(
it
!=
_userhdd2
.
end
())
{
if
(
it
->
userid
!=
userid
)
return
false
;
eosio_assert
(
it
->
userid
==
userid
,
"invalidate userid"
);
}
else
{
_userhdd2
.
emplace
(
_self
,
[
&
](
auto
&
row
)
{
row
.
account_name
=
name
{
namevalue
};
row
.
userid
=
userid
;
});
}
return
true
;
}
/*
bool hddpool::is_bp_account(uint64_t uservalue)
{
account_name producers[21];
...
...
@@ -784,6 +794,19 @@ bool hddpool::is_bp_account(uint64_t uservalue)
}
return false;
}
*/
void
hddpool
::
check_bp_account
(
account_name
bpacc
,
uint64_t
id
)
{
account_name
shadow
;
uint64_t
seq_num
=
eosiosystem
::
getProducerSeq
(
bpacc
,
shadow
);
eosio_assert
(
seq_num
>
0
&&
seq_num
<
22
,
"invalidate account"
);
if
(
id
!=
0
)
{
eosio_assert
(
(
id
%
21
)
==
(
seq_num
-
1
),
"can not access this id"
);
}
//require_auth(shadow);
require_auth
(
bpacc
);
}
asset
exchange_state
::
convert_to_exchange
(
connector
&
c
,
asset
in
)
{
...
...
contracts/hddpool/hddpool.hpp
浏览文件 @
db020072
...
...
@@ -185,9 +185,9 @@ private:
hmarket_table
_hmarket
;
bool
is_bp_account
(
uint64_t
uservalue
);
bool
check_userid
(
uint64_t
namevalue
,
uint64_t
userid
);
//
bool is_bp_account(uint64_t uservalue);
void
check_bp_account
(
account_name
bpacc
,
uint64_t
id
);
void
check_userid
(
uint64_t
namevalue
,
uint64_t
userid
);
bool
calculate_balance
(
int64_t
oldbalance
,
int64_t
hdd_per_cycle_fee
,
int64_t
hdd_per_cycle_profit
,
uint64_t
last_hdd_time
,
uint64_t
current_time
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录