Skip to content

Commit

Permalink
chore(mempool_p2p_types): unify client implementations
Browse files Browse the repository at this point in the history
commit-id:c52611c9
  • Loading branch information
Itay-Tsabary-Starkware committed Nov 17, 2024
1 parent 61d5549 commit 5509967
Showing 1 changed file with 4 additions and 32 deletions.
36 changes: 4 additions & 32 deletions crates/starknet_mempool_p2p_types/src/communication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,38 +66,10 @@ pub enum MempoolP2pPropagatorClientError {
}

#[async_trait]
impl MempoolP2pPropagatorClient for LocalMempoolP2pPropagatorClient {
async fn add_transaction(
&self,
transaction: RpcTransaction,
) -> MempoolP2pPropagatorClientResult<()> {
let request = MempoolP2pPropagatorRequest::AddTransaction(transaction);
let response = self.send(request).await;
handle_response_variants!(
MempoolP2pPropagatorResponse,
AddTransaction,
MempoolP2pPropagatorClientError,
MempoolP2pPropagatorError
)
}

async fn continue_propagation(
&self,
propagation_metadata: BroadcastedMessageMetadata,
) -> MempoolP2pPropagatorClientResult<()> {
let request = MempoolP2pPropagatorRequest::ContinuePropagation(propagation_metadata);
let response = self.send(request).await;
handle_response_variants!(
MempoolP2pPropagatorResponse,
ContinuePropagation,
MempoolP2pPropagatorClientError,
MempoolP2pPropagatorError
)
}
}

#[async_trait]
impl MempoolP2pPropagatorClient for RemoteMempoolP2pPropagatorClient {
impl<T> MempoolP2pPropagatorClient for T
where
T: Send + Sync + ComponentClient<MempoolP2pPropagatorRequest, MempoolP2pPropagatorResponse>,
{
async fn add_transaction(
&self,
transaction: RpcTransaction,
Expand Down

0 comments on commit 5509967

Please sign in to comment.