Skip to content

Commit

Permalink
feat: add functionality to create all servers
Browse files Browse the repository at this point in the history
commit-id:0f64f96b
  • Loading branch information
lev-starkware committed Jun 27, 2024
1 parent a9656f4 commit 90919ee
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/mempool_node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ workspace = true
clap.workspace = true
const_format.workspace = true
starknet_gateway = { path = "../gateway", version = "0.0" }
starknet_mempool_infra = { path = "../mempool_infra", version = "0.0" }
starknet_mempool = { path = "../mempool", version = "0.0" }
starknet_mempool_types = { path = "../mempool_types", version = "0.0" }
serde.workspace = true
Expand Down
1 change: 1 addition & 0 deletions crates/mempool_node/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub mod communication;
pub mod components;
pub mod config;
pub mod servers;
pub mod version;
41 changes: 41 additions & 0 deletions crates/mempool_node/src/servers.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// use std::future::pending;
// use std::pin::Pin;

// use futures::{Future, FutureExt};
use starknet_gateway::gateway::create_gateway_server;
use starknet_mempool::communication::create_mempool_server;
use starknet_mempool_infra::component_server::CommunicationServer;

use crate::communication::MempoolNodeCommunication;
use crate::components::Components;
use crate::config::MempoolNodeConfig;

pub struct Servers {
pub gateway: Option<Box<dyn CommunicationServer>>,
pub mempool: Option<Box<dyn CommunicationServer>>,
}

pub fn create_servers(
config: &MempoolNodeConfig,
mut channels: MempoolNodeCommunication,
components: Components,
) -> Servers {
let mut servers = Servers { gateway: None, mempool: None };

if config.components.gateway_component.execute {
servers.gateway = Some(Box::new(create_gateway_server(
components.gateway.expect("Gateway component is not initialized."),
)));
}

if config.components.mempool_component.execute {
servers.mempool = Some(Box::new(create_mempool_server(
components.mempool.expect("Mempool component is not initialized."),
channels.take_mempool_rx(),
)));
}

servers
}

// TODO (Lev): Implement the run server components function.

0 comments on commit 90919ee

Please sign in to comment.