mirror of
https://github.com/pezkuwichain/revive-differential-tests.git
synced 2026-07-24 12:45:40 +00:00
Rename the retry layer
This commit is contained in:
@@ -10,7 +10,7 @@ use alloy::{
|
|||||||
};
|
};
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
|
|
||||||
use crate::provider_utils::{ConcurrencyLimiterLayer, FallbackGasFiller, ReceiptRetryLayer};
|
use crate::provider_utils::{ConcurrencyLimiterLayer, FallbackGasFiller, RetryLayer};
|
||||||
|
|
||||||
pub type ConcreteProvider<N, W> = FillProvider<
|
pub type ConcreteProvider<N, W> = FillProvider<
|
||||||
JoinFill<
|
JoinFill<
|
||||||
@@ -46,7 +46,7 @@ where
|
|||||||
|
|
||||||
let client = ClientBuilder::default()
|
let client = ClientBuilder::default()
|
||||||
.layer(GLOBAL_CONCURRENCY_LIMITER_LAYER.clone())
|
.layer(GLOBAL_CONCURRENCY_LIMITER_LAYER.clone())
|
||||||
.layer(ReceiptRetryLayer::default())
|
.layer(RetryLayer::default())
|
||||||
.connect(rpc_url)
|
.connect(rpc_url)
|
||||||
.await
|
.await
|
||||||
.context("Failed to construct the RPC client")?;
|
.context("Failed to construct the RPC client")?;
|
||||||
|
|||||||
@@ -20,8 +20,10 @@ use tower::{Layer, Service};
|
|||||||
/// considers that a timeout. It attempts to poll for the receipt for the `polling_duration` with an
|
/// considers that a timeout. It attempts to poll for the receipt for the `polling_duration` with an
|
||||||
/// interval of `polling_interval` between each poll. If by the end of the `polling_duration` it was
|
/// interval of `polling_interval` between each poll. If by the end of the `polling_duration` it was
|
||||||
/// not able to get the receipt successfully then this is considered to be a timeout.
|
/// not able to get the receipt successfully then this is considered to be a timeout.
|
||||||
|
///
|
||||||
|
/// Additionally, this layer allows for retries for other rpc methods such as all tracing methods.
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub struct ReceiptRetryLayer {
|
pub struct RetryLayer {
|
||||||
/// The amount of time to keep polling for the receipt before considering it a timeout.
|
/// The amount of time to keep polling for the receipt before considering it a timeout.
|
||||||
polling_duration: Duration,
|
polling_duration: Duration,
|
||||||
|
|
||||||
@@ -29,7 +31,7 @@ pub struct ReceiptRetryLayer {
|
|||||||
polling_interval: Duration,
|
polling_interval: Duration,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ReceiptRetryLayer {
|
impl RetryLayer {
|
||||||
pub fn new(polling_duration: Duration, polling_interval: Duration) -> Self {
|
pub fn new(polling_duration: Duration, polling_interval: Duration) -> Self {
|
||||||
Self {
|
Self {
|
||||||
polling_duration,
|
polling_duration,
|
||||||
@@ -48,7 +50,7 @@ impl ReceiptRetryLayer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for ReceiptRetryLayer {
|
impl Default for RetryLayer {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
polling_duration: Duration::from_secs(90),
|
polling_duration: Duration::from_secs(90),
|
||||||
@@ -57,11 +59,11 @@ impl Default for ReceiptRetryLayer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S> Layer<S> for ReceiptRetryLayer {
|
impl<S> Layer<S> for RetryLayer {
|
||||||
type Service = ReceiptRetryService<S>;
|
type Service = RetryService<S>;
|
||||||
|
|
||||||
fn layer(&self, inner: S) -> Self::Service {
|
fn layer(&self, inner: S) -> Self::Service {
|
||||||
ReceiptRetryService {
|
RetryService {
|
||||||
service: inner,
|
service: inner,
|
||||||
polling_duration: self.polling_duration,
|
polling_duration: self.polling_duration,
|
||||||
polling_interval: self.polling_interval,
|
polling_interval: self.polling_interval,
|
||||||
@@ -70,7 +72,7 @@ impl<S> Layer<S> for ReceiptRetryLayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub struct ReceiptRetryService<S> {
|
pub struct RetryService<S> {
|
||||||
/// The internal service.
|
/// The internal service.
|
||||||
service: S,
|
service: S,
|
||||||
|
|
||||||
@@ -81,7 +83,7 @@ pub struct ReceiptRetryService<S> {
|
|||||||
polling_interval: Duration,
|
polling_interval: Duration,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S> Service<RequestPacket> for ReceiptRetryService<S>
|
impl<S> Service<RequestPacket> for RetryService<S>
|
||||||
where
|
where
|
||||||
S: Service<RequestPacket, Future = TransportFut<'static>, Error = TransportError>
|
S: Service<RequestPacket, Future = TransportFut<'static>, Error = TransportError>
|
||||||
+ Send
|
+ Send
|
||||||
|
|||||||
Reference in New Issue
Block a user