From 8026904c3d78d1f0c81920d530f83f3217f22ab8 Mon Sep 17 00:00:00 2001 From: joshieDo <93316087+joshieDo@users.noreply.github.com> Date: Wed, 3 Aug 2022 17:19:10 +0100 Subject: [PATCH] take provider interval on PendingTransaction (#1558) --- ethers-providers/src/pending_transaction.rs | 10 ++++------ ethers-providers/src/provider.rs | 4 ++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/ethers-providers/src/pending_transaction.rs b/ethers-providers/src/pending_transaction.rs index 81b3228e..c6ffea54 100644 --- a/ethers-providers/src/pending_transaction.rs +++ b/ethers-providers/src/pending_transaction.rs @@ -1,7 +1,4 @@ -use crate::{ - stream::{interval, DEFAULT_POLL_INTERVAL}, - JsonRpcClient, Middleware, PinBoxFut, Provider, ProviderError, -}; +use crate::{stream::interval, JsonRpcClient, Middleware, PinBoxFut, Provider, ProviderError}; use ethers_core::types::{Transaction, TransactionReceipt, TxHash, U64}; use futures_core::stream::Stream; use futures_util::stream::StreamExt; @@ -70,13 +67,14 @@ const DEFAULT_RETRIES: usize = 3; impl<'a, P: JsonRpcClient> PendingTransaction<'a, P> { /// Creates a new pending transaction poller from a hash and a provider pub fn new(tx_hash: TxHash, provider: &'a Provider

) -> Self { - let delay = Box::pin(Delay::new(DEFAULT_POLL_INTERVAL)); + let delay = Box::pin(Delay::new(provider.get_interval())); + Self { tx_hash, confirmations: 1, provider, state: PendingTxState::InitialDelay(delay), - interval: Box::new(interval(DEFAULT_POLL_INTERVAL)), + interval: Box::new(interval(provider.get_interval())), retries_remaining: DEFAULT_RETRIES, } } diff --git a/ethers-providers/src/provider.rs b/ethers-providers/src/provider.rs index bd306c3c..5348d670 100644 --- a/ethers-providers/src/provider.rs +++ b/ethers-providers/src/provider.rs @@ -635,7 +635,7 @@ impl Middleware for Provider

{ self.fill_transaction(&mut tx, block).await?; let tx_hash = self.request("eth_sendTransaction", [tx]).await?; - Ok(PendingTransaction::new(tx_hash, self).interval(self.get_interval())) + Ok(PendingTransaction::new(tx_hash, self)) } /// Send the raw RLP encoded transaction to the entire Ethereum network and returns the @@ -646,7 +646,7 @@ impl Middleware for Provider

{ ) -> Result, ProviderError> { let rlp = utils::serialize(&tx); let tx_hash = self.request("eth_sendRawTransaction", [rlp]).await?; - Ok(PendingTransaction::new(tx_hash, self).interval(self.get_interval())) + Ok(PendingTransaction::new(tx_hash, self)) } /// The JSON-RPC provider is at the bottom-most position in the middleware stack. Here we check