Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
a7d77526
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,发现更多精彩内容 >>
未验证
提交
a7d77526
编写于
5月 17, 2018
作者:
D
Daniel Larimer
提交者:
GitHub
5月 17, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3179 from EOSIO/cleos-more-producers
Scale votes in producer list (#2933)
上级
875c5f1b
3366ccfe
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
26 addition
and
5 deletion
+26
-5
plugins/chain_plugin/chain_plugin.cpp
plugins/chain_plugin/chain_plugin.cpp
+18
-1
plugins/chain_plugin/include/eosio/chain_plugin/chain_plugin.hpp
.../chain_plugin/include/eosio/chain_plugin/chain_plugin.hpp
+2
-1
programs/cleos/main.cpp
programs/cleos/main.cpp
+6
-3
未找到文件。
plugins/chain_plugin/chain_plugin.cpp
浏览文件 @
a7d77526
...
...
@@ -403,11 +403,27 @@ static float64_t to_softfloat64( double d ) {
return
*
reinterpret_cast
<
float64_t
*>
(
&
d
);
}
static
fc
::
variant
get_global_row
(
const
database
&
db
,
const
abi_def
&
abi
,
const
abi_serializer
&
abis
)
{
const
auto
table_type
=
get_table_type
(
abi
,
N
(
global
));
EOS_ASSERT
(
table_type
==
read_only
::
KEYi64
,
chain
::
contract_table_query_exception
,
"Invalid table type ${type} for table global"
,
(
"type"
,
table_type
));
const
auto
*
const
table_id
=
db
.
find
<
chain
::
table_id_object
,
chain
::
by_code_scope_table
>
(
boost
::
make_tuple
(
N
(
eosio
),
N
(
eosio
),
N
(
global
)));
EOS_ASSERT
(
table_id
,
chain
::
contract_table_query_exception
,
"Missing table global"
);
const
auto
&
kv_index
=
db
.
get_index
<
key_value_index
,
by_scope_primary
>
();
const
auto
it
=
kv_index
.
find
(
boost
::
make_tuple
(
table_id
->
id
,
N
(
global
)));
EOS_ASSERT
(
it
!=
kv_index
.
end
(),
chain
::
contract_table_query_exception
,
"Missing row in table global"
);
vector
<
char
>
data
;
read_only
::
copy_inline_row
(
*
it
,
data
);
return
abis
.
binary_to_variant
(
abis
.
get_table_type
(
N
(
global
)),
data
);
}
read_only
::
get_producers_result
read_only
::
get_producers
(
const
read_only
::
get_producers_params
&
p
)
const
{
const
abi_def
abi
=
get_abi
(
db
,
N
(
eosio
));
const
auto
table_type
=
get_table_type
(
abi
,
N
(
producers
));
const
abi_serializer
abis
{
abi
};
EOS_ASSERT
(
table_type
==
KEYi64
,
chain
::
contract_table_query_exception
,
"Invalid table type ${type}"
,
(
"type"
,
table_type
));
EOS_ASSERT
(
table_type
==
KEYi64
,
chain
::
contract_table_query_exception
,
"Invalid table type ${type}
for table producers
"
,
(
"type"
,
table_type
));
const
auto
&
d
=
db
.
db
();
const
auto
lower
=
name
{
p
.
lower_bound
};
...
...
@@ -448,6 +464,7 @@ read_only::get_producers_result read_only::get_producers( const read_only::get_p
result
.
rows
.
emplace_back
(
fc
::
variant
(
data
));
}
result
.
total_producer_vote_weight
=
get_global_row
(
d
,
abi
,
abis
)[
"total_producer_vote_weight"
].
as_double
();
return
result
;
}
...
...
plugins/chain_plugin/include/eosio/chain_plugin/chain_plugin.hpp
浏览文件 @
a7d77526
...
...
@@ -216,6 +216,7 @@ public:
struct
get_producers_result
{
vector
<
fc
::
variant
>
rows
;
///< one row per item, either encoded as hex string or JSON object
double
total_producer_vote_weight
;
string
more
;
///< fill lower_bound with this value to fetch more rows
};
...
...
@@ -397,7 +398,7 @@ FC_REFLECT( eosio::chain_apis::read_only::get_currency_stats_params, (code)(symb
FC_REFLECT
(
eosio
::
chain_apis
::
read_only
::
get_currency_stats_result
,
(
supply
)(
max_supply
)(
issuer
));
FC_REFLECT
(
eosio
::
chain_apis
::
read_only
::
get_producers_params
,
(
json
)(
lower_bound
)(
limit
)
)
FC_REFLECT
(
eosio
::
chain_apis
::
read_only
::
get_producers_result
,
(
rows
)(
more
)
);
FC_REFLECT
(
eosio
::
chain_apis
::
read_only
::
get_producers_result
,
(
rows
)(
total_producer_vote_weight
)(
more
)
);
FC_REFLECT
(
eosio
::
chain_apis
::
read_only
::
get_account_results
,
(
account_name
)(
privileged
)(
last_code_update
)(
created
)(
ram_quota
)(
net_weight
)(
cpu_weight
)(
net_limit
)(
cpu_limit
)(
ram_usage
)(
permissions
)(
total_resources
)(
delegated_bandwidth
)(
voter_info
)
)
FC_REFLECT
(
eosio
::
chain_apis
::
read_only
::
get_code_results
,
(
account_name
)(
code_hash
)(
wast
)(
abi
)
)
...
...
programs/cleos/main.cpp
浏览文件 @
a7d77526
...
...
@@ -1031,13 +1031,16 @@ struct list_producers_subcommand {
std
::
cout
<<
"No producers found"
<<
std
::
endl
;
return
;
}
printf
(
"%-13s %-54s %-59s %s
\n
"
,
"Producer"
,
"Producer key"
,
"Url"
,
"Total votes"
);
auto
weight
=
result
.
total_producer_vote_weight
;
if
(
!
weight
)
weight
=
1
;
printf
(
"%-13s %-54s %-59s %s
\n
"
,
"Producer"
,
"Producer key"
,
"Url"
,
"Scaled votes"
);
for
(
auto
&
row
:
result
.
rows
)
printf
(
"%-13.13s %-54.54s %-59.59s %
040
f
\n
"
,
printf
(
"%-13.13s %-54.54s %-59.59s %
1.4
f
\n
"
,
row
[
"owner"
].
as_string
().
c_str
(),
row
[
"producer_key"
].
as_string
().
c_str
(),
row
[
"url"
].
as_string
().
c_str
(),
row
[
"total_votes"
].
as_double
());
row
[
"total_votes"
].
as_double
()
/
weight
);
if
(
!
result
.
more
.
empty
()
)
std
::
cout
<<
"-L "
<<
result
.
more
<<
" for more"
<<
std
::
endl
;
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录