1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//!# Indexer1
//!
//!Indexer1 is a library that provides a mechanism to index EVM-compatible blockchains.
//!It uses PostgreSQL to ensure consistent and fault-tolerant indexing, however re-implementing storage trait is available.
//!Indexer1 is lightweight, self-hosted and simple to use.
//!If you need a professional and extendable way of indexing EVM, you should definately prefer Indexer1
//!
//!# Example
//!To make it work you only need to implement a Processor trait that gives you transaction and
//!allow you to inject your custom logic of parsing and applying logs. It also gives you a
//!transaction to work with database and does all the deduplication work for you. You are
//!guaranteed to receive all events ordered.
//!
//!```ignore
//!pub struct TestProcessor;
//!
//!impl Processor for TestProcessor {
//! async fn process<Postgres>(
//! &mut self,
//! _logs: &[alloy::rpc::types::Log],
//! _transaction: &mut sqlx::Transaction<'static, Postgres>,
//! _chain_id: u64,
//! ) -> anyhow::Result<()> {
//! // put here any code to collect logs
//! Ok(())
//! }
//!}
//!```
//!
//!After you described processing, build indexer by specifying all connections and filter for
//!events. If the filter will be changed, indexer will re-index all the data from the blockchain.
//!
//!```ignore
//!Indexer::builder()
//! .http_rpc_url(http_url)
//! .ws_rpc_url(ws_url)
//! .fetch_interval(Duration::from_secs(10))
//! // Add event filter
//! .filter(Filter::new().address(contract_address).events([
//! MockERC20::Transfer::SIGNATURE,
//! MockERC20::Approval::SIGNATURE,
//! ]))
//! // Set up a function to process events
//! .set_processor(TestProcessor)
//! .sqlite_storage(pool)
//! .build()
//! .await
//! .unwrap()
//! .run()
//! .await?;
//!```
pub use alloy;
pub use anyhow;
pub use IndexerBuilder;
pub use ;
pub use sqlx;
pub use LogStorage;
pub use tokio;