From 706cef01e1aeadf06be1b726b3f595087e89e2cc Mon Sep 17 00:00:00 2001 From: Itay Tsabary Date: Sat, 16 Nov 2024 22:37:08 +0200 Subject: [PATCH] chore(batcher): unify client implementations commit-id:9a7ff36a --- .../src/communication.rs | 70 ++----------------- 1 file changed, 4 insertions(+), 66 deletions(-) diff --git a/crates/starknet_batcher_types/src/communication.rs b/crates/starknet_batcher_types/src/communication.rs index cf1157fa31..f92b699b2b 100644 --- a/crates/starknet_batcher_types/src/communication.rs +++ b/crates/starknet_batcher_types/src/communication.rs @@ -100,72 +100,10 @@ pub enum BatcherClientError { } #[async_trait] -impl BatcherClient for LocalBatcherClient { - async fn build_proposal(&self, input: BuildProposalInput) -> BatcherClientResult<()> { - let request = BatcherRequest::BuildProposal(input); - let response = self.send(request).await; - handle_response_variants!(BatcherResponse, BuildProposal, BatcherClientError, BatcherError) - } - - async fn get_proposal_content( - &self, - input: GetProposalContentInput, - ) -> BatcherClientResult { - let request = BatcherRequest::GetProposalContent(input); - let response = self.send(request).await; - handle_response_variants!( - BatcherResponse, - GetProposalContent, - BatcherClientError, - BatcherError - ) - } - - async fn validate_proposal(&self, input: ValidateProposalInput) -> BatcherClientResult<()> { - let request = BatcherRequest::ValidateProposal(input); - let response = self.send(request).await; - handle_response_variants!( - BatcherResponse, - ValidateProposal, - BatcherClientError, - BatcherError - ) - } - - async fn send_proposal_content( - &self, - input: SendProposalContentInput, - ) -> BatcherClientResult { - let request = BatcherRequest::SendProposalContent(input); - let response = self.send(request).await; - handle_response_variants!( - BatcherResponse, - SendProposalContent, - BatcherClientError, - BatcherError - ) - } - - async fn start_height(&self, input: StartHeightInput) -> BatcherClientResult<()> { - let request = BatcherRequest::StartHeight(input); - let response = self.send(request).await; - handle_response_variants!(BatcherResponse, StartHeight, BatcherClientError, BatcherError) - } - - async fn decision_reached(&self, input: DecisionReachedInput) -> BatcherClientResult<()> { - let request = BatcherRequest::DecisionReached(input); - let response = self.send(request).await; - handle_response_variants!( - BatcherResponse, - DecisionReached, - BatcherClientError, - BatcherError - ) - } -} - -#[async_trait] -impl BatcherClient for RemoteBatcherClient { +impl BatcherClient for T +where + T: Send + Sync + ComponentClient, +{ async fn build_proposal(&self, input: BuildProposalInput) -> BatcherClientResult<()> { let request = BatcherRequest::BuildProposal(input); let response = self.send(request).await;