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>>,
) -> Self
pub fn new( chain: SharedChain, tx: Option<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.
pub fn get_pool_address(&self, instrument_id: InstrumentId) -> Option<&Address>
Sourcepub async fn process_block_dex_contract_events(
&self,
dex: &DexType,
block: u64,
contract_addresses: Vec<Address>,
swap_event_encoded_signature: String,
mint_event_encoded_signature: String,
burn_event_encoded_signature: String,
)
pub async fn process_block_dex_contract_events( &self, dex: &DexType, block: u64, contract_addresses: Vec<Address>, swap_event_encoded_signature: String, mint_event_encoded_signature: String, burn_event_encoded_signature: String, )
Processes DEX contract events for a specific block.
§Panics
Panics if the DEX extended configuration cannot be retrieved or if stream creation fails.
Sourcepub async fn request_contract_events_stream(
&self,
from_block: u64,
to_block: Option<u64>,
contract_address: &Address,
topics: Vec<&str>,
) -> impl Stream<Item = Log> + 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 = Log> + 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 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
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 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> 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