From c3a26881e38953eaac30ae481bba08f64ebd0ef6 Mon Sep 17 00:00:00 2001 From: Itay Tsabary Date: Sat, 16 Nov 2024 23:07:42 +0200 Subject: [PATCH] chore(mempool_types): unify client implementations commit-id:f8764575 --- .../src/communication.rs | 31 +++---------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/crates/starknet_mempool_types/src/communication.rs b/crates/starknet_mempool_types/src/communication.rs index 8c17e21899..880ad50676 100644 --- a/crates/starknet_mempool_types/src/communication.rs +++ b/crates/starknet_mempool_types/src/communication.rs @@ -70,33 +70,10 @@ pub enum MempoolClientError { } #[async_trait] -impl MempoolClient for LocalMempoolClient { - async fn add_tx(&self, args: AddTransactionArgsWrapper) -> MempoolClientResult<()> { - let request = MempoolRequest::AddTransaction(args); - let response = self.send(request).await; - handle_response_variants!(MempoolResponse, AddTransaction, MempoolClientError, MempoolError) - } - - async fn commit_block(&self, args: CommitBlockArgs) -> MempoolClientResult<()> { - let request = MempoolRequest::CommitBlock(args); - let response = self.send(request).await; - handle_response_variants!(MempoolResponse, CommitBlock, MempoolClientError, MempoolError) - } - - async fn get_txs(&self, n_txs: usize) -> MempoolClientResult> { - let request = MempoolRequest::GetTransactions(n_txs); - let response = self.send(request).await; - handle_response_variants!( - MempoolResponse, - GetTransactions, - MempoolClientError, - MempoolError - ) - } -} - -#[async_trait] -impl MempoolClient for RemoteMempoolClient { +impl MempoolClient for T +where + T: Send + Sync + ComponentClient, +{ async fn add_tx(&self, args: AddTransactionArgsWrapper) -> MempoolClientResult<()> { let request = MempoolRequest::AddTransaction(args); let response = self.send(request).await;