diff --git a/ethers-middleware/src/timelag/mod.rs b/ethers-middleware/src/timelag/mod.rs index 133b6e3d..09541eab 100644 --- a/ethers-middleware/src/timelag/mod.rs +++ b/ethers-middleware/src/timelag/mod.rs @@ -33,21 +33,22 @@ impl FromErr for TimeLagError { /// TimeLag Provider #[derive(Debug)] -pub struct TimeLag { +pub struct TimeLag { inner: Arc, + lag: u8, } -impl TimeLag +impl TimeLag where M: Middleware, { /// Instantiates TimeLag provider - pub fn new(inner: M) -> Self { - Self { inner: inner.into() } + pub fn new(inner: M, lag: u8) -> Self { + Self { inner: inner.into(), lag } } } -impl TimeLag +impl TimeLag where M: Middleware, { @@ -93,7 +94,7 @@ where #[cfg_attr(target_arch = "wasm32", async_trait(?Send))] #[cfg_attr(not(target_arch = "wasm32"), async_trait)] -impl Middleware for TimeLag +impl Middleware for TimeLag where M: Middleware, { @@ -111,7 +112,7 @@ where self.inner() .get_block_number() .await - .map(|num| num - K) + .map(|num| num - self.lag) .map_err(ethers_providers::FromErr::from) }