diff --git a/crates/rpc/rpc/src/eth/filter.rs b/crates/rpc/rpc/src/eth/filter.rs index a98b4be51e..aab0fa32df 100644 --- a/crates/rpc/rpc/src/eth/filter.rs +++ b/crates/rpc/rpc/src/eth/filter.rs @@ -759,6 +759,26 @@ impl ActiveFilters { pub fn new() -> Self { Self { inner: Arc::new(Mutex::new(HashMap::default())) } } + + /// Returns `true` if a filter with the given id exists. + pub async fn contains(&self, id: &FilterId) -> bool { + self.inner.lock().await.contains_key(id) + } + + /// Returns the number of currently active filters. + pub async fn len(&self) -> usize { + self.inner.lock().await.len() + } + + /// Returns `true` if there are no active filters. + pub async fn is_empty(&self) -> bool { + self.inner.lock().await.is_empty() + } + + /// Returns all active filter ids. + pub async fn ids(&self) -> Vec { + self.inner.lock().await.keys().cloned().collect() + } } /// An installed filter