Skip to content

Commit

Permalink
chore(batcher): unify client implementations
Browse files Browse the repository at this point in the history
commit-id:9a7ff36a
  • Loading branch information
Itay-Tsabary-Starkware committed Nov 16, 2024
1 parent 46aafa6 commit 706cef0
Showing 1 changed file with 4 additions and 66 deletions.
70 changes: 4 additions & 66 deletions crates/starknet_batcher_types/src/communication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<GetProposalContentResponse> {
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<SendProposalContentResponse> {
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<T> BatcherClient for T
where
T: Send + Sync + ComponentClient<BatcherRequest, BatcherResponse>,
{
async fn build_proposal(&self, input: BuildProposalInput) -> BatcherClientResult<()> {
let request = BatcherRequest::BuildProposal(input);
let response = self.send(request).await;
Expand Down

0 comments on commit 706cef0

Please sign in to comment.