reth_rpc_eth_api/
filter.rs1use alloy_json_rpc::RpcObject;
4use alloy_rpc_types_eth::{Filter, FilterChanges, FilterId, PendingTransactionFilterKind};
5use jsonrpsee::{core::RpcResult, proc_macros::rpc};
6use std::future::Future;
7
8#[rpc(server, namespace = "eth")]
10pub trait EthFilterApi<T: RpcObject, L: RpcObject> {
11 #[method(name = "newFilter")]
13 async fn new_filter(&self, filter: Filter) -> RpcResult<FilterId>;
14
15 #[method(name = "newBlockFilter")]
17 async fn new_block_filter(&self) -> RpcResult<FilterId>;
18
19 #[method(name = "newPendingTransactionFilter")]
21 async fn new_pending_transaction_filter(
22 &self,
23 kind: Option<PendingTransactionFilterKind>,
24 ) -> RpcResult<FilterId>;
25
26 #[method(name = "getFilterChanges")]
28 async fn filter_changes(&self, id: FilterId) -> RpcResult<FilterChanges<T, L>>;
29
30 #[method(name = "getFilterLogs")]
32 async fn filter_logs(&self, id: FilterId) -> RpcResult<Vec<L>>;
33
34 #[method(name = "uninstallFilter")]
36 async fn uninstall_filter(&self, id: FilterId) -> RpcResult<bool>;
37
38 #[method(name = "getLogs")]
40 async fn logs(&self, filter: Filter) -> RpcResult<Vec<L>>;
41}
42
43#[derive(Default, Debug, Clone, Copy)]
45pub struct QueryLimits {
46 pub max_blocks_per_filter: Option<u64>,
48 pub max_logs_per_response: Option<usize>,
50}
51
52impl QueryLimits {
53 pub fn no_limits() -> Self {
55 Default::default()
56 }
57}
58
59pub trait EngineEthFilter<L: RpcObject>: Send + Sync + 'static {
62 fn logs(
64 &self,
65 filter: Filter,
66 limits: QueryLimits,
67 ) -> impl Future<Output = RpcResult<Vec<L>>> + Send;
68}