mirror of
https://github.com/logos-blockchain/logos-blockchain-testing.git
synced 2026-03-31 08:13:48 +00:00
Make scenario source transitions explicit
This commit is contained in:
parent
6888c18275
commit
3f8e287c68
@ -569,13 +569,13 @@ impl<E: Application, Caps> Builder<E, Caps> {
|
||||
|
||||
#[must_use]
|
||||
pub fn with_attach_source(mut self, attach: AttachSource) -> Self {
|
||||
self.sources.set_attach(attach);
|
||||
self.sources = self.sources.with_attach(attach);
|
||||
self
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn with_external_node(mut self, node: ExternalNodeSource) -> Self {
|
||||
self.sources.add_external_node(node);
|
||||
self.sources = self.sources.with_external_node(node);
|
||||
self
|
||||
}
|
||||
|
||||
@ -591,7 +591,7 @@ impl<E: Application, Caps> Builder<E, Caps> {
|
||||
|
||||
#[must_use]
|
||||
pub fn with_external_only_sources(mut self) -> Self {
|
||||
self.sources.set_external_only();
|
||||
self.sources = self.sources.into_external_only();
|
||||
self
|
||||
}
|
||||
|
||||
|
||||
@ -128,22 +128,29 @@ impl ScenarioSources {
|
||||
Self::ExternalOnly { external }
|
||||
}
|
||||
|
||||
pub(crate) fn add_external_node(&mut self, node: ExternalNodeSource) {
|
||||
match self {
|
||||
#[must_use]
|
||||
pub fn with_external_node(mut self, node: ExternalNodeSource) -> Self {
|
||||
match &mut self {
|
||||
Self::Managed { external }
|
||||
| Self::Attached { external, .. }
|
||||
| Self::ExternalOnly { external } => external.push(node),
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub(crate) fn set_attach(&mut self, attach: AttachSource) {
|
||||
#[must_use]
|
||||
pub fn with_attach(self, attach: AttachSource) -> Self {
|
||||
let external = self.external_nodes().to_vec();
|
||||
*self = Self::Attached { attach, external };
|
||||
|
||||
Self::Attached { attach, external }
|
||||
}
|
||||
|
||||
pub(crate) fn set_external_only(&mut self) {
|
||||
#[must_use]
|
||||
pub fn into_external_only(self) -> Self {
|
||||
let external = self.external_nodes().to_vec();
|
||||
*self = Self::ExternalOnly { external };
|
||||
|
||||
Self::ExternalOnly { external }
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user