reth_rpc_eth_api/
filter.rs1use alloy_json_rpc::RpcObject;
4use alloy_rpc_types_eth::{Filter, FilterChanges, FilterId, Log, PendingTransactionFilterKind};
5use jsonrpsee::{core::RpcResult, proc_macros::rpc};
6use std::future::Future;
7
8#[cfg_attr(not(feature = "client"), rpc(server, namespace = "eth"))]
10#[cfg_attr(feature = "client", rpc(server, client, namespace = "eth"))]
11pub trait EthFilterApi<T: RpcObject> {
12    #[method(name = "newFilter")]
14    async fn new_filter(&self, filter: Filter) -> RpcResult<FilterId>;
15
16    #[method(name = "newBlockFilter")]
18    async fn new_block_filter(&self) -> RpcResult<FilterId>;
19
20    #[method(name = "newPendingTransactionFilter")]
22    async fn new_pending_transaction_filter(
23        &self,
24        kind: Option<PendingTransactionFilterKind>,
25    ) -> RpcResult<FilterId>;
26
27    #[method(name = "getFilterChanges")]
29    async fn filter_changes(&self, id: FilterId) -> RpcResult<FilterChanges<T>>;
30
31    #[method(name = "getFilterLogs")]
33    async fn filter_logs(&self, id: FilterId) -> RpcResult<Vec<Log>>;
34
35    #[method(name = "uninstallFilter")]
37    async fn uninstall_filter(&self, id: FilterId) -> RpcResult<bool>;
38
39    #[method(name = "getLogs")]
41    async fn logs(&self, filter: Filter) -> RpcResult<Vec<Log>>;
42}
43
44#[derive(Default, Debug, Clone, Copy)]
46pub struct QueryLimits {
47    pub max_blocks_per_filter: Option<u64>,
49    pub max_logs_per_response: Option<usize>,
51}
52
53impl QueryLimits {
54    pub fn no_limits() -> Self {
56        Default::default()
57    }
58}
59
60pub trait EngineEthFilter: Send + Sync + 'static {
63    fn logs(
65        &self,
66        filter: Filter,
67        limits: QueryLimits,
68    ) -> impl Future<Output = RpcResult<Vec<Log>>> + Send;
69}