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(batcher): unify client implementations #2086

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
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
Loading