Skip to content

Commit

Permalink
feat: Migrate to new SEDA-based sources (#481)
Browse files Browse the repository at this point in the history
  • Loading branch information
scarmuega authored Nov 24, 2022
1 parent d1ef44c commit fad5a41
Show file tree
Hide file tree
Showing 15 changed files with 823 additions and 1,180 deletions.
338 changes: 0 additions & 338 deletions src/sources/common.rs

This file was deleted.

53 changes: 51 additions & 2 deletions src/sources/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,55 @@
mod common;
use gasket::messaging::OutputPort;
use serde::Deserialize;

use crate::{bootstrap, crosscut, model, storage};

#[cfg(target_family = "unix")]
pub mod n2c;

pub mod n2n;
pub mod utils;

#[derive(Deserialize)]
#[serde(tag = "type")]
pub enum Config {
N2N(n2n::Config),

#[cfg(target_family = "unix")]
N2C(n2c::Config),
}

impl Config {
pub fn bootstrapper(
self,
chain: &crosscut::ChainWellKnownInfo,
intersect: &crosscut::IntersectConfig,
finalize: &Option<crosscut::FinalizeConfig>,
policy: &crosscut::policies::RuntimePolicy,
) -> Bootstrapper {
match self {
Config::N2N(c) => Bootstrapper::N2N(c.bootstrapper(chain, intersect, finalize, policy)),
Config::N2C(c) => Bootstrapper::N2C(c.bootstrapper(chain, intersect, finalize, policy)),
}
}
}

pub enum Bootstrapper {
N2N(n2n::Bootstrapper),
N2C(n2c::Bootstrapper),
}

impl Bootstrapper {
pub fn borrow_output_port(&mut self) -> &'_ mut OutputPort<model::RawBlockPayload> {
match self {
Bootstrapper::N2N(p) => p.borrow_output_port(),
Bootstrapper::N2C(p) => p.borrow_output_port(),
}
}

pub use common::*;
pub fn spawn_stages(self, pipeline: &mut bootstrap::Pipeline, cursor: storage::Cursor) {
match self {
Bootstrapper::N2N(p) => p.spawn_stages(pipeline, cursor),
Bootstrapper::N2C(p) => p.spawn_stages(pipeline, cursor),
}
}
}
Loading

0 comments on commit fad5a41

Please sign in to comment.