Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
polkadot-sdk
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
parity
Mirrored projects
polkadot-sdk
Commits
350f2e66
Commit
350f2e66
authored
6 years ago
by
Gav Wood
Committed by
asynchronous rob
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Td bps (#527)
* Add blocks per second to informant. * Add some colours.
parent
9d88d868
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
substrate/substrate/cli/src/informant.rs
+39
-7
39 additions, 7 deletions
substrate/substrate/cli/src/informant.rs
with
39 additions
and
7 deletions
substrate/substrate/cli/src/informant.rs
+
39
−
7
View file @
350f2e66
...
...
@@ -16,6 +16,7 @@
//! Console informant. Prints sync progress and block events. Runs on the calling thread.
use
ansi_term
::
Colour
;
use
std
::
time
::{
Duration
,
Instant
};
use
futures
::{
Future
,
Stream
};
use
service
::{
Service
,
Components
};
...
...
@@ -38,6 +39,7 @@ pub fn start<C>(service: &Service<C>, exit: ::exit_future::Exit, handle: TaskExe
let
network
=
service
.network
();
let
client
=
service
.client
();
let
txpool
=
service
.extrinsic_pool
();
let
mut
last_number
=
None
;
let
display_notifications
=
interval
.map_err
(|
e
|
debug!
(
"Timer error: {:?}"
,
e
))
.for_each
(
move
|
_
|
{
let
sync_status
=
network
.status
();
...
...
@@ -45,15 +47,32 @@ pub fn start<C>(service: &Service<C>, exit: ::exit_future::Exit, handle: TaskExe
if
let
Ok
(
best_block
)
=
client
.best_block_header
()
{
let
hash
=
best_block
.hash
();
let
num_peers
=
sync_status
.num_peers
;
let
status
=
match
(
sync_status
.sync.state
,
sync_status
.sync.best_seen_block
)
{
(
SyncState
::
Idle
,
_
)
=>
"Idle"
.into
(),
(
SyncState
::
Downloading
,
None
)
=>
"Syncing"
.into
(),
(
SyncState
::
Downloading
,
Some
(
n
))
=>
format!
(
"Syncing, target=#{}"
,
n
),
let
best_number
:
u64
=
best_block
.number
()
.as_
();
let
speed
=
move
||
speed
(
best_number
,
last_number
);
let
(
status
,
target
)
=
match
(
sync_status
.sync.state
,
sync_status
.sync.best_seen_block
)
{
(
SyncState
::
Idle
,
_
)
=>
(
"Idle"
.into
(),
""
.into
()),
(
SyncState
::
Downloading
,
None
)
=>
(
format!
(
"Syncing{}"
,
speed
()),
""
.into
()),
(
SyncState
::
Downloading
,
Some
(
n
))
=>
(
format!
(
"Syncing{}"
,
speed
()),
format!
(
", target=#{}"
,
n
)),
};
last_number
=
Some
(
best_number
);
let
txpool_status
=
txpool
.light_status
();
let
best_number
:
u64
=
best_block
.number
()
.as_
();
info!
(
target
:
"substrate"
,
"{} ({} peers), best: #{} ({})"
,
status
,
sync_status
.num_peers
,
best_number
,
hash
);
telemetry!
(
"system.interval"
;
"status"
=>
status
,
"peers"
=>
num_peers
,
"height"
=>
best_number
,
"best"
=>
?
hash
,
"txcount"
=>
txpool_status
.transaction_count
);
info!
(
target
:
"substrate"
,
"{}{} ({} peers), best: #{} ({})"
,
Colour
::
White
.bold
()
.paint
(
&
status
),
target
,
Colour
::
White
.bold
()
.paint
(
format!
(
"{}"
,
sync_status
.num_peers
)),
Colour
::
White
.paint
(
format!
(
"{}"
,
best_number
)),
hash
);
telemetry!
(
"system.interval"
;
"status"
=>
format!
(
"{}{}"
,
status
,
target
),
"peers"
=>
num_peers
,
"height"
=>
best_number
,
"best"
=>
?
hash
,
"txcount"
=>
txpool_status
.transaction_count
);
}
else
{
warn!
(
"Error getting best block information"
);
}
...
...
@@ -77,3 +96,16 @@ pub fn start<C>(service: &Service<C>, exit: ::exit_future::Exit, handle: TaskExe
handle
.spawn
(
exit
.until
(
informant_work
)
.map
(|
_
|
()));
}
fn
speed
(
best_number
:
u64
,
last_number
:
Option
<
u64
>
)
->
String
{
let
speed
=
match
last_number
{
Some
(
num
)
=>
(
best_number
.saturating_sub
(
num
)
*
10_000
/
TIMER_INTERVAL_MS
)
as
f64
,
None
=>
0.0
};
if
speed
<
1.0
{
""
.into
()
}
else
{
format!
(
" {:4.1} bps"
,
speed
/
10.0
)
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment