Skip to content

Commit

Permalink
chore: rename getters for shared clients
Browse files Browse the repository at this point in the history
commit-id:9bfa6756
  • Loading branch information
nadin-Starkware committed Nov 14, 2024
1 parent e177200 commit c568306
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 26 deletions.
2 changes: 1 addition & 1 deletion crates/starknet_integration_tests/src/flow_test_setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl FlowTestSetup {
task_executor,
add_tx_http_client,
batcher_storage_file_handle: storage_for_test.batcher_storage_handle,
batcher_client: clients.get_batcher_client().unwrap(),
batcher_client: clients.get_batcher_shared_client().unwrap(),
rpc_storage_file_handle: storage_for_test.rpc_storage_handle,
sequencer_node_handle,
consensus_proposals_channels,
Expand Down
14 changes: 8 additions & 6 deletions crates/starknet_sequencer_node/src/clients.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ pub struct SequencerNodeClients {
/// // Assuming `SequencerNodeClients` struct has fields `batcher_client` and `mempool_client`,
/// // each with methods `get_local_client()` and `get_remote_client()`.
/// impl SequencerNodeClients {
/// pub fn get_batcher_client(&self) -> Option<Arc<dyn BatcherClient>> {
/// pub fn get_batcher_shared_client(&self) -> Option<Arc<dyn BatcherClient>> {
/// get_shared_client!(self, batcher_client)
/// }
///
/// pub fn get_mempool_client(&self) -> Option<Arc<dyn MempoolClient>> {
/// pub fn get_mempool_shared_client(&self) -> Option<Arc<dyn MempoolClient>> {
/// get_shared_client!(self, mempool_client)
/// }
/// }
Expand Down Expand Up @@ -97,19 +97,21 @@ macro_rules! get_shared_client {
}

impl SequencerNodeClients {
pub fn get_batcher_client(&self) -> Option<SharedBatcherClient> {
pub fn get_batcher_shared_client(&self) -> Option<SharedBatcherClient> {
get_shared_client!(self, batcher_client)
}

pub fn get_mempool_client(&self) -> Option<SharedMempoolClient> {
pub fn get_mempool_shared_client(&self) -> Option<SharedMempoolClient> {
get_shared_client!(self, mempool_client)
}

pub fn get_gateway_client(&self) -> Option<SharedGatewayClient> {
pub fn get_gateway_shared_client(&self) -> Option<SharedGatewayClient> {
get_shared_client!(self, gateway_client)
}

pub fn get_mempool_p2p_propagator_client(&self) -> Option<SharedMempoolP2pPropagatorClient> {
pub fn get_mempool_p2p_propagator_shared_client(
&self,
) -> Option<SharedMempoolP2pPropagatorClient> {
get_shared_client!(self, mempool_p2p_propagator_client)
}
}
Expand Down
39 changes: 20 additions & 19 deletions crates/starknet_sequencer_node/src/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub fn create_node_components(
ComponentExecutionMode::LocalExecutionWithRemoteDisabled
| ComponentExecutionMode::LocalExecutionWithRemoteEnabled => {
let mempool_client =
clients.get_mempool_client().expect("Mempool Client should be available");
clients.get_mempool_shared_client().expect("Mempool Client should be available");
Some(create_batcher(config.batcher_config.clone(), mempool_client))
}
ComponentExecutionMode::Disabled | ComponentExecutionMode::Remote => None,
Expand All @@ -44,7 +44,7 @@ pub fn create_node_components(
ComponentExecutionMode::LocalExecutionWithRemoteDisabled
| ComponentExecutionMode::LocalExecutionWithRemoteEnabled => {
let batcher_client =
clients.get_batcher_client().expect("Batcher Client should be available");
clients.get_batcher_shared_client().expect("Batcher Client should be available");
Some(ConsensusManager::new(config.consensus_manager_config.clone(), batcher_client))
}
ComponentExecutionMode::Disabled | ComponentExecutionMode::Remote => None,
Expand All @@ -53,7 +53,7 @@ pub fn create_node_components(
ComponentExecutionMode::LocalExecutionWithRemoteDisabled
| ComponentExecutionMode::LocalExecutionWithRemoteEnabled => {
let mempool_client =
clients.get_mempool_client().expect("Mempool Client should be available");
clients.get_mempool_shared_client().expect("Mempool Client should be available");

Some(create_gateway(
config.gateway_config.clone(),
Expand All @@ -68,33 +68,34 @@ pub fn create_node_components(
ComponentExecutionMode::LocalExecutionWithRemoteDisabled
| ComponentExecutionMode::LocalExecutionWithRemoteEnabled => {
let gateway_client =
clients.get_gateway_client().expect("Gateway Client should be available");
clients.get_gateway_shared_client().expect("Gateway Client should be available");

Some(create_http_server(config.http_server_config.clone(), gateway_client))
}
ComponentExecutionMode::Disabled | ComponentExecutionMode::Remote => None,
};

let (mempool_p2p_propagator, mempool_p2p_runner) =
match config.components.mempool_p2p.execution_mode {
ComponentExecutionMode::LocalExecutionWithRemoteDisabled
| ComponentExecutionMode::LocalExecutionWithRemoteEnabled => {
let gateway_client =
clients.get_gateway_client().expect("Gateway Client should be available");
let (mempool_p2p_propagator, mempool_p2p_runner) = create_p2p_propagator_and_runner(
config.mempool_p2p_config.clone(),
gateway_client,
);
(Some(mempool_p2p_propagator), Some(mempool_p2p_runner))
}
ComponentExecutionMode::Disabled | ComponentExecutionMode::Remote => (None, None),
};
let (mempool_p2p_propagator, mempool_p2p_runner) = match config
.components
.mempool_p2p
.execution_mode
{
ComponentExecutionMode::LocalExecutionWithRemoteDisabled
| ComponentExecutionMode::LocalExecutionWithRemoteEnabled => {
let gateway_client =
clients.get_gateway_shared_client().expect("Gateway Client should be available");
let (mempool_p2p_propagator, mempool_p2p_runner) =
create_p2p_propagator_and_runner(config.mempool_p2p_config.clone(), gateway_client);
(Some(mempool_p2p_propagator), Some(mempool_p2p_runner))
}
ComponentExecutionMode::Disabled | ComponentExecutionMode::Remote => (None, None),
};

let mempool = match config.components.mempool.execution_mode {
ComponentExecutionMode::LocalExecutionWithRemoteDisabled
| ComponentExecutionMode::LocalExecutionWithRemoteEnabled => {
let mempool_p2p_propagator_client = clients
.get_mempool_p2p_propagator_client()
.get_mempool_p2p_propagator_shared_client()
.expect("Propagator Client should be available");
let mempool = create_mempool(mempool_p2p_propagator_client);
Some(mempool)
Expand Down

0 comments on commit c568306

Please sign in to comment.