pub struct HyperSyncClient { /* private fields */ }
Expand description
A client for interacting with a HyperSync API to retrieve blockchain data.
Implementations§
Source§impl HyperSyncClient
impl HyperSyncClient
Sourcepub fn new(chain: SharedChain, tx: UnboundedSender<BlockchainMessage>) -> Self
pub fn new(chain: SharedChain, tx: UnboundedSender<BlockchainMessage>) -> Self
Creates a new HyperSyncClient
instance for the given chain and message sender.
§Panics
Panics if the chain’s hypersync_url
is invalid or if the underlying client cannot be initialized.
Sourcepub async fn request_contract_events_stream(
&self,
from_block: u64,
to_block: Option<u64>,
contract_address: &str,
event_signature: &str,
additional_topics: Vec<String>,
) -> impl Stream<Item = Log> + use<>
pub async fn request_contract_events_stream( &self, from_block: u64, to_block: Option<u64>, contract_address: &str, event_signature: &str, additional_topics: Vec<String>, ) -> impl Stream<Item = Log> + use<>
Creates a stream of contract event logs matching the specified criteria.
Sourcepub fn disconnect(&mut self)
pub fn disconnect(&mut self)
Disconnects from the HyperSync service and stops all background tasks.
Sourcepub async fn current_block(&self) -> u64
pub async fn current_block(&self) -> u64
Returns the current block
Sourcepub async fn request_blocks_stream(
&self,
from_block: u64,
to_block: Option<u64>,
) -> impl Stream<Item = Block>
pub async fn request_blocks_stream( &self, from_block: u64, to_block: Option<u64>, ) -> impl Stream<Item = Block>
Creates a stream that yields blockchain blocks within the specified range.
Sourcepub fn subscribe_blocks(&mut self)
pub fn subscribe_blocks(&mut self)
Starts a background task that continuously polls for new blockchain blocks.
Sourcepub fn subscribe_pool_swaps(&mut self, pool_address: Address)
pub fn subscribe_pool_swaps(&mut self, pool_address: Address)
Subscribes to swap events for a specific pool address.
Sourcepub fn unsubscribe_pool_swaps(&mut self, pool_address: Address)
pub fn unsubscribe_pool_swaps(&mut self, pool_address: Address)
Unsubscribes from swap events for a specific pool address.
Sourcepub fn unsubscribe_all_swaps(&mut self)
pub fn unsubscribe_all_swaps(&mut self)
Unsubscribes from all swap events by stopping all swap background tasks.
Sourcepub fn unsubscribe_blocks(&mut self)
pub fn unsubscribe_blocks(&mut self)
Unsubscribes from new blocks by stopping the background watch task.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for HyperSyncClient
impl !RefUnwindSafe for HyperSyncClient
impl Send for HyperSyncClient
impl Sync for HyperSyncClient
impl Unpin for HyperSyncClient
impl !UnwindSafe for HyperSyncClient
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
§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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
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>
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