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
e83d6c6f
Commit
e83d6c6f
authored
5 years ago
by
Pierre Krieger
Committed by
André Silva
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add a warning if network is too slow (#3160)
parent
08d19331
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
substrate/core/service/src/lib.rs
+20
-6
20 additions, 6 deletions
substrate/core/service/src/lib.rs
with
20 additions
and
6 deletions
substrate/core/service/src/lib.rs
+
20
−
6
View file @
e83d6c6f
...
...
@@ -29,7 +29,7 @@ use std::io;
use
std
::
marker
::
PhantomData
;
use
std
::
net
::
SocketAddr
;
use
std
::
collections
::
HashMap
;
use
std
::
time
::
Duration
;
use
std
::
time
::
{
Duration
,
Instant
}
;
use
futures
::
sync
::
mpsc
;
use
parking_lot
::
Mutex
;
...
...
@@ -39,7 +39,7 @@ use futures::prelude::*;
use
futures03
::
stream
::{
StreamExt
as
_
,
TryStreamExt
as
_
};
use
keystore
::
Store
as
Keystore
;
use
network
::{
NetworkState
,
NetworkStateInfo
};
use
log
::{
info
,
warn
,
debug
,
error
};
use
log
::{
log
,
info
,
warn
,
debug
,
error
,
Level
};
use
parity_codec
::{
Encode
,
Decode
};
use
primitives
::{
Pair
,
ed25519
,
crypto
};
use
runtime_primitives
::
generic
::
BlockId
;
...
...
@@ -647,6 +647,8 @@ fn build_network_future<
.map
(|
v
|
Ok
::
<
_
,
()
>
(
v
))
.compat
();
futures
::
future
::
poll_fn
(
move
||
{
let
before_polling
=
Instant
::
now
();
// We poll `imported_blocks_stream`.
while
let
Ok
(
Async
::
Ready
(
Some
(
notification
)))
=
imported_blocks_stream
.poll
()
{
network
.on_block_imported
(
notification
.hash
,
notification
.header
);
...
...
@@ -705,10 +707,22 @@ fn build_network_future<
}
// Main network polling.
network
.poll
()
.map_err
(|
err
|
{
warn!
(
target
:
"service"
,
"Error in network: {:?}"
,
err
);
})
match
network
.poll
()
{
Ok
(
Async
::
NotReady
)
=>
{}
Err
(
err
)
=>
warn!
(
target
:
"service"
,
"Error in network: {:?}"
,
err
),
Ok
(
Async
::
Ready
(()))
=>
warn!
(
target
:
"service"
,
"Network service finished"
),
}
// Now some diagnostic for performances.
let
polling_dur
=
before_polling
.elapsed
();
log
!
(
target
:
"service"
,
if
polling_dur
>=
Duration
::
from_millis
(
50
)
{
Level
::
Warn
}
else
{
Level
::
Trace
},
"Polling the network future took {:?}"
,
polling_dur
);
Ok
(
Async
::
NotReady
)
})
}
...
...
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