Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
c67773ea
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,发现更多精彩内容 >>
提交
c67773ea
编写于
5月 13, 2018
作者:
D
Daniel Larimer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improve pretty printing of account status
上级
8210e063
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
63 addition
and
45 deletion
+63
-45
programs/cleos/main.cpp
programs/cleos/main.cpp
+63
-45
未找到文件。
programs/cleos/main.cpp
浏览文件 @
c67773ea
...
...
@@ -1194,10 +1194,34 @@ void get_account( const string& accountName, bool json_format ) {
dfs_print
(
r
,
0
);
}
auto
to_pretty_net
=
[](
double
bytes
)
{
string
unit
=
"bytes"
;
if
(
bytes
>=
1024
*
1024
*
1024
*
1024ll
){
unit
=
"Tb"
;
bytes
/=
1024
*
1024
*
1024
*
1024ll
;
}
else
if
(
bytes
>=
1024
*
1024
*
1024
){
unit
=
"Gb"
;
bytes
/=
1024
*
1024
*
1024
;
}
else
if
(
bytes
>=
1024
*
1024
){
unit
=
"Mb"
;
bytes
/=
1024
*
1024
;
}
else
if
(
bytes
>=
1024
)
{
unit
=
"Kb"
;
bytes
/=
1024
;
}
std
::
stringstream
ss
;
ss
<<
setprecision
(
4
);
ss
<<
bytes
<<
" "
<<
std
::
left
<<
setw
(
5
)
<<
unit
;
return
ss
.
str
();
};
std
::
cout
<<
"memory: "
<<
std
::
endl
<<
indent
<<
"quota: "
<<
std
::
setw
(
15
)
<<
res
.
ram_quota
<<
" bytes used: "
<<
std
::
setw
(
15
)
<<
res
.
ram_usage
<<
" bytes"
<<
std
::
endl
<<
std
::
endl
;
<<
indent
<<
"quota: "
<<
std
::
setw
(
15
)
<<
to_pretty_net
(
res
.
ram_quota
)
<<
" used: "
<<
std
::
setw
(
15
)
<<
to_pretty_net
(
res
.
ram_usage
)
<<
std
::
endl
<<
std
::
endl
;
std
::
cout
<<
"net bandwidth:"
<<
std
::
endl
;
std
::
cout
<<
"net bandwidth:
(averaged over 3 days)
"
<<
std
::
endl
;
if
(
res
.
total_resources
.
is_object
()
)
{
asset
net_own
(
res
.
delegated_bandwidth
.
is_object
()
?
stoll
(
res
.
delegated_bandwidth
.
get_object
()[
"net_weight"
].
as_string
()
)
:
0
);
auto
net_others
=
to_asset
(
res
.
total_resources
.
get_object
()[
"net_weight"
].
as_string
())
-
net_own
;
...
...
@@ -1207,47 +1231,41 @@ void get_account( const string& accountName, bool json_format ) {
<<
std
::
string
(
11
,
' '
)
<<
"(total staked delegated to account from others)"
<<
std
::
endl
;
}
string
unit
=
"bytes"
;
double
net_usage
=
res
.
net_limit
.
available
;
if
(
res
.
net_limit
.
available
>=
1024
*
1024
*
1024
){
unit
=
"Gb"
;
net_usage
/=
1024
*
1024
*
1024
;
}
else
if
(
res
.
net_limit
.
available
>=
1024
*
1024
){
unit
=
"Mb"
;
net_usage
/=
1024
*
1024
;
}
else
if
(
res
.
net_limit
.
available
>=
1024
)
{
unit
=
"Kb"
;
net_usage
/=
1024
;
}
auto
to_pretty_time
=
[](
double
micro
)
{
string
unit
=
"us"
;
std
::
cout
<<
std
::
fixed
<<
setprecision
(
3
);
std
::
cout
<<
indent
<<
"used:"
<<
std
::
setw
(
15
)
<<
(
"~"
+
std
::
to_string
(
res
.
net_limit
.
used
))
<<
" bytes (past 3 days)"
<<
std
::
string
(
3
,
' '
)
<<
"(assuming current congestion and current usage)"
<<
std
::
endl
<<
indent
<<
"available:"
<<
std
::
setw
(
19
)
<<
(
"~"
+
std
::
to_string
(
net_usage
))
<<
" "
<<
unit
<<
std
::
string
(
3
,
' '
)
<<
"(assuming current congestion and 0 usage in current window)"
<<
std
::
endl
/*
<< indent << "guaranteed: " << std::setw(11) << res.net_limit.guaranteed_per_day << " bytes/day"
<< std::string(5, ' ') << "(assuming 100% congestion and 0 usage in current window)" << std::endl
*/
<<
std
::
endl
;
if
(
micro
>
1000000
*
60
)
{
micro
/=
1000000
*
60
*
60ll
;
unit
=
"hr"
;
}
else
if
(
micro
>
1000000
*
60
)
{
micro
/=
1000000
*
60
;
unit
=
"min"
;
}
else
if
(
micro
>
1000000
)
{
micro
/=
1000000
;
unit
=
"sec"
;
}
else
if
(
micro
>
1000
)
{
micro
/=
1000
;
unit
=
"ms"
;
}
std
::
stringstream
ss
;
ss
<<
setprecision
(
4
);
ss
<<
micro
<<
" "
<<
std
::
left
<<
setw
(
5
)
<<
unit
;
return
ss
.
str
();
};
std
::
cout
<<
"cpu bandwidth:"
<<
std
::
endl
;
std
::
cout
<<
std
::
fixed
<<
setprecision
(
3
);
std
::
cout
<<
indent
<<
std
::
left
<<
std
::
setw
(
11
)
<<
"used:"
<<
std
::
right
<<
std
::
setw
(
18
)
<<
to_pretty_net
(
res
.
net_limit
.
used
)
<<
"
\n
"
;
std
::
cout
<<
indent
<<
std
::
left
<<
std
::
setw
(
11
)
<<
"available:"
<<
std
::
right
<<
std
::
setw
(
18
)
<<
to_pretty_net
(
res
.
net_limit
.
available
)
<<
"
\n
"
;
std
::
cout
<<
indent
<<
std
::
left
<<
std
::
setw
(
11
)
<<
"limit:"
<<
std
::
right
<<
std
::
setw
(
18
)
<<
to_pretty_net
(
res
.
net_limit
.
max
)
<<
"
\n
"
;
std
::
cout
<<
std
::
endl
;
double
cpu_avail
=
res
.
cpu_limit
.
available
/
1000000.
;
string
cunit
=
"sec"
;
if
(
cpu_avail
>
60
*
60
*
24
)
{
cunit
=
"days"
;
cpu_avail
/=
60
*
60
*
24
;
}
else
if
(
cpu_avail
>
60
*
60
)
{
cunit
=
"hr"
;
cpu_avail
/=
60
*
60
;
}
else
if
(
cpu_avail
>
60
)
{
cunit
=
"min"
;
cpu_avail
/=
60
;
}
std
::
cout
<<
"cpu bandwidth: (averaged over 3 days)"
<<
std
::
endl
;
if
(
res
.
total_resources
.
is_object
()
)
{
...
...
@@ -1259,13 +1277,13 @@ void get_account( const string& accountName, bool json_format ) {
<<
std
::
string
(
11
,
' '
)
<<
"(total staked delegated to account from others)"
<<
std
::
endl
;
}
std
::
cout
<<
indent
<<
"used:"
<<
std
::
setw
(
15
)
<<
(
"~"
+
std
::
to_string
(
double
(
res
.
cpu_limit
.
used
/
1000000.
)))
<<
" sec (past 3 days)
\n
"
<<
indent
<<
"available:"
<<
std
::
setw
(
19
)
<<
(
"~"
+
std
::
to_string
(
cpu_avail
)
)
<<
" "
<<
cunit
<<
"
\n
"
/*
<< indent << "guaranteed:" << std::setw(12) << res.cpu_limit.guaranteed_per_day/1024 << " kcycle/day"
<< std::string(4, ' ') << "(assuming 100% congestion and 0 usage in current window)" << std::endl
*/
<<
std
::
endl
;
std
::
cout
<<
std
::
fixed
<<
setprecision
(
3
);
std
::
cout
<<
indent
<<
std
::
left
<<
std
::
setw
(
11
)
<<
"used:"
<<
std
::
right
<<
std
::
setw
(
18
)
<<
to_pretty_time
(
res
.
cpu_limit
.
used
)
<<
"
\n
"
;
std
::
cout
<<
indent
<<
std
::
left
<<
std
::
setw
(
11
)
<<
"available:"
<<
std
::
right
<<
std
::
setw
(
18
)
<<
to_pretty_time
(
res
.
cpu_limit
.
available
)
<<
"
\n
"
;
std
::
cout
<<
indent
<<
std
::
left
<<
std
::
setw
(
11
)
<<
"limit:"
<<
std
::
right
<<
std
::
setw
(
18
)
<<
to_pretty_time
(
res
.
cpu_limit
.
max
)
<<
"
\n
"
;
std
::
cout
<<
std
::
endl
;
if
(
res
.
voter_info
.
is_object
()
)
{
auto
&
obj
=
res
.
voter_info
.
get_object
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录