@@ -22,7 +22,7 @@ use strum_macros::{AsRefStr, EnumDiscriminants, EnumIter, IntoStaticStr};
2222use thiserror:: Error ;
2323
2424use crate :: errors:: MempoolError ;
25- use crate :: mempool_types:: { AddTransactionArgs , CommitBlockArgs , MempoolSnapshot } ;
25+ use crate :: mempool_types:: { AddTransactionArgs , CommitBlockArgs , MempoolSnapshot , ValidationArgs } ;
2626
2727pub type LocalMempoolClient = LocalComponentClient < MempoolRequest , MempoolResponse > ;
2828pub type RemoteMempoolClient = RemoteComponentClient < MempoolRequest , MempoolResponse > ;
@@ -45,6 +45,7 @@ pub trait MempoolClient: Send + Sync {
4545 // TODO(AlonH): Add Option<BroadcastedMessageMetadata> as an argument for add_transaction
4646 // TODO(AlonH): Rename tx to transaction
4747 async fn add_tx ( & self , args : AddTransactionArgsWrapper ) -> MempoolClientResult < ( ) > ;
48+ async fn validate_tx ( & self , args : ValidationArgs ) -> MempoolClientResult < ( ) > ;
4849 async fn commit_block ( & self , args : CommitBlockArgs ) -> MempoolClientResult < ( ) > ;
4950 async fn get_txs ( & self , n_txs : usize ) -> MempoolClientResult < Vec < InternalRpcTransaction > > ;
5051 async fn account_tx_in_pool_or_recent_block (
@@ -63,6 +64,7 @@ pub trait MempoolClient: Send + Sync {
6364) ]
6465pub enum MempoolRequest {
6566 AddTransaction ( AddTransactionArgsWrapper ) ,
67+ ValidateTransaction ( ValidationArgs ) ,
6668 CommitBlock ( CommitBlockArgs ) ,
6769 GetTransactions ( usize ) ,
6870 AccountTxInPoolOrRecentBlock ( ContractAddress ) ,
@@ -79,6 +81,7 @@ impl PrioritizedRequest for MempoolRequest {
7981 RequestPriority :: High
8082 }
8183 MempoolRequest :: AddTransaction ( _)
84+ | MempoolRequest :: ValidateTransaction ( _)
8285 | MempoolRequest :: AccountTxInPoolOrRecentBlock ( _)
8386 | MempoolRequest :: UpdateGasPrice ( _)
8487 | MempoolRequest :: GetMempoolSnapshot ( ) => RequestPriority :: Normal ,
@@ -89,6 +92,7 @@ impl PrioritizedRequest for MempoolRequest {
8992#[ derive( Clone , Serialize , Deserialize , AsRefStr ) ]
9093pub enum MempoolResponse {
9194 AddTransaction ( MempoolResult < ( ) > ) ,
95+ ValidateTransaction ( MempoolResult < ( ) > ) ,
9296 CommitBlock ( MempoolResult < ( ) > ) ,
9397 GetTransactions ( MempoolResult < Vec < InternalRpcTransaction > > ) ,
9498 AccountTxInPoolOrRecentBlock ( MempoolResult < bool > ) ,
@@ -121,6 +125,17 @@ where
121125 )
122126 }
123127
128+ async fn validate_tx ( & self , args : ValidationArgs ) -> MempoolClientResult < ( ) > {
129+ let request = MempoolRequest :: ValidateTransaction ( args) ;
130+ handle_all_response_variants ! (
131+ MempoolResponse ,
132+ ValidateTransaction ,
133+ MempoolClientError ,
134+ MempoolError ,
135+ Direct
136+ )
137+ }
138+
124139 async fn commit_block ( & self , args : CommitBlockArgs ) -> MempoolClientResult < ( ) > {
125140 let request = MempoolRequest :: CommitBlock ( args) ;
126141 handle_all_response_variants ! (
0 commit comments