reth_optimism_txpool/interop.rs
1//! Additional support for pooled interop transactions.
2
3/// Helper trait that allows attaching an interop deadline.
4pub trait MaybeInteropTransaction {
5 /// Attach an interop deadline
6 fn set_interop_deadline(&self, deadline: u64);
7
8 /// Get attached deadline if any.
9 fn interop_deadline(&self) -> Option<u64>;
10
11 /// Helper that sets the interop and returns the instance again
12 fn with_interop_deadline(self, interop: u64) -> Self
13 where
14 Self: Sized,
15 {
16 self.set_interop_deadline(interop);
17 self
18 }
19}
20
21/// Helper to keep track of cross transaction interop validity
22/// Checks if provided timestamp fits into tx validation window
23#[inline]
24pub fn is_valid_interop(timeout: u64, timestamp: u64) -> bool {
25 timestamp < timeout
26}
27
28/// Checks if transaction needs revalidation based on offset
29#[inline]
30pub fn is_stale_interop(timeout: u64, timestamp: u64, offset: u64) -> bool {
31 timestamp + offset > timeout
32}