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
e296cf8c
Commit
e296cf8c
authored
5 years ago
by
Svyatoslav Nikolsky
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
fix panic in PSM when add_reserved_peer(same_peer) is called twice (#2640)
parent
b9c39d77
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
substrate/core/peerset/src/peersstate.rs
+16
-0
16 additions, 0 deletions
substrate/core/peerset/src/peersstate.rs
with
16 additions
and
0 deletions
substrate/core/peerset/src/peersstate.rs
+
16
−
0
View file @
e296cf8c
...
...
@@ -291,6 +291,10 @@ impl<'a> ConnectedPeer<'a> {
/// Sets whether or not the node is reserved.
pub
fn
set_reserved
(
&
mut
self
,
reserved
:
bool
)
{
if
reserved
==
self
.state.reserved
{
return
;
}
if
reserved
{
self
.state.reserved
=
true
;
match
self
.state.connection_state
{
...
...
@@ -595,4 +599,16 @@ mod tests {
peer
.set_reserved
(
true
);
peer
.disconnect
();
}
#[test]
fn
multiple_set_reserved_calls_doesnt_panic
()
{
let
mut
peers_state
=
PeersState
::
new
(
1
,
1
);
let
id
=
PeerId
::
random
();
let
mut
peer
=
peers_state
.peer
(
&
id
)
.into_unknown
()
.unwrap
()
.discover
()
.force_outgoing
();
peer
.set_reserved
(
true
);
peer
.set_reserved
(
true
);
peer
.disconnect
();
}
}
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