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
586dce10
Commit
586dce10
authored
5 years ago
by
Pierre Krieger
Committed by
Gavin Wood
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Simplify the code of connection_keep_alive (#2438)
parent
1761a7fc
Branches
gh-readonly-queue/master/pr-4276-3a20232337410c36eeb9929136f96b9a703ccdf8
Branches containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
substrate/core/network-libp2p/src/custom_proto/handler.rs
+4
-21
4 additions, 21 deletions
substrate/core/network-libp2p/src/custom_proto/handler.rs
with
4 additions
and
21 deletions
substrate/core/network-libp2p/src/custom_proto/handler.rs
+
4
−
21
View file @
586dce10
...
...
@@ -27,7 +27,7 @@ use libp2p::core::{
};
use
log
::{
debug
,
error
};
use
smallvec
::{
smallvec
,
SmallVec
};
use
std
::{
borrow
::
Cow
,
error
,
fmt
,
io
,
marker
::
PhantomData
,
mem
,
time
::
Duration
,
time
::
Instant
};
use
std
::{
borrow
::
Cow
,
error
,
fmt
,
io
,
marker
::
PhantomData
,
mem
,
time
::
Duration
};
use
tokio_io
::{
AsyncRead
,
AsyncWrite
};
use
tokio_timer
::{
Delay
,
clock
::
Clock
};
use
void
::
Void
;
...
...
@@ -125,7 +125,6 @@ where
init_deadline
:
Delay
::
new
(
clock
.now
()
+
Duration
::
from_secs
(
5
))
},
events_queue
:
SmallVec
::
new
(),
warm_up_end
:
clock
.now
()
+
Duration
::
from_secs
(
5
),
clock
,
}
}
...
...
@@ -149,10 +148,6 @@ pub struct CustomProtoHandler<TMessage, TSubstream> {
/// element.
events_queue
:
SmallVec
<
[
ProtocolsHandlerEvent
<
RegisteredProtocol
<
TMessage
>
,
(),
CustomProtoHandlerOut
<
TMessage
>>
;
16
]
>
,
/// We have a warm-up period after creating the handler during which we don't shut down the
/// connection.
warm_up_end
:
Instant
,
/// `Clock` instance that uses the current execution context's source of time.
clock
:
Clock
,
}
...
...
@@ -579,22 +574,10 @@ where TSubstream: AsyncRead + AsyncWrite, TMessage: CustomMessage {
}
fn
connection_keep_alive
(
&
self
)
->
KeepAlive
{
if
self
.warm_up_end
>=
self
.clock
.now
()
{
return
KeepAlive
::
Until
(
self
.warm_up_end
)
}
let
mut
keep_forever
=
false
;
match
self
.state
{
ProtocolState
::
Init
{
..
}
|
ProtocolState
::
Opening
{
..
}
=>
{}
ProtocolState
::
Normal
{
..
}
=>
keep_forever
=
true
,
ProtocolState
::
Disabled
{
..
}
|
ProtocolState
::
Poisoned
=>
return
KeepAlive
::
No
,
}
if
keep_forever
{
KeepAlive
::
Yes
}
else
{
KeepAlive
::
No
ProtocolState
::
Init
{
..
}
|
ProtocolState
::
Opening
{
..
}
|
ProtocolState
::
Normal
{
..
}
=>
KeepAlive
::
Yes
,
ProtocolState
::
Disabled
{
..
}
|
ProtocolState
::
Poisoned
=>
KeepAlive
::
No
,
}
}
...
...
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