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: Option<UnboundedSender<BlockchainMessage>>,
cancellation_token: CancellationToken,
) -> Self
pub fn new( chain: SharedChain, tx: Option<UnboundedSender<BlockchainMessage>>, cancellation_token: CancellationToken, ) -> Self
Creates a new HyperSyncClient instance for the given chain and message sender.
§Panics
Panics if:
- The chain’s
hypersync_urlis invalid. - The
ENVIO_API_TOKENenvironment variable is not set or invalid. - The underlying client cannot be initialized.
pub fn get_pool_address(&self, instrument_id: InstrumentId) -> Option<&Address>
Sourcepub async fn update_dex_event_stream(
&mut self,
dex: DexType,
contract_addresses: Vec<Address>,
event_signatures: Vec<String>,
)
pub async fn update_dex_event_stream( &mut self, dex: DexType, contract_addresses: Vec<Address>, event_signatures: Vec<String>, )
Starts, refreshes, or stops the live DEX event stream for one DEX.
The stream query is open-ended (to_block = None) and the background task resumes from the
last HyperSync next_block whenever the SDK stream reaches the current indexed tip.
Sourcepub async fn request_contract_events_stream(
&self,
from_block: u64,
to_block: Option<u64>,
contract_address: &Address,
topics: Vec<&str>,
) -> impl Stream<Item = PoolEventStreamItem> + use<>
pub async fn request_contract_events_stream( &self, from_block: u64, to_block: Option<u64>, contract_address: &Address, topics: Vec<&str>, ) -> impl Stream<Item = PoolEventStreamItem> + use<>
Creates a stream of contract event logs matching the specified criteria.
§Panics
Panics if the contract address cannot be parsed as a valid Ethereum address.
Sourcepub async fn disconnect(&mut self)
pub async 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
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.
§Panics
Panics if the stream creation or block transformation fails.
Sourcepub fn subscribe_blocks(&mut self)
pub fn subscribe_blocks(&mut self)
Starts a background task that continuously polls for new blockchain blocks.
§Panics
Panics if client height requests or block transformations fail.
Sourcepub async fn unsubscribe_blocks(&mut self)
pub async fn unsubscribe_blocks(&mut self)
Unsubscribes from new blocks by stopping the background watch task.
Trait Implementations§
Source§impl Debug for HyperSyncClient
impl Debug for HyperSyncClient
Source§impl Drop for HyperSyncClient
impl Drop for HyperSyncClient
Auto Trait Implementations§
impl Freeze for HyperSyncClient
impl RefUnwindSafe for HyperSyncClient
impl Send for HyperSyncClient
impl Sync for HyperSyncClient
impl Unpin for HyperSyncClient
impl UnsafeUnpin for HyperSyncClient
impl UnwindSafe for HyperSyncClient
Blanket Implementations§
impl<T> Allocation for T
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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