Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add client getters #2035

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 39 additions & 1 deletion crates/starknet_sequencer_node/src/clients.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use starknet_mempool_types::communication::{
RemoteMempoolClient,
SharedMempoolClient,
};
use starknet_sequencer_infra::component_client::Client;
use starknet_sequencer_infra::component_client::{Client, LocalComponentClient};

use crate::communication::SequencerNodeCommunication;
use crate::config::component_execution_config::ComponentExecutionMode;
Expand Down Expand Up @@ -92,24 +92,62 @@ macro_rules! get_shared_client {
}};
}

// TODO(Nadin): Refactor getters to remove code duplication.
impl SequencerNodeClients {
pub fn get_batcher_shared_client(&self) -> Option<SharedBatcherClient> {
get_shared_client!(self, batcher_client)
}

pub fn get_batcher_local_client(
&self,
) -> Option<LocalComponentClient<BatcherRequest, BatcherResponse>> {
match &self.batcher_client {
Some(client) => client.get_local_client(),
None => None,
}
}

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

pub fn get_mempool_local_client(
&self,
) -> Option<LocalComponentClient<MempoolRequest, MempoolResponse>> {
match &self.mempool_client {
Some(client) => client.get_local_client(),
None => None,
}
}

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

pub fn get_gateway_local_client(
&self,
) -> Option<LocalComponentClient<GatewayRequest, GatewayResponse>> {
match &self.gateway_client {
Some(client) => client.get_local_client(),
None => None,
}
}

pub fn get_mempool_p2p_propagator_shared_client(
&self,
) -> Option<SharedMempoolP2pPropagatorClient> {
get_shared_client!(self, mempool_p2p_propagator_client)
}

pub fn get_mempool_p2p_propagator_local_client(
&self,
) -> Option<LocalComponentClient<MempoolP2pPropagatorRequest, MempoolP2pPropagatorResponse>>
{
match &self.mempool_p2p_propagator_client {
Some(client) => client.get_local_client(),
None => None,
}
}
}

/// A macro for creating a component client, determined by the component's execution mode. Returns a
Expand Down
Loading