pub struct GasCache { /* private fields */ }Expand description
Cached EIP-1559 gas fees with TTL-based staleness detection.
Updated from block headers (typically via subscription or polling).
All methods that check freshness take an explicit now_ms parameter
for deterministic testing.
Implementations§
Source§impl GasCache
impl GasCache
Sourcepub fn new(ttl_ms: u64, default_priority_fee: u64) -> Self
pub fn new(ttl_ms: u64, default_priority_fee: u64) -> Self
Create a new cache.
ttl_ms: how long cached fees are valid (2000 = 2 Base L2 blocks)default_priority_fee: miner tip in wei (e.g. 1_000_000_000 = 1 gwei)
Sourcepub fn update(&mut self, base_fee: u64, now_ms: u64)
pub fn update(&mut self, base_fee: u64, now_ms: u64)
Update the cache from a new block header’s base fee.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for GasCache
impl RefUnwindSafe for GasCache
impl Send for GasCache
impl Sync for GasCache
impl Unpin for GasCache
impl UnsafeUnpin for GasCache
impl UnwindSafe for GasCache
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more