Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
41e34c9f
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,发现更多精彩内容 >>
提交
41e34c9f
编写于
7月 29, 2019
作者:
W
Wang Zhi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
changes include : 1. shadow account for producer 2. update voter's votes when deposit change
上级
f5d30504
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
89 addition
and
8 deletion
+89
-8
contracts/eosio.system/CMakeLists.txt
contracts/eosio.system/CMakeLists.txt
+1
-1
contracts/eosio.system/eosio.system.abi
contracts/eosio.system/eosio.system.abi
+13
-1
contracts/eosio.system/eosio.system.cpp
contracts/eosio.system/eosio.system.cpp
+1
-1
contracts/eosio.system/eosio.system.hpp
contracts/eosio.system/eosio.system.hpp
+19
-3
contracts/eosio.system/voting.cpp
contracts/eosio.system/voting.cpp
+25
-2
contracts/hdddeposit/hdddeposit.cpp
contracts/hdddeposit/hdddeposit.cpp
+30
-0
未找到文件。
contracts/eosio.system/CMakeLists.txt
浏览文件 @
41e34c9f
...
...
@@ -3,6 +3,6 @@ configure_file("${ABI_FILES}" "${CMAKE_CURRENT_BINARY_DIR}" COPYONLY)
add_wast_executable
(
TARGET eosio.system
INCLUDE_FOLDERS
${
STANDARD_INCLUDE_FOLDERS
}
LIBRARIES libc++ libc eosiolib eosio.token
LIBRARIES libc++ libc eosiolib eosio.token
hdddeposit
DESTINATION_FOLDER
${
CMAKE_CURRENT_BINARY_DIR
}
)
contracts/eosio.system/eosio.system.abi
浏览文件 @
41e34c9f
...
...
@@ -320,7 +320,8 @@
{"name":"seq_num", "type":"uint16"},
{"name":"out_votes", "type":"int64"},
{"name":"deposit_votes", "type":"int64"},
{"name":"unpaid_base_cnt", "type":"uint32"}
{"name":"unpaid_base_cnt", "type":"uint32"},
{"name":"shadow", "type":"account_name"}
]
},{
"name": "master_sn_info",
...
...
@@ -371,6 +372,7 @@
"base": "",
"fields": [
{"name":"producer", "type":"account_name"},
{"name":"shadow", "type":"account_name"},
{"name":"seq", "type":"uint16"},
{"name":"level", "type":"uint8"}
]
...
...
@@ -406,6 +408,12 @@
{"name":"proxy", "type":"account_name"},
{"name":"producers", "type":"account_name[]"}
]
},{
"name": "changevotes",
"base": "",
"fields": [
{"name":"voter_name", "type":"account_name"}
]
},{
"name": "voter_info",
"base": "",
...
...
@@ -607,6 +615,10 @@
"name": "voteproducer",
"type": "voteproducer",
"ricardian_contract": ""
},{
"name": "changevotes",
"type": "changevotes",
"ricardian_contract": ""
},{
"name": "claimrewards",
"type": "claimrewards",
...
...
contracts/eosio.system/eosio.system.cpp
浏览文件 @
41e34c9f
...
...
@@ -209,7 +209,7 @@ EOSIO_ABI( eosiosystem::system_contract,
// delegate_bandwidth.cpp
(
buyrambytes
)(
buyram
)(
sellram
)(
delegatebw
)(
undelegatebw
)(
refund
)
// voting.cpp
(
regproducer
)(
unregprod
)(
voteproducer
)(
regproxy
)(
clsprods2
)(
seqproducer
)(
testnewelec
)
(
regproducer
)(
unregprod
)(
voteproducer
)(
changevotes
)(
regproxy
)(
clsprods2
)(
seqproducer
)(
testnewelec
)
// producer_pay.cpp
(
onblock
)(
claimrewards
)(
rewardprods
)
)
contracts/eosio.system/eosio.system.hpp
浏览文件 @
41e34c9f
...
...
@@ -104,9 +104,10 @@ namespace eosiosystem {
int64_t
out_votes
=
0
;
int64_t
deposit_votes
=
0
;
uint32_t
unpaid_base_cnt
=
0
;
account_name
shadow
=
0
;
uint64_t
primary_key
()
const
{
return
owner
;
}
EOSLIB_SERIALIZE
(
producer_info_ext
,
(
owner
)(
seq_num
)(
out_votes
)(
deposit_votes
)(
unpaid_base_cnt
))
EOSLIB_SERIALIZE
(
producer_info_ext
,
(
owner
)(
seq_num
)(
out_votes
)(
deposit_votes
)(
unpaid_base_cnt
)
(
shadow
)
)
};
...
...
@@ -309,11 +310,13 @@ namespace eosiosystem {
//##YTA-Change start:
void
clsprods2
();
void
seqproducer
(
const
account_name
producer
,
uint16_t
seq
,
uint8_t
level
);
void
seqproducer
(
const
account_name
producer
,
const
account_name
shadow
,
uint16_t
seq
,
uint8_t
level
);
void
tmpvotennn
(
const
account_name
producer
,
int64_t
tickets
);
void
testnewelec
();
void
testnewelec
();
void
changevotes
(
const
account_name
voter_name
);
//##YTA-Change end:
void
setram
(
uint64_t
max_ram_size
);
...
...
@@ -367,6 +370,19 @@ namespace eosiosystem {
void
propagate_weight_change
(
const
voter_info
&
voter
);
};
bool
isActiveVoter
(
account_name
owner
)
{
voters_table
voters
(
N
(
eosio
),
N
(
eosio
));
auto
voter
=
voters
.
find
(
owner
);
if
(
voter
==
voters
.
end
()
)
{
return
false
;
}
if
(
voter
->
producers
.
size
()
==
0
)
{
return
false
;
}
return
true
;
}
uint16_t
getProducerSeq
(
account_name
producer
){
producers_ext_table
_producer_ext
(
N
(
eosio
),
N
(
eosio
));
auto
prod
=
_producer_ext
.
find
(
producer
);
...
...
contracts/eosio.system/voting.cpp
浏览文件 @
41e34c9f
...
...
@@ -14,11 +14,13 @@
#include <eosiolib/singleton.hpp>
#include <eosiolib/transaction.hpp>
#include <eosio.token/eosio.token.hpp>
#include <hdddeposit/hdddeposit.hpp>
#include <algorithm>
#include <cmath>
const
uint64_t
useconds_per_day_v
=
24
*
3600
*
uint64_t
(
1000000
);
const
account_name
hdd_deposit_account
=
N
(
hdddeposit12
);
namespace
eosiosystem
{
using
eosio
::
indexed_by
;
...
...
@@ -209,7 +211,7 @@ namespace eosiosystem {
});
}
void
system_contract
::
seqproducer
(
const
account_name
producer
,
uint16_t
seq
,
uint8_t
level
)
{
void
system_contract
::
seqproducer
(
const
account_name
producer
,
const
account_name
shadow
,
uint16_t
seq
,
uint8_t
level
)
{
require_auth
(
_self
);
//const auto& prod = _producers.get( producer, "producer not found" );
...
...
@@ -224,13 +226,15 @@ namespace eosiosystem {
if
(
it
==
_producersext
.
end
())
{
_producersext
.
emplace
(
_self
,
[
&
](
auto
&
row
)
{
row
.
owner
=
producer
;
row
.
seq_num
=
seq
;
row
.
seq_num
=
seq
;
row
.
shadow
=
shadow
;
});
add_producer_seq
(
producer
,
seq
,
level
);
}
else
{
uint16_t
old_seq
=
it
->
seq_num
;
_producersext
.
modify
(
it
,
_self
,
[
&
](
auto
&
row
)
{
row
.
seq_num
=
seq
;
row
.
shadow
=
shadow
;
});
rm_producer_seq
(
producer
,
old_seq
);
add_producer_seq
(
producer
,
seq
,
level
);
...
...
@@ -377,6 +381,11 @@ namespace eosiosystem {
void
system_contract
::
change_producer_seq_info
(
const
account_name
producer
,
const
eosio
::
public_key
&
producer_key
,
bool
isactive
,
bool
seturl
,
const
std
::
string
&
url
)
{
if
(
!
isactive
)
{
delproducer
(
producer
);
return
;
}
all_prods_singleton
_all_prods
(
_self
,
_self
);
all_prods_level
_all_prods_state
;
if
(
_all_prods
.
exists
())
{
...
...
@@ -855,6 +864,19 @@ namespace eosiosystem {
update_votes
(
voter_name
,
proxy
,
producers
,
true
);
}
//##YTA-Change start:
void
system_contract
::
changevotes
(
const
account_name
voter_name
)
{
require_auth
(
voter_name
);
auto
from_voter
=
_voters
.
find
(
voter_name
);
if
(
from_voter
==
_voters
.
end
()
)
{
return
;
}
if
(
from_voter
->
producers
.
size
()
||
from_voter
->
proxy
)
{
update_votes
(
voter_name
,
from_voter
->
proxy
,
from_voter
->
producers
,
false
);
}
}
//##YTA-Change end:
void
system_contract
::
update_votes
(
const
account_name
voter_name
,
const
account_name
proxy
,
const
std
::
vector
<
account_name
>&
producers
,
bool
voting
)
{
//validate input
if
(
proxy
)
{
...
...
@@ -889,6 +911,7 @@ namespace eosiosystem {
}
auto
new_vote_weight
=
stake2vote
(
voter
->
staked
);
new_vote_weight
+=
hdddeposit
(
hdd_deposit_account
).
get_deposit
(
voter_name
).
amount
;
if
(
voter
->
is_proxy
)
{
new_vote_weight
+=
voter
->
proxied_vote_weight
;
}
...
...
contracts/hdddeposit/hdddeposit.cpp
浏览文件 @
41e34c9f
...
...
@@ -63,6 +63,13 @@ void hdddeposit::paydeposit(account_name user, uint64_t minerid, asset quant) {
a
.
dep_total
+=
quant
;
});
}
if
(
eosiosystem
::
isActiveVoter
(
user
)
)
{
action
(
permission_level
{
user
,
active_permission
},
system_account
,
N
(
changevotes
),
std
::
make_tuple
(
user
)).
send
();
}
}
void
hdddeposit
::
undeposit
(
name
user
,
uint64_t
minerid
,
asset
quant
)
{
...
...
@@ -87,6 +94,14 @@ void hdddeposit::undeposit(name user, uint64_t minerid, asset quant) {
_deposit
.
modify
(
acc
,
0
,
[
&
](
auto
&
a
)
{
a
.
deposit
.
amount
-=
quant
.
amount
;
});
if
(
eosiosystem
::
isActiveVoter
(
user
)
)
{
action
(
permission_level
{
user
,
active_permission
},
system_account
,
N
(
changevotes
),
std
::
make_tuple
(
user
)).
send
();
}
}
void
hdddeposit
::
payforfeit
(
name
user
,
uint64_t
minerid
,
asset
quant
,
uint8_t
acc_type
,
name
caller
)
{
...
...
@@ -124,6 +139,14 @@ void hdddeposit::payforfeit(name user, uint64_t minerid, asset quant, uint8_t ac
token_account
,
N
(
transfer
),
std
::
make_tuple
(
user
,
hdd_deposit_account
,
quant
,
std
::
string
(
"draw forfeit"
)))
.
send
();
if
(
eosiosystem
::
isActiveVoter
(
user
)
)
{
action
(
permission_level
{
user
,
active_permission
},
system_account
,
N
(
changevotes
),
std
::
make_tuple
(
user
)).
send
();
}
}
void
hdddeposit
::
delminer
(
uint64_t
minerid
)
{
...
...
@@ -163,6 +186,9 @@ void hdddeposit::setrate(int64_t rate) {
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.");
...
...
@@ -191,6 +217,10 @@ void hdddeposit::drawforfeit(name user, uint8_t acc_type, name caller) {
}
void
hdddeposit
::
cutvote
(
name
user
,
uint8_t
acc_type
,
name
caller
)
{
((
void
)
user
);
((
void
)
acc_type
);
((
void
)
caller
);
/*
if(acc_type == 2) {
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录