This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove connected disconnected state, 3rd attempt (#3898)
* overseer: remove mut in connector * rename SelectRelayChainWFallback -> SelectRelayChain * split Basics * introduce the OverseerConnector, use it * introduce is_relay_chain to RelayChainSelection * chore: rename var * avoid dummy import in subsystem * actually remove Disconnecte/Connected enum * extract DummySubsystem into mod dummy. * Handle::Connected -> Handle::new * chore: fmt * fix test * select relay chain takes no arg, simplification * fmt * Update node/service/src/lib.rs Co-authored-by: Andronik Ordian <write@reusable.software> * chore: improve malus tests * avoid the deferred setting of `is_relay_chain` in `RelayChainSelection` * positive assertion is not mandated, only the negative one, to avoid a stall * chore: fmt * assure the `RelayChainSelection` is not used before the overseer is up and running Co-authored-by: Andronik Ordian <write@reusable.software>
- Loading branch information
Showing
18 changed files
with
641 additions
and
331 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright 2020 Parity Technologies (UK) Ltd. | ||
// This file is part of Polkadot. | ||
|
||
// Polkadot is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// Polkadot is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
use crate::{AllMessages, OverseerSignal}; | ||
use polkadot_node_subsystem_types::errors::SubsystemError; | ||
use polkadot_overseer_gen::{FromOverseer, SpawnedSubsystem, Subsystem, SubsystemContext}; | ||
|
||
/// A dummy subsystem that implements [`Subsystem`] for all | ||
/// types of messages. Used for tests or as a placeholder. | ||
#[derive(Clone, Copy, Debug)] | ||
pub struct DummySubsystem; | ||
|
||
impl<Context> Subsystem<Context, SubsystemError> for DummySubsystem | ||
where | ||
Context: SubsystemContext< | ||
Signal = OverseerSignal, | ||
Error = SubsystemError, | ||
AllMessages = AllMessages, | ||
>, | ||
{ | ||
fn start(self, mut ctx: Context) -> SpawnedSubsystem<SubsystemError> { | ||
let future = Box::pin(async move { | ||
loop { | ||
match ctx.recv().await { | ||
Err(_) => return Ok(()), | ||
Ok(FromOverseer::Signal(OverseerSignal::Conclude)) => return Ok(()), | ||
Ok(overseer_msg) => { | ||
tracing::debug!( | ||
target: "dummy-subsystem", | ||
"Discarding a message sent from overseer {:?}", | ||
overseer_msg | ||
); | ||
continue | ||
}, | ||
} | ||
} | ||
}); | ||
|
||
SpawnedSubsystem { name: "dummy-subsystem", future } | ||
} | ||
} |
Oops, something went wrong.