pub struct BlockchainDataClient {
pub chain: SharedChain,
/* private fields */
}
Expand description
A comprehensive client for interacting with blockchain data from multiple sources.
The BlockchainDataClient
serves as a facade that coordinates between different blockchain
data providers, caching mechanisms, and contract interactions. It provides a unified interface
for retrieving and processing blockchain data, particularly focused on DeFi protocols.
This client supports two primary data sources:
- Direct RPC connections to blockchain nodes (via WebSocket).
- HyperSync API for efficient historical data queries.
Fields§
§chain: SharedChain
The blockchain being targeted by this client instance.
Implementations§
Source§impl BlockchainDataClient
impl BlockchainDataClient
Sourcepub fn new(chain: SharedChain, config: BlockchainAdapterConfig) -> Self
pub fn new(chain: SharedChain, config: BlockchainAdapterConfig) -> Self
Creates a new BlockchainDataClient
instance for the specified chain and configuration.
§Panics
Panics if use_hypersync_for_live_data
is false and wss_rpc_url
is None
in the provided config.
Sourcepub async fn initialize_cache_database(
&mut self,
pg_connect_options: Option<PostgresConnectOptions>,
)
pub async fn initialize_cache_database( &mut self, pg_connect_options: Option<PostgresConnectOptions>, )
Initializes the database connection for the blockchain cache.
Sourcepub async fn connect(&mut self) -> Result<()>
pub async fn connect(&mut self) -> Result<()>
Establishes connections to the data providers and cache.
Sourcepub fn disconnect(&mut self) -> Result<()>
pub fn disconnect(&mut self) -> Result<()>
Gracefully disconnects from all data providers.
Sourcepub async fn sync_exchange_pools(
&mut self,
dex_id: &str,
from_block: Option<u32>,
) -> Result<()>
pub async fn sync_exchange_pools( &mut self, dex_id: &str, from_block: Option<u32>, ) -> Result<()>
Synchronizes token and pool data for a specific DEX from the specified block.
Sourcepub async fn register_exchange(&mut self, dex: DexExtended) -> Result<()>
pub async fn register_exchange(&mut self, dex: DexExtended) -> Result<()>
Registers a decentralized exchange with the client.
Sourcepub async fn process_hypersync_message(&mut self)
pub async fn process_hypersync_message(&mut self)
Processes incoming messages from the HyperSync client.
Sourcepub async fn process_rpc_message(&mut self)
pub async fn process_rpc_message(&mut self)
Processes incoming messages from the RPC client.
Sourcepub async fn subscribe_blocks(&mut self)
pub async fn subscribe_blocks(&mut self)
Subscribes to new blockchain blocks from the available data source.
§Panics
Panics if using the RPC client and the block subscription request fails.
Sourcepub async fn unsubscribe_blocks(&mut self)
pub async fn unsubscribe_blocks(&mut self)
Unsubscribes from block events.
§Panics
Panics if using the RPC client and the block unsubscription request fails.
Trait Implementations§
Source§impl DataClient for BlockchainDataClient
impl DataClient for BlockchainDataClient
Source§fn connect<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn connect<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn disconnect<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn disconnect<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn is_connected(&self) -> bool
fn is_connected(&self) -> bool
true
if the client is currently connected.Source§fn is_disconnected(&self) -> bool
fn is_disconnected(&self) -> bool
true
if the client is currently disconnected.Source§fn subscribe(&mut self, _cmd: &SubscribeCustomData) -> Result<()>
fn subscribe(&mut self, _cmd: &SubscribeCustomData) -> Result<()>
Source§fn subscribe_instruments(&mut self, _cmd: &SubscribeInstruments) -> Result<()>
fn subscribe_instruments(&mut self, _cmd: &SubscribeInstruments) -> Result<()>
Source§fn subscribe_instrument(&mut self, _cmd: &SubscribeInstrument) -> Result<()>
fn subscribe_instrument(&mut self, _cmd: &SubscribeInstrument) -> Result<()>
Source§fn subscribe_instrument_status(
&mut self,
_cmd: &SubscribeInstrumentStatus,
) -> Result<()>
fn subscribe_instrument_status( &mut self, _cmd: &SubscribeInstrumentStatus, ) -> Result<()>
Source§fn subscribe_instrument_close(
&mut self,
_cmd: &SubscribeInstrumentClose,
) -> Result<()>
fn subscribe_instrument_close( &mut self, _cmd: &SubscribeInstrumentClose, ) -> Result<()>
Source§fn subscribe_quotes(&mut self, _cmd: &SubscribeQuotes) -> Result<()>
fn subscribe_quotes(&mut self, _cmd: &SubscribeQuotes) -> Result<()>
Source§fn subscribe_trades(&mut self, _cmd: &SubscribeTrades) -> Result<()>
fn subscribe_trades(&mut self, _cmd: &SubscribeTrades) -> Result<()>
Source§fn subscribe_bars(&mut self, _cmd: &SubscribeBars) -> Result<()>
fn subscribe_bars(&mut self, _cmd: &SubscribeBars) -> Result<()>
Source§fn subscribe_book_snapshots(
&mut self,
_cmd: &SubscribeBookSnapshots,
) -> Result<()>
fn subscribe_book_snapshots( &mut self, _cmd: &SubscribeBookSnapshots, ) -> Result<()>
Source§fn subscribe_book_deltas(&mut self, _cmd: &SubscribeBookDeltas) -> Result<()>
fn subscribe_book_deltas(&mut self, _cmd: &SubscribeBookDeltas) -> Result<()>
Source§fn subscribe_book_depth10(&mut self, _cmd: &SubscribeBookDepth10) -> Result<()>
fn subscribe_book_depth10(&mut self, _cmd: &SubscribeBookDepth10) -> Result<()>
Source§fn subscribe_index_prices(&mut self, _cmd: &SubscribeIndexPrices) -> Result<()>
fn subscribe_index_prices(&mut self, _cmd: &SubscribeIndexPrices) -> Result<()>
Source§fn subscribe_mark_prices(&mut self, _cmd: &SubscribeMarkPrices) -> Result<()>
fn subscribe_mark_prices(&mut self, _cmd: &SubscribeMarkPrices) -> Result<()>
Source§fn unsubscribe(&mut self, _cmd: &UnsubscribeCustomData) -> Result<()>
fn unsubscribe(&mut self, _cmd: &UnsubscribeCustomData) -> Result<()>
Source§fn unsubscribe_instruments(
&mut self,
_cmd: &UnsubscribeInstruments,
) -> Result<()>
fn unsubscribe_instruments( &mut self, _cmd: &UnsubscribeInstruments, ) -> Result<()>
Source§fn unsubscribe_instrument(&mut self, _cmd: &UnsubscribeInstrument) -> Result<()>
fn unsubscribe_instrument(&mut self, _cmd: &UnsubscribeInstrument) -> Result<()>
Source§fn unsubscribe_instrument_status(
&mut self,
_cmd: &UnsubscribeInstrumentStatus,
) -> Result<()>
fn unsubscribe_instrument_status( &mut self, _cmd: &UnsubscribeInstrumentStatus, ) -> Result<()>
Source§fn unsubscribe_instrument_close(
&mut self,
_cmd: &UnsubscribeInstrumentClose,
) -> Result<()>
fn unsubscribe_instrument_close( &mut self, _cmd: &UnsubscribeInstrumentClose, ) -> Result<()>
Source§fn unsubscribe_quotes(&mut self, _cmd: &UnsubscribeQuotes) -> Result<()>
fn unsubscribe_quotes(&mut self, _cmd: &UnsubscribeQuotes) -> Result<()>
Source§fn unsubscribe_trades(&mut self, _cmd: &UnsubscribeTrades) -> Result<()>
fn unsubscribe_trades(&mut self, _cmd: &UnsubscribeTrades) -> Result<()>
Source§fn unsubscribe_bars(&mut self, _cmd: &UnsubscribeBars) -> Result<()>
fn unsubscribe_bars(&mut self, _cmd: &UnsubscribeBars) -> Result<()>
Source§fn unsubscribe_book_snapshots(
&mut self,
_cmd: &UnsubscribeBookSnapshots,
) -> Result<()>
fn unsubscribe_book_snapshots( &mut self, _cmd: &UnsubscribeBookSnapshots, ) -> Result<()>
Source§fn unsubscribe_book_deltas(
&mut self,
_cmd: &UnsubscribeBookDeltas,
) -> Result<()>
fn unsubscribe_book_deltas( &mut self, _cmd: &UnsubscribeBookDeltas, ) -> Result<()>
Source§fn unsubscribe_book_depth10(
&mut self,
_cmd: &UnsubscribeBookDepth10,
) -> Result<()>
fn unsubscribe_book_depth10( &mut self, _cmd: &UnsubscribeBookDepth10, ) -> Result<()>
Source§fn unsubscribe_index_prices(
&mut self,
_cmd: &UnsubscribeIndexPrices,
) -> Result<()>
fn unsubscribe_index_prices( &mut self, _cmd: &UnsubscribeIndexPrices, ) -> Result<()>
Source§fn unsubscribe_mark_prices(
&mut self,
_cmd: &UnsubscribeMarkPrices,
) -> Result<()>
fn unsubscribe_mark_prices( &mut self, _cmd: &UnsubscribeMarkPrices, ) -> Result<()>
Source§fn request_instruments(&self, _request: &RequestInstruments) -> Result<()>
fn request_instruments(&self, _request: &RequestInstruments) -> Result<()>
Source§fn request_instrument(&self, _request: &RequestInstrument) -> Result<()>
fn request_instrument(&self, _request: &RequestInstrument) -> Result<()>
Source§fn request_quotes(&self, _request: &RequestQuotes) -> Result<()>
fn request_quotes(&self, _request: &RequestQuotes) -> Result<()>
Source§fn request_trades(&self, _request: &RequestTrades) -> Result<()>
fn request_trades(&self, _request: &RequestTrades) -> Result<()>
Source§fn request_bars(&self, _request: &RequestBars) -> Result<()>
fn request_bars(&self, _request: &RequestBars) -> Result<()>
Auto Trait Implementations§
impl Freeze for BlockchainDataClient
impl !RefUnwindSafe for BlockchainDataClient
impl Send for BlockchainDataClient
impl Sync for BlockchainDataClient
impl Unpin for BlockchainDataClient
impl !UnwindSafe for BlockchainDataClient
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