-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add functionality to create all servers
commit-id:0f64f96b
- Loading branch information
1 parent
5fa98c3
commit 778c186
Showing
4 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |