Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Z
zombienet-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
zombienet-sdk
Commits
3d36d461
Unverified
Commit
3d36d461
authored
11 months ago
by
Javier Viola
Committed by
GitHub
11 months ago
Browse files
Options
Downloads
Patches
Plain Diff
remove hashmap `nodes_by_name` (#193)
based on #190 cc:
@s0me0ne-unkn0wn
parent
043345ef
Branches
Branches containing commit
No related merge requests found
Pipeline
#457515
passed with stage
in 16 minutes and 4 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
crates/orchestrator/src/network.rs
+31
-8
31 additions, 8 deletions
crates/orchestrator/src/network.rs
with
31 additions
and
8 deletions
crates/orchestrator/src/network.rs
+
31
−
8
View file @
3d36d461
...
...
@@ -122,7 +122,7 @@ impl<T: FileSystem> Network<T> {
let
name
=
name
.into
();
let
relaychain
=
self
.relaychain
();
if
self
.nodes_
by_name
.contains_key
(
&
name
)
{
if
self
.nodes_
iter
()
.any
(|
n
|
n
.name
==
name
)
{
return
Err
(
anyhow
::
anyhow!
(
"Name: {} is already used."
,
name
));
}
...
...
@@ -178,10 +178,8 @@ impl<T: FileSystem> Network<T> {
// // tx_helper::validator_actions::register(vec![&node], &running_node.ws_uri, None).await?;
// }
// Add node to
the global hash
// Add node to
relaychain data
self
.add_running_node
(
node
.clone
(),
None
);
// add node to relay
self
.relay.nodes
.push
(
node
);
Ok
(())
}
...
...
@@ -487,14 +485,14 @@ impl<T: FileSystem> Network<T> {
// remove_parachain()
pub
fn
get_node
(
&
self
,
name
:
impl
Into
<
String
>
)
->
Result
<&
NetworkNode
,
anyhow
::
Error
>
{
let
name
=
&
name
.into
();
if
let
Some
(
node
)
=
self
.nodes_
by_name
.get
(
name
)
{
let
name
=
name
.into
();
if
let
Some
(
node
)
=
self
.nodes_
iter
()
.find
(|
&
n
|
n
.name
==
name
)
{
return
Ok
(
node
);
}
let
list
=
self
.nodes_
by_name
.
keys
(
)
.nodes_
iter
()
.
map
(|
n
|
&
n
.name
)
.cloned
()
.collect
::
<
Vec
<
_
>>
()
.join
(
", "
);
...
...
@@ -504,6 +502,16 @@ impl<T: FileSystem> Network<T> {
))
}
pub
fn
get_node_mut
(
&
mut
self
,
name
:
impl
Into
<
String
>
,
)
->
Result
<&
mut
NetworkNode
,
anyhow
::
Error
>
{
let
name
=
name
.into
();
self
.nodes_iter_mut
()
.find
(|
n
|
n
.name
==
name
)
.ok_or
(
anyhow
::
anyhow!
(
"can't find node with name: {name:?}"
))
}
pub
fn
nodes
(
&
self
)
->
Vec
<&
NetworkNode
>
{
self
.nodes_by_name
.values
()
.collect
::
<
Vec
<&
NetworkNode
>>
()
}
...
...
@@ -544,4 +552,19 @@ impl<T: FileSystem> Network<T> {
pub
(
crate
)
fn
parachains
(
&
self
)
->
Vec
<&
Parachain
>
{
self
.parachains
.values
()
.collect
()
}
pub
(
crate
)
fn
nodes_iter
(
&
self
)
->
impl
Iterator
<
Item
=
&
NetworkNode
>
{
self
.relay
.nodes
.iter
()
.chain
(
self
.parachains
.values
()
.flat_map
(|
p
|
&
p
.collators
))
}
pub
(
crate
)
fn
nodes_iter_mut
(
&
mut
self
)
->
impl
Iterator
<
Item
=
&
mut
NetworkNode
>
{
self
.relay.nodes
.iter_mut
()
.chain
(
self
.parachains
.iter_mut
()
.flat_map
(|(
_
,
p
)|
&
mut
p
.collators
),
)
}
}
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