From 09d095005abcaf2b71547b82034a9b13ae34fd73 Mon Sep 17 00:00:00 2001 From: 0xlosha Date: Thu, 18 May 2023 22:03:51 +0200 Subject: [PATCH 1/2] add subscribe_full_pending_txs() --- ethers-middleware/src/timelag/mod.rs | 9 +++++++++ ethers-providers/src/middleware.rs | 17 ++++++++++++++++- ethers-providers/src/rpc/provider.rs | 9 +++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/ethers-middleware/src/timelag/mod.rs b/ethers-middleware/src/timelag/mod.rs index 258fc15ad..2735887c8 100644 --- a/ethers-middleware/src/timelag/mod.rs +++ b/ethers-middleware/src/timelag/mod.rs @@ -380,6 +380,15 @@ where Err(TimeLagError::Unsupported) } + async fn subscribe_full_pending_txs( + &self, + ) -> Result, Self::Error> + where + Self::Provider: ethers_providers::PubsubClient, + { + Err(TimeLagError::Unsupported) + } + async fn subscribe_logs<'a>( &'a self, _filter: ðers_core::types::Filter, diff --git a/ethers-providers/src/middleware.rs b/ethers-providers/src/middleware.rs index 436c8c3be..de6acdc10 100644 --- a/ethers-providers/src/middleware.rs +++ b/ethers-providers/src/middleware.rs @@ -905,7 +905,7 @@ pub trait Middleware: Sync + Send + Debug { self.inner().subscribe_blocks().await.map_err(MiddlewareError::from_err) } - /// Subscribe to a stream of pending transactions. + /// Subscribe to a stream of pending transaction hashes. /// /// This function is only available on pubsub clients, such as Websockets /// or IPC. For a polling alternative available over HTTP, use @@ -920,6 +920,21 @@ pub trait Middleware: Sync + Send + Debug { self.inner().subscribe_pending_txs().await.map_err(MiddlewareError::from_err) } + /// Subscribe to a stream of pending transaction bodies. + /// + /// This function is only available on pubsub clients, such as Websockets + /// or IPC. For a polling alternative available over HTTP, use + /// [`Middleware::watch_pending_transactions`]. However, be aware that + /// polling increases RPC usage drastically. + async fn subscribe_full_pending_txs( + &self, + ) -> Result, Self::Error> + where + ::Provider: PubsubClient, + { + self.inner().subscribe_full_pending_txs().await.map_err(MiddlewareError::from_err) + } + /// Subscribe to a stream of event logs matchin the provided [`Filter`]. /// /// This function is only available on pubsub clients, such as Websockets diff --git a/ethers-providers/src/rpc/provider.rs b/ethers-providers/src/rpc/provider.rs index 522073a14..ae9fc6206 100644 --- a/ethers-providers/src/rpc/provider.rs +++ b/ethers-providers/src/rpc/provider.rs @@ -1049,6 +1049,15 @@ impl Middleware for Provider

{ self.subscribe(["newPendingTransactions"]).await } + async fn subscribe_full_pending_txs( + &self, + ) -> Result, ProviderError> + where + P: PubsubClient, + { + self.subscribe([utils::serialize(&"newPendingTransactions"), utils::serialize(&true)]).await + } + async fn subscribe_logs<'a>( &'a self, filter: &Filter, From 410db4d2756df93691debd55129cc84c36699dd7 Mon Sep 17 00:00:00 2001 From: red <83345377+red-eth@users.noreply.github.com> Date: Tue, 23 May 2023 16:58:06 +0200 Subject: [PATCH 2/2] Update middleware.rs --- ethers-providers/src/middleware.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ethers-providers/src/middleware.rs b/ethers-providers/src/middleware.rs index de6acdc10..a13de6b30 100644 --- a/ethers-providers/src/middleware.rs +++ b/ethers-providers/src/middleware.rs @@ -926,6 +926,8 @@ pub trait Middleware: Sync + Send + Debug { /// or IPC. For a polling alternative available over HTTP, use /// [`Middleware::watch_pending_transactions`]. However, be aware that /// polling increases RPC usage drastically. + /// + /// Note: This endpoint is compatible only with Geth client version 1.11.0 or later. async fn subscribe_full_pending_txs( &self, ) -> Result, Self::Error>