take provider interval on PendingTransaction (#1558)

This commit is contained in:
joshieDo 2022-08-03 17:19:10 +01:00 committed by GitHub
parent 550d2d86ef
commit 8026904c3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 8 deletions

View File

@ -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<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,
}
}

View File

@ -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
@ -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