pub struct Indexer<T, U, Db>where
T: HoprIndexerRpcOperations + Send + 'static,
U: ChainLogHandler + Send + 'static,
Db: HoprDbGeneralModelOperations + HoprDbInfoOperations + HoprDbLogOperations + Clone + Send + Sync + 'static,{ /* private fields */ }
Expand description
Indexer
Accepts the RPC operational functionality hopr_chain_rpc::HoprIndexerRpcOperations and provides the indexing operation resulting in and output of hopr_chain_types::chain_events::SignificantChainEvent streamed outside the indexer by the unbounded channel.
The roles of the indexer:
- prime the RPC endpoint
- request an RPC stream of changes to process
- process block and log stream
- ensure finalization by postponing processing until the head is far enough
- store relevant data into the DB
- pass the processing on to the business logic
Implementations§
Source§impl<T, U, Db> Indexer<T, U, Db>where
T: HoprIndexerRpcOperations + Sync + Send + 'static,
U: ChainLogHandler + Send + Sync + 'static,
Db: HoprDbGeneralModelOperations + HoprDbInfoOperations + HoprDbLogOperations + Clone + Send + Sync + 'static,
impl<T, U, Db> Indexer<T, U, Db>where
T: HoprIndexerRpcOperations + Sync + Send + 'static,
U: ChainLogHandler + Send + Sync + 'static,
Db: HoprDbGeneralModelOperations + HoprDbInfoOperations + HoprDbLogOperations + Clone + Send + Sync + 'static,
pub fn new( rpc: T, db_processor: U, db: Db, cfg: IndexerConfig, egress: Sender<SignificantChainEvent>, ) -> Self
Sourcepub fn without_panic_on_completion(self) -> Self
pub fn without_panic_on_completion(self) -> Self
Disables the panic on completion.
pub async fn start(self) -> Result<AbortHandle>where
T: HoprIndexerRpcOperations + 'static,
U: ChainLogHandler + 'static,
Db: HoprDbGeneralModelOperations + HoprDbInfoOperations + HoprDbLogOperations + Clone + Send + Sync + 'static,
pub async fn pre_start(&self) -> Result<()>
Sourcepub async fn download_snapshot(&self) -> Result<SnapshotInfo>
pub async fn download_snapshot(&self) -> Result<SnapshotInfo>
Downloads and installs a database snapshot for faster initial synchronization.
This method coordinates the snapshot download process by:
- Validating the indexer configuration
- Creating a snapshot manager instance
- Downloading and extracting the snapshot to the data directory
Snapshots allow new nodes to quickly synchronize with the network by downloading pre-built database files instead of fetching all historical logs from scratch.
§Returns
Ok(SnapshotInfo)
containing details about the downloaded snapshotErr(CoreEthereumIndexerError::SnapshotError)
if validation or download fails
§Prerequisites
- Configuration must be valid (proper URL format, data directory set)
- Sufficient disk space must be available
- Network connectivity to the snapshot URL
Trait Implementations§
Source§impl<T, U, Db> Clone for Indexer<T, U, Db>where
T: HoprIndexerRpcOperations + Send + 'static + Clone,
U: ChainLogHandler + Send + 'static + Clone,
Db: HoprDbGeneralModelOperations + HoprDbInfoOperations + HoprDbLogOperations + Clone + Send + Sync + 'static + Clone,
impl<T, U, Db> Clone for Indexer<T, U, Db>where
T: HoprIndexerRpcOperations + Send + 'static + Clone,
U: ChainLogHandler + Send + 'static + Clone,
Db: HoprDbGeneralModelOperations + HoprDbInfoOperations + HoprDbLogOperations + Clone + Send + Sync + 'static + Clone,
Source§impl<T, U, Db> Debug for Indexer<T, U, Db>where
T: HoprIndexerRpcOperations + Send + 'static + Debug,
U: ChainLogHandler + Send + 'static + Debug,
Db: HoprDbGeneralModelOperations + HoprDbInfoOperations + HoprDbLogOperations + Clone + Send + Sync + 'static + Debug,
impl<T, U, Db> Debug for Indexer<T, U, Db>where
T: HoprIndexerRpcOperations + Send + 'static + Debug,
U: ChainLogHandler + Send + 'static + Debug,
Db: HoprDbGeneralModelOperations + HoprDbInfoOperations + HoprDbLogOperations + Clone + Send + Sync + 'static + Debug,
Auto Trait Implementations§
impl<T, U, Db> Freeze for Indexer<T, U, Db>
impl<T, U, Db> RefUnwindSafe for Indexer<T, U, Db>
impl<T, U, Db> Send for Indexer<T, U, Db>
impl<T, U, Db> Sync for Indexer<T, U, Db>
impl<T, U, Db> Unpin for Indexer<T, U, Db>
impl<T, U, Db> UnwindSafe for Indexer<T, U, Db>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more