Files
pezkuwi-sdk/pezkuwi/node/subsystem-bench/src/lib/mock/approval_voting_parallel.rs
T
pezkuwichain abc4c3989b style: Migrate to stable-only rustfmt configuration
- Remove nightly-only features from .rustfmt.toml and vendor/ss58-registry/rustfmt.toml
- Removed features: imports_granularity, wrap_comments, comment_width,
  reorder_impl_items, spaces_around_ranges, binop_separator,
  match_arm_blocks, trailing_semicolon, trailing_comma
- Format all 898 affected files with stable rustfmt
- Ensures long-term reliability without nightly toolchain dependency
2025-12-23 09:37:11 +03:00

66 lines
2.2 KiB
Rust

// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi 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.
// Pezkuwi 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 Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! A generic mock approval voting parallel suitable to be used in benchmarks.
use futures::FutureExt;
use pezkuwi_node_subsystem::{
messages::ApprovalVotingParallelMessage, overseer, SpawnedSubsystem, SubsystemError,
};
use pezkuwi_node_subsystem_types::OverseerSignal;
const LOG_TARGET: &str = "subsystem-bench::approval-voting-parallel-mock";
pub struct MockApprovalVotingParallel {}
impl MockApprovalVotingParallel {
pub fn new() -> Self {
Self {}
}
}
#[overseer::subsystem(ApprovalVotingParallel, error=SubsystemError, prefix=self::overseer)]
impl<Context> MockApprovalVotingParallel {
fn start(self, ctx: Context) -> SpawnedSubsystem {
let future = self.run(ctx).map(|_| Ok(())).boxed();
SpawnedSubsystem { name: "test-environment", future }
}
}
#[overseer::contextbounds(ApprovalVotingParallel, prefix = self::overseer)]
impl MockApprovalVotingParallel {
async fn run<Context>(self, mut ctx: Context) {
loop {
let msg = ctx.recv().await.expect("Overseer never fails us");
match msg {
orchestra::FromOrchestra::Signal(signal) => {
if signal == OverseerSignal::Conclude {
return;
}
},
orchestra::FromOrchestra::Communication { msg } => match msg {
ApprovalVotingParallelMessage::GetApprovalSignaturesForCandidate(hash, tx) => {
gum::debug!(target: LOG_TARGET, "GetApprovalSignaturesForCandidate for candidate {:?}", hash);
tx.send(Default::default()).unwrap();
},
_ => todo!("Subsystem received unexpected message, {:?}", msg),
},
}
}
}
}