Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

add subscribe_full_pending_txs() #2424

Merged
merged 2 commits into from
May 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 9 additions & 0 deletions ethers-middleware/src/timelag/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,15 @@ where
Err(TimeLagError::Unsupported)
}

async fn subscribe_full_pending_txs(
&self,
) -> Result<ethers_providers::SubscriptionStream<'_, Self::Provider, Transaction>, Self::Error>
where
Self::Provider: ethers_providers::PubsubClient,
{
Err(TimeLagError::Unsupported)
}

async fn subscribe_logs<'a>(
&'a self,
_filter: &ethers_core::types::Filter,
Expand Down
17 changes: 16 additions & 1 deletion ethers-providers/src/middleware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you document that this API will only work on Geth >=X.Y.Z?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is also not available on all providers or is specific to tiers.

so essentially the same as all the tracing APIs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you document that this API will only work on Geth >=X.Y.Z?

added :)

&self,
) -> Result<SubscriptionStream<'_, Self::Provider, Transaction>, Self::Error>
where
<Self as Middleware>::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
Expand Down
9 changes: 9 additions & 0 deletions ethers-providers/src/rpc/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1049,6 +1049,15 @@ impl<P: JsonRpcClient> Middleware for Provider<P> {
self.subscribe(["newPendingTransactions"]).await
}

async fn subscribe_full_pending_txs(
&self,
) -> Result<SubscriptionStream<'_, P, Transaction>, ProviderError>
where
P: PubsubClient,
{
self.subscribe([utils::serialize(&"newPendingTransactions"), utils::serialize(&true)]).await
}

async fn subscribe_logs<'a>(
&'a self,
filter: &Filter,
Expand Down