Struct eventify_idx::app::App
source · pub struct App<T, U>{
pub src_block: BlockNumber,
pub dst_block: BlockNumber,
/* private fields */
}Expand description
The App struct represents an application with a JSON-RPC client (T) and storage (U).
It manages the interaction between the blockchain and storage, keeping track of the source
and destination block numbers for operations.
Type Parameters
T: A JSON-RPC client that implementsJsonRpcClient,Clone,Send, andSync.U: A storage system that implementsStorage,Auth,Clone,Send, andSync.
Fields§
§src_block: BlockNumberThe starting block number from which the App operates.
dst_block: BlockNumberThe ending block number up to which the App operates.
Implementations§
source§impl<T, U> App<T, U>
impl<T, U> App<T, U>
sourcepub fn new(
transport_node: Option<NodeProvider<T>>,
transport_storage: Option<U>,
src_block: BlockNumber,
dst_block: BlockNumber
) -> Self
pub fn new( transport_node: Option<NodeProvider<T>>, transport_storage: Option<U>, src_block: BlockNumber, dst_block: BlockNumber ) -> Self
Create a new instance of the indexer
pub fn with_src_block(self, src_block: BlockNumber) -> Self
pub fn with_dst_block(self, dst_block: BlockNumber) -> Self
pub fn with_node_conn(self, transport: NodeProvider<T>) -> Self
pub fn with_storage(self, url: &str) -> Self
pub fn src_block(&self) -> u64
pub fn dst_block(&self) -> u64
pub fn storage_conn(&self) -> Result<&U, Error>
sourcepub async fn fetch_block_with_txs(
&self,
block: BlockId
) -> Result<Block<Transaction>, Error>
pub async fn fetch_block_with_txs( &self, block: BlockId ) -> Result<Block<Transaction>, Error>
sourcepub async fn fetch_block(&self, block: BlockId) -> Result<Block<TxHash>, Error>
pub async fn fetch_block(&self, block: BlockId) -> Result<Block<TxHash>, Error>
Retrieves block details for a given block ID.
This function does not return transaction objects.
sourcepub async fn fetch_logs(
&self,
criterias: &Criterias,
block: BlockNumber
) -> Result<Vec<Log>, Error>
pub async fn fetch_logs( &self, criterias: &Criterias, block: BlockNumber ) -> Result<Vec<Log>, Error>
sourcepub async fn fetch_transactions(
&self,
block: BlockNumber
) -> Result<Vec<Transaction>, Error>
pub async fn fetch_transactions( &self, block: BlockNumber ) -> Result<Vec<Transaction>, Error>
Fetches transactions for a specified block number.
sourcepub async fn fetch_indexed_data(
&self,
block: BlockNumber
) -> Result<(IndexedBlock, Vec<IndexedTransaction>), Error>
pub async fn fetch_indexed_data( &self, block: BlockNumber ) -> Result<(IndexedBlock, Vec<IndexedTransaction>), Error>
sourcepub async fn get_latest_block(&self) -> Result<u64, Error>
pub async fn get_latest_block(&self) -> Result<u64, Error>
Returns the latest finalized block number.
This function queries the underlying transport node for the current block number. If the transport node is not set, or if there is an error in fetching the block number, the function will return an appropriate error.
source§impl<U: Storage + Auth + Clone + Send + Sync> App<Http, U>
impl<U: Storage + Auth + Clone + Send + Sync> App<Http, U>
sourcepub fn with_http(self, node_url: &str) -> Result<Self, Error>
pub fn with_http(self, node_url: &str) -> Result<Self, Error>
Configures the application to use an HTTP transport node.
Example
use ethers_providers::Http;
use eventify_idx::App;
use eventify_primitives::storage::Postgres;
let app: App<Http, Postgres> = App::default().with_http("http://localhost:8545")?;
// Use `app` for further operations...Arguments
node_url- The URL of the HTTP node.
Errors
Returns an error if the URL parsing fails or the HTTP transport cannot be created.
source§impl<U: Storage + Auth + Clone + Send + Sync> App<Ipc, U>
impl<U: Storage + Auth + Clone + Send + Sync> App<Ipc, U>
sourcepub async fn with_ipc(self, node_url: &str) -> Result<Self, Error>
pub async fn with_ipc(self, node_url: &str) -> Result<Self, Error>
Creates a new instance of the App with the IPC transport.
Example
use ethers_providers::Ipc;
use eventify_idx::App;
use eventify_primitives::storage::Postgres;
let app: App<Ipc, Postgres> = App::default().with_ipc("ipc://path/to/socket").await?;
// use app...Arguments
node_url- The URL for the IPC node.
Errors
Returns an error if the IPC transport creation fails.
pub async fn subscribe_blocks( &self ) -> Result<SubscriptionStream<'_, Ipc, Block<TxHash>>, Error>
pub async fn subscribe_logs( &self, filter: Filter ) -> Result<SubscriptionStream<'_, Ipc, Log>, Error>
source§impl<U: Storage + Auth + Clone + Send + Sync> App<Ws, U>
impl<U: Storage + Auth + Clone + Send + Sync> App<Ws, U>
sourcepub async fn with_websocket(self, node_url: &str) -> Result<Self, Error>
pub async fn with_websocket(self, node_url: &str) -> Result<Self, Error>
Creates a new instance of the App with the WebSocket transport.
Example
use ethers_providers::Ws;
use eventify_idx::App;
use eventify_primitives::storage::Postgres;
let app: App<Ws, Postgres> = App::default().with_websocket("ws://localhost:8546").await?;
// Use `app` for further operations...Arguments
node_url- The URL for the WebSocket node.
Errors
Returns an error if the WebSocket transport creation fails.
sourcepub async fn with_ws(self, node_url: &str) -> Result<Self, Error>
pub async fn with_ws(self, node_url: &str) -> Result<Self, Error>
Creates a new instance of the App with the WebSocket transport
An alias for [with_websocket]