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

fix(provider): use provider interval on PendingTransaction #1558

Merged
merged 1 commit into from
Aug 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 4 additions & 6 deletions ethers-providers/src/pending_transaction.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<P>) -> 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,
}
}
Expand Down
4 changes: 2 additions & 2 deletions ethers-providers/src/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ impl<P: JsonRpcClient> Middleware for Provider<P> {
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
Expand All @@ -646,7 +646,7 @@ impl<P: JsonRpcClient> Middleware for Provider<P> {
) -> Result<PendingTransaction<'a, P>, 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
Expand Down