-
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
77f752c
commit ddc76ad
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 starknet_gateway::communication::create_gateway_server; | ||
use starknet_mempool::communication::create_mempool_server; | ||
use starknet_mempool_infra::component_server::ComponentServerStarter; | ||
|
||
use crate::communication::MempoolNodeCommunication; | ||
use crate::components::Components; | ||
use crate::config::MempoolNodeConfig; | ||
|
||
pub struct Servers { | ||
pub gateway: Option<Box<dyn ComponentServerStarter>>, | ||
pub mempool: Option<Box<dyn ComponentServerStarter>>, | ||
} | ||
|
||
pub fn create_servers( | ||
config: &MempoolNodeConfig, | ||
mut communication: MempoolNodeCommunication, | ||
components: Components, | ||
) -> Servers { | ||
let gateway_server: Option<Box<dyn ComponentServerStarter>> = | ||
if config.components.gateway_component.execute { | ||
Some(Box::new(create_gateway_server( | ||
components.gateway.expect("Gateway is not initialized."), | ||
))) | ||
} else { | ||
None | ||
}; | ||
|
||
let mempool_server: Option<Box<dyn ComponentServerStarter>> = | ||
if config.components.mempool_component.execute { | ||
Some(Box::new(create_mempool_server( | ||
components.mempool.expect("Mempool is not initialized."), | ||
communication.take_mempool_rx(), | ||
))) | ||
} else { | ||
None | ||
}; | ||
|
||
Servers { gateway: gateway_server, mempool: mempool_server } | ||
} | ||
|
||
// TODO (Lev): Implement the run server components function. |