Trait HoprIndexerRpcOperations

Source
pub trait HoprIndexerRpcOperations {
    // Required methods
    fn block_number<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_hopr_allowance<'life0, 'async_trait>(
        &'life0 self,
        owner: Address,
        spender: Address,
    ) -> Pin<Box<dyn Future<Output = Result<HoprBalance>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_xdai_balance<'life0, 'async_trait>(
        &'life0 self,
        address: Address,
    ) -> Pin<Box<dyn Future<Output = Result<XDaiBalance>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_hopr_balance<'life0, 'async_trait>(
        &'life0 self,
        address: Address,
    ) -> Pin<Box<dyn Future<Output = Result<HoprBalance>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn try_stream_logs<'a>(
        &'a self,
        start_block_number: u64,
        filters: FilterSet,
        is_synced: bool,
    ) -> Result<Pin<Box<dyn Stream<Item = BlockWithLogs> + Send + 'a>>>;
}
Expand description

Trait with RPC provider functionality required by the Indexer.

Required Methods§

Source

fn block_number<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Retrieves the latest block number.

Source

fn get_hopr_allowance<'life0, 'async_trait>( &'life0 self, owner: Address, spender: Address, ) -> Pin<Box<dyn Future<Output = Result<HoprBalance>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Queries the HOPR token allowance between owner and spender addresses.

This method queries the HOPR token contract to determine how many tokens the owner has approved the spender to transfer on their behalf.

§Arguments
  • owner - The address that owns the tokens and grants the allowance
  • spender - The address that is approved to spend the tokens
§Returns
  • Result<HoprBalance> - The current allowance amount
Source

fn get_xdai_balance<'life0, 'async_trait>( &'life0 self, address: Address, ) -> Pin<Box<dyn Future<Output = Result<XDaiBalance>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Queries the xDAI (native token) balance for a specific address.

This method queries the current xDAI balance of the specified address from the blockchain.

§Arguments
  • address - The Ethereum address to query the balance for
§Returns
  • Result<XDaiBalance> - The current xDAI balance
Source

fn get_hopr_balance<'life0, 'async_trait>( &'life0 self, address: Address, ) -> Pin<Box<dyn Future<Output = Result<HoprBalance>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Queries the HOPR token balance for a specific address.

This method directly queries the HOPR token contract to get the current token balance of the specified address.

§Arguments
  • address - The Ethereum address to query the balance for
§Returns
  • Result<HoprBalance> - The current HOPR token balance
Source

fn try_stream_logs<'a>( &'a self, start_block_number: u64, filters: FilterSet, is_synced: bool, ) -> Result<Pin<Box<dyn Stream<Item = BlockWithLogs> + Send + 'a>>>

Streams blockchain logs using selective filtering based on synchronization state.

This method intelligently selects which log filters to use based on whether the indexer is currently syncing historical data or processing live events. During initial sync, it uses no_token filters to exclude irrelevant token events. When synced, it uses all filters to capture complete event data.

§Arguments
  • start_block_number - Starting block number for log retrieval
  • filters - Set of categorized filters (all, token, no_token)
  • is_synced - Whether the indexer has completed initial synchronization
§Returns
  • impl Stream<Item = Result<Log>> - Stream of blockchain logs
§Behavior
  • When is_synced is false: Uses filter_set.no_token to reduce log volume
  • When is_synced is true: Uses filter_set.all for complete coverage

Implementors§