sc_consensus_subspace/
lib.rs#![feature(let_chains, try_blocks)]
#![feature(duration_constructors)]
#![forbid(unsafe_code)]
#![warn(missing_docs)]
pub mod archiver;
pub mod aux_schema;
pub mod block_import;
pub mod notification;
pub mod slot_worker;
#[cfg(test)]
mod tests;
pub mod verifier;
use crate::archiver::{ArchivedSegmentNotification, ObjectMappingNotification};
use crate::block_import::BlockImportingNotification;
use crate::notification::{SubspaceNotificationSender, SubspaceNotificationStream};
use crate::slot_worker::{NewSlotNotification, RewardSigningNotification};
use sp_consensus_subspace::ChainConstants;
use sp_runtime::traits::Block as BlockT;
use subspace_erasure_coding::ErasureCoding;
use subspace_kzg::Kzg;
#[derive(Clone)]
pub struct SubspaceLink<Block: BlockT> {
new_slot_notification_sender: SubspaceNotificationSender<NewSlotNotification>,
new_slot_notification_stream: SubspaceNotificationStream<NewSlotNotification>,
reward_signing_notification_sender: SubspaceNotificationSender<RewardSigningNotification>,
reward_signing_notification_stream: SubspaceNotificationStream<RewardSigningNotification>,
object_mapping_notification_sender: SubspaceNotificationSender<ObjectMappingNotification>,
object_mapping_notification_stream: SubspaceNotificationStream<ObjectMappingNotification>,
archived_segment_notification_sender: SubspaceNotificationSender<ArchivedSegmentNotification>,
archived_segment_notification_stream: SubspaceNotificationStream<ArchivedSegmentNotification>,
block_importing_notification_sender:
SubspaceNotificationSender<BlockImportingNotification<Block>>,
block_importing_notification_stream:
SubspaceNotificationStream<BlockImportingNotification<Block>>,
chain_constants: ChainConstants,
kzg: Kzg,
erasure_coding: ErasureCoding,
}
impl<Block: BlockT> SubspaceLink<Block> {
pub fn new(chain_constants: ChainConstants, kzg: Kzg, erasure_coding: ErasureCoding) -> Self {
let (new_slot_notification_sender, new_slot_notification_stream) =
notification::channel("subspace_new_slot_notification_stream");
let (reward_signing_notification_sender, reward_signing_notification_stream) =
notification::channel("subspace_reward_signing_notification_stream");
let (object_mapping_notification_sender, object_mapping_notification_stream) =
notification::channel("subspace_object_mapping_notification_stream");
let (archived_segment_notification_sender, archived_segment_notification_stream) =
notification::channel("subspace_archived_segment_notification_stream");
let (block_importing_notification_sender, block_importing_notification_stream) =
notification::channel("subspace_block_importing_notification_stream");
Self {
new_slot_notification_sender,
new_slot_notification_stream,
reward_signing_notification_sender,
reward_signing_notification_stream,
object_mapping_notification_sender,
object_mapping_notification_stream,
archived_segment_notification_sender,
archived_segment_notification_stream,
block_importing_notification_sender,
block_importing_notification_stream,
chain_constants,
kzg,
erasure_coding,
}
}
pub fn new_slot_notification_stream(&self) -> SubspaceNotificationStream<NewSlotNotification> {
self.new_slot_notification_stream.clone()
}
pub fn reward_signing_notification_stream(
&self,
) -> SubspaceNotificationStream<RewardSigningNotification> {
self.reward_signing_notification_stream.clone()
}
pub fn object_mapping_notification_stream(
&self,
) -> SubspaceNotificationStream<ObjectMappingNotification> {
self.object_mapping_notification_stream.clone()
}
pub fn archived_segment_notification_stream(
&self,
) -> SubspaceNotificationStream<ArchivedSegmentNotification> {
self.archived_segment_notification_stream.clone()
}
pub fn block_importing_notification_stream(
&self,
) -> SubspaceNotificationStream<BlockImportingNotification<Block>> {
self.block_importing_notification_stream.clone()
}
pub fn chain_constants(&self) -> &ChainConstants {
&self.chain_constants
}
pub fn kzg(&self) -> &Kzg {
&self.kzg
}
pub fn erasure_coding(&self) -> &ErasureCoding {
&self.erasure_coding
}
}