Skip to content

Commit

Permalink
chore(mempool_types): unify client implementations
Browse files Browse the repository at this point in the history
commit-id:f8764575
  • Loading branch information
Itay-Tsabary-Starkware committed Nov 17, 2024
1 parent 2018498 commit c3a2688
Showing 1 changed file with 4 additions and 27 deletions.
31 changes: 4 additions & 27 deletions crates/starknet_mempool_types/src/communication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Vec<AccountTransaction>> {
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<T> MempoolClient for T
where
T: Send + Sync + ComponentClient<MempoolRequest, MempoolResponse>,
{
async fn add_tx(&self, args: AddTransactionArgsWrapper) -> MempoolClientResult<()> {
let request = MempoolRequest::AddTransaction(args);
let response = self.send(request).await;
Expand Down

0 comments on commit c3a2688

Please sign in to comment.