Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
d5a47f15
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,发现更多精彩内容 >>
提交
d5a47f15
编写于
6月 18, 2019
作者:
W
Wang Zhi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
New BP election algorithm
上级
88ea4f01
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
135 addition
and
17 deletion
+135
-17
contracts/eosio.system/eosio.system.abi
contracts/eosio.system/eosio.system.abi
+11
-3
contracts/eosio.system/eosio.system.cpp
contracts/eosio.system/eosio.system.cpp
+3
-1
contracts/eosio.system/eosio.system.hpp
contracts/eosio.system/eosio.system.hpp
+17
-12
contracts/eosio.system/voting.cpp
contracts/eosio.system/voting.cpp
+104
-1
未找到文件。
contracts/eosio.system/eosio.system.abi
浏览文件 @
d5a47f15
...
...
@@ -39,7 +39,8 @@
{"name":"total_votes", "type":"float64"},
{"name":"producer_key", "type":"public_key"},
{"name":"all_stake", "type":"int64"},
{"name":"is_active", "type":"bool"}
{"name":"is_active", "type":"bool"},
{"name":"location", "type":"uint16"}
]
},{
"name": "bidname",
...
...
@@ -294,8 +295,7 @@
"base": "",
"fields": [
{"name":"owner", "type":"account_name"},
{"name":"seq_num", "type":"uint16"},
{"name":"all_stake", "type":"int64"}
{"name":"seq_num", "type":"uint16"}
]
},{
...
...
@@ -337,6 +337,10 @@
{"name":"seq", "type":"uint16"},
{"name":"level", "type":"uint8"}
]
},{
"name": "testnewelec",
"base": "",
"fields": []
},{
"name": "setram",
"base": "",
...
...
@@ -539,6 +543,10 @@
"name": "seqproducer",
"type": "seqproducer",
"ricardian_contract": ""
},{
"name": "testnewelec",
"type": "testnewelec",
"ricardian_contract": ""
},{
"name": "regproxy",
"type": "regproxy",
...
...
contracts/eosio.system/eosio.system.cpp
浏览文件 @
d5a47f15
...
...
@@ -93,6 +93,8 @@ namespace eosiosystem {
_producers
.
modify
(
prod
,
0
,
[
&
](
auto
&
p
)
{
p
.
deactivate
();
});
active_producer_seq
(
producer
,
public_key
(),
false
);
}
void
system_contract
::
bidname
(
account_name
bidder
,
account_name
newname
,
asset
bid
)
{
...
...
@@ -204,7 +206,7 @@ EOSIO_ABI( eosiosystem::system_contract,
// delegate_bandwidth.cpp
(
buyrambytes
)(
buyram
)(
sellram
)(
delegatebw
)(
undelegatebw
)(
refund
)
// voting.cpp
(
regproducer
)(
unregprod
)(
voteproducer
)(
regproxy
)(
clsprods2
)(
seqproducer
)
(
regproducer
)(
unregprod
)(
voteproducer
)(
regproxy
)(
clsprods2
)(
seqproducer
)
(
testnewelec
)
// producer_pay.cpp
(
onblock
)(
claimrewards
)
)
contracts/eosio.system/eosio.system.hpp
浏览文件 @
d5a47f15
...
...
@@ -93,7 +93,6 @@ namespace eosiosystem {
struct
producer_info_ext
{
account_name
owner
;
uint16_t
seq_num
=
1
;
// from 1 to 21
int64_t
all_stake
=
0
;
uint64_t
primary_key
()
const
{
return
owner
;
}
EOSLIB_SERIALIZE
(
producer_info_ext
,
(
owner
)(
seq_num
)
)
...
...
@@ -102,12 +101,13 @@ namespace eosiosystem {
struct
prod_meta
{
account_name
owner
;
double
total_votes
=
0
;
double
total_votes
=
0
;
// total votes
eosio
::
public_key
producer_key
;
/// a packed public key object
int64_t
all_stake
=
0
;
int64_t
all_stake
=
0
;
// total original votes (buy yta amount)
bool
is_active
=
true
;
uint16_t
location
=
0
;
EOSLIB_SERIALIZE
(
prod_meta
,
(
owner
)(
total_votes
)(
producer_key
)(
all_stake
)(
is_active
)
)
EOSLIB_SERIALIZE
(
prod_meta
,
(
owner
)(
total_votes
)(
producer_key
)(
all_stake
)(
is_active
)
(
location
)
)
};
struct
producers_seq
{
...
...
@@ -260,14 +260,8 @@ namespace eosiosystem {
void
seqproducer
(
const
account_name
producer
,
uint16_t
seq
,
uint8_t
level
);
void
rm_producer_seq
(
const
account_name
producer
,
uint16_t
seq
);
void
add_producer_seq
(
const
account_name
producer
,
uint16_t
seq
,
uint8_t
level
);
void
active_producer_seq
(
const
account_name
producer
,
const
eosio
::
public_key
&
producer_key
,
bool
isactive
);
void
update_producers_seq_totalvotes
(
uint16_t
seq_num
,
account_name
owner
,
double
total_votes
);
//##YTA-Change end:
void
testnewelec
();
//##YTA-Change end:
void
setram
(
uint64_t
max_ram_size
);
...
...
@@ -287,8 +281,19 @@ namespace eosiosystem {
void
bidname
(
account_name
bidder
,
account_name
newname
,
asset
bid
);
private:
void
update_elected_producers
(
block_timestamp
timestamp
);
//##YTA-Change start:
void
update_elected_producers_yta
(
block_timestamp
timestamp
);
std
::
pair
<
eosio
::
producer_key
,
uint16_t
>
getProducerForSeq
(
uint64_t
seq_num
);
void
rm_producer_seq
(
const
account_name
producer
,
uint16_t
seq
);
void
add_producer_seq
(
const
account_name
producer
,
uint16_t
seq
,
uint8_t
level
);
void
active_producer_seq
(
const
account_name
producer
,
const
eosio
::
public_key
&
producer_key
,
bool
isactive
);
void
update_producers_seq_totalvotes
(
uint16_t
seq_num
,
account_name
owner
,
double
total_votes
);
//##YTA-Change end:
// Implementation details:
...
...
contracts/eosio.system/voting.cpp
浏览文件 @
d5a47f15
...
...
@@ -269,10 +269,113 @@ namespace eosiosystem {
});
}
void
system_contract
::
testnewelec
()
{
require_auth
(
_self
);
std
::
vector
<
std
::
pair
<
eosio
::
producer_key
,
uint16_t
>
>
top_producers
;
top_producers
.
reserve
(
21
);
for
(
uint16_t
seq_num
=
1
;
seq_num
<=
21
;
seq_num
++
)
{
std
::
pair
<
eosio
::
producer_key
,
uint16_t
>
ppinfo
=
getProducerForSeq
(
seq_num
);
if
(
ppinfo
.
first
.
producer_name
!=
0
)
{
top_producers
.
emplace_back
(
ppinfo
);
}
}
if
(
top_producers
.
size
()
<
_gstate
.
last_producer_schedule_size
)
{
return
;
}
/// sort by producer name
std
::
sort
(
top_producers
.
begin
(),
top_producers
.
end
()
);
std
::
vector
<
eosio
::
producer_key
>
producers
;
producers
.
reserve
(
top_producers
.
size
());
for
(
const
auto
&
item
:
top_producers
)
producers
.
push_back
(
item
.
first
);
/*
print("producers start------------------------------\n");
for( const auto& item : producers ) {
print("producer -", (name{item.producer_name}), "--");
//std::string str(std::begin(item.block_signing_key.data), std::end(item.block_signing_key.data));
//for(size_t i=0; i<33; i++) {
// char c = item.block_signing_key.data[i];
// printf("%c",c);
//}
//print(str);
print("\n");
}
print("producers end------------------------------\n");
*/
}
void
system_contract
::
update_elected_producers_yta
(
block_timestamp
block_time
)
{
_gstate
.
last_producer_schedule_update
=
block_time
;
}
std
::
vector
<
std
::
pair
<
eosio
::
producer_key
,
uint16_t
>
>
top_producers
;
top_producers
.
reserve
(
21
);
for
(
uint16_t
seq_num
=
1
;
seq_num
<=
21
;
seq_num
++
)
{
std
::
pair
<
eosio
::
producer_key
,
uint16_t
>
ppinfo
=
getProducerForSeq
(
seq_num
);
if
(
ppinfo
.
first
.
producer_name
!=
0
)
{
top_producers
.
emplace_back
(
ppinfo
);
}
}
if
(
top_producers
.
size
()
<
_gstate
.
last_producer_schedule_size
)
{
return
;
}
/// sort by producer name
std
::
sort
(
top_producers
.
begin
(),
top_producers
.
end
()
);
std
::
vector
<
eosio
::
producer_key
>
producers
;
producers
.
reserve
(
top_producers
.
size
());
for
(
const
auto
&
item
:
top_producers
)
producers
.
push_back
(
item
.
first
);
bytes
packed_schedule
=
pack
(
producers
);
if
(
set_proposed_producers
(
packed_schedule
.
data
(),
packed_schedule
.
size
()
)
>=
0
)
{
_gstate
.
last_producer_schedule_size
=
static_cast
<
decltype
(
_gstate
.
last_producer_schedule_size
)
>
(
top_producers
.
size
()
);
}
}
std
::
pair
<
eosio
::
producer_key
,
uint16_t
>
system_contract
::
getProducerForSeq
(
uint64_t
seq_num
)
{
producers_seq_table
_prodseq
(
_self
,
seq_num
);
auto
ps_itr
=
_prodseq
.
find
(
seq_num
);
if
(
ps_itr
==
_prodseq
.
end
()
)
return
std
::
pair
<
eosio
::
producer_key
,
uint16_t
>
({{
0
,
eosio
::
public_key
{}},
0
});
if
(
ps_itr
->
prods_all
.
begin
()
==
ps_itr
->
prods_all
.
end
()
)
return
std
::
pair
<
eosio
::
producer_key
,
uint16_t
>
({{
0
,
eosio
::
public_key
{}},
0
});
double
total_votes
=
0
;
bool
is_find
=
false
;
auto
max
=
ps_itr
->
prods_all
.
begin
();
for
(
auto
it
=
ps_itr
->
prods_all
.
begin
();
it
!=
ps_itr
->
prods_all
.
end
();
it
++
)
{
if
(
it
->
is_active
&&
it
->
total_votes
>
total_votes
)
{
max
=
it
;
total_votes
=
it
->
total_votes
;
is_find
=
true
;
}
}
if
(
is_find
)
return
std
::
pair
<
eosio
::
producer_key
,
uint16_t
>
({{
max
->
owner
,
max
->
producer_key
},
max
->
location
});
return
std
::
pair
<
eosio
::
producer_key
,
uint16_t
>
({{
0
,
eosio
::
public_key
{}},
0
});
}
//##YTA-Change end:
void
system_contract
::
update_elected_producers
(
block_timestamp
block_time
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录