fix: remove const lag so it can be passed in as runtime variable (#587)
This commit is contained in:
parent
b3fed152a4
commit
8eac1997f4
|
@ -33,21 +33,22 @@ impl<M: Middleware> FromErr<M::Error> for TimeLagError<M> {
|
||||||
|
|
||||||
/// TimeLag Provider
|
/// TimeLag Provider
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct TimeLag<M, const K: u8> {
|
pub struct TimeLag<M> {
|
||||||
inner: Arc<M>,
|
inner: Arc<M>,
|
||||||
|
lag: u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<M, const K: u8> TimeLag<M, K>
|
impl<M> TimeLag<M>
|
||||||
where
|
where
|
||||||
M: Middleware,
|
M: Middleware,
|
||||||
{
|
{
|
||||||
/// Instantiates TimeLag provider
|
/// Instantiates TimeLag provider
|
||||||
pub fn new(inner: M) -> Self {
|
pub fn new(inner: M, lag: u8) -> Self {
|
||||||
Self { inner: inner.into() }
|
Self { inner: inner.into(), lag }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<M, const K: u8> TimeLag<M, K>
|
impl<M> TimeLag<M>
|
||||||
where
|
where
|
||||||
M: Middleware,
|
M: Middleware,
|
||||||
{
|
{
|
||||||
|
@ -93,7 +94,7 @@ where
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
|
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
|
||||||
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
|
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
|
||||||
impl<M, const K: u8> Middleware for TimeLag<M, K>
|
impl<M> Middleware for TimeLag<M>
|
||||||
where
|
where
|
||||||
M: Middleware,
|
M: Middleware,
|
||||||
{
|
{
|
||||||
|
@ -111,7 +112,7 @@ where
|
||||||
self.inner()
|
self.inner()
|
||||||
.get_block_number()
|
.get_block_number()
|
||||||
.await
|
.await
|
||||||
.map(|num| num - K)
|
.map(|num| num - self.lag)
|
||||||
.map_err(ethers_providers::FromErr::from)
|
.map_err(ethers_providers::FromErr::from)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue