mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 02:51:08 +00:00
Add some message types from subsystem definitions (#1265)
* introduce polkadot-node-primitives * guide: change statement distribution message types * guide: remove variant from `CandidateSelectionMessage` * add a few more message types * add TODOs * Almost all messages * NewBackedCandidate notification * Formatting * Use AttestedCandidate as BackedCandidate * Update node/primitives/src/lib.rs Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com> * Fix the tests * Bring in types from #1242 * Adds network bridge messages * More message types from doc * use fn pointer type * Fixes from the review * Add missing Runtime subsystem message * rename to CandidateValidationMessage and fix tests Co-authored-by: Fedor Sakharov <fedor.sakharov@gmail.com> Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
87ae6e42f5
commit
c226c4403d
@@ -20,22 +20,24 @@
|
||||
|
||||
use std::time::Duration;
|
||||
use futures::{
|
||||
channel::oneshot,
|
||||
pending, pin_mut, executor, select, stream,
|
||||
FutureExt, StreamExt,
|
||||
};
|
||||
use futures_timer::Delay;
|
||||
use kv_log_macro as log;
|
||||
|
||||
use polkadot_primitives::parachain::{BlockData, PoVBlock};
|
||||
use polkadot_overseer::{Overseer, Subsystem, SubsystemContext, SpawnedSubsystem};
|
||||
|
||||
use messages::{
|
||||
AllMessages, CandidateBackingSubsystemMessage, FromOverseer, ValidationSubsystemMessage
|
||||
AllMessages, CandidateBackingMessage, FromOverseer, CandidateValidationMessage
|
||||
};
|
||||
|
||||
struct Subsystem1;
|
||||
|
||||
impl Subsystem1 {
|
||||
async fn run(mut ctx: SubsystemContext<CandidateBackingSubsystemMessage>) {
|
||||
async fn run(mut ctx: SubsystemContext<CandidateBackingMessage>) {
|
||||
loop {
|
||||
match ctx.try_recv().await {
|
||||
Ok(Some(msg)) => {
|
||||
@@ -52,15 +54,24 @@ impl Subsystem1 {
|
||||
}
|
||||
|
||||
Delay::new(Duration::from_secs(1)).await;
|
||||
ctx.send_msg(AllMessages::Validation(
|
||||
ValidationSubsystemMessage::ValidityAttestation
|
||||
let (tx, _) = oneshot::channel();
|
||||
|
||||
ctx.send_msg(AllMessages::CandidateValidation(
|
||||
CandidateValidationMessage::Validate(
|
||||
Default::default(),
|
||||
Default::default(),
|
||||
PoVBlock {
|
||||
block_data: BlockData(Vec::new()),
|
||||
},
|
||||
tx,
|
||||
)
|
||||
)).await.unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Subsystem<CandidateBackingSubsystemMessage> for Subsystem1 {
|
||||
fn start(&mut self, ctx: SubsystemContext<CandidateBackingSubsystemMessage>) -> SpawnedSubsystem {
|
||||
impl Subsystem<CandidateBackingMessage> for Subsystem1 {
|
||||
fn start(&mut self, ctx: SubsystemContext<CandidateBackingMessage>) -> SpawnedSubsystem {
|
||||
SpawnedSubsystem(Box::pin(async move {
|
||||
Self::run(ctx).await;
|
||||
}))
|
||||
@@ -70,7 +81,7 @@ impl Subsystem<CandidateBackingSubsystemMessage> for Subsystem1 {
|
||||
struct Subsystem2;
|
||||
|
||||
impl Subsystem2 {
|
||||
async fn run(mut ctx: SubsystemContext<ValidationSubsystemMessage>) {
|
||||
async fn run(mut ctx: SubsystemContext<CandidateValidationMessage>) {
|
||||
ctx.spawn(Box::pin(async {
|
||||
loop {
|
||||
log::info!("Job tick");
|
||||
@@ -94,8 +105,8 @@ impl Subsystem2 {
|
||||
}
|
||||
}
|
||||
|
||||
impl Subsystem<ValidationSubsystemMessage> for Subsystem2 {
|
||||
fn start(&mut self, ctx: SubsystemContext<ValidationSubsystemMessage>) -> SpawnedSubsystem {
|
||||
impl Subsystem<CandidateValidationMessage> for Subsystem2 {
|
||||
fn start(&mut self, ctx: SubsystemContext<CandidateValidationMessage>) -> SpawnedSubsystem {
|
||||
SpawnedSubsystem(Box::pin(async move {
|
||||
Self::run(ctx).await;
|
||||
}))
|
||||
|
||||
Reference in New Issue
Block a user