pub struct EnhancedWebsocket { /* private fields */ }
Expand description
A client for subscribing to transaction or account updates from a Helius (Geyser) enhanced websocket server.
Forked from Solana’s [PubsubClient
].
Implementations§
Source§impl EnhancedWebsocket
impl EnhancedWebsocket
Sourcepub async fn new(
url: &str,
ping_interval_secs: Option<u64>,
pong_timeout_secs: Option<u64>,
) -> Result<Self>
pub async fn new( url: &str, ping_interval_secs: Option<u64>, pong_timeout_secs: Option<u64>, ) -> Result<Self>
Expects enhanced websocket endpoint: wss://atlas-mainnet.helius-rpc.com?api-key=<API_KEY>
pub async fn shutdown(self) -> Result<()>
pub async fn set_node_version(&self, version: Version) -> Result<()>
Sourcepub async fn transaction_subscribe(
&self,
config: RpcTransactionsConfig,
) -> Result<(BoxStream<'_, TransactionNotification>, Box<dyn FnOnce() -> BoxFuture<'static, ()> + Send>)>
pub async fn transaction_subscribe( &self, config: RpcTransactionsConfig, ) -> Result<(BoxStream<'_, TransactionNotification>, Box<dyn FnOnce() -> BoxFuture<'static, ()> + Send>)>
Stream transactions with numerous configurations and filters to choose from.
§Example
use helius::Helius;
use helius::error::Result;
use helius::types::{Cluster, RpcTransactionsConfig, TransactionSubscribeFilter, TransactionSubscribeOptions};
use solana_sdk::pubkey;
use tokio_stream::StreamExt;
#[tokio::main]
async fn main() -> Result<()> {
let helius = Helius::new("your_api_key", Cluster::MainnetBeta).expect("Failed to create a Helius client");
// you may monitor transactions for any pubkey, this is just an example.
let key = pubkey!("BtsmiEEvnSuUnKxqXj2PZRYpPJAc7C34mGz8gtJ1DAaH");
let config = RpcTransactionsConfig {
filter: TransactionSubscribeFilter::standard(&key),
options: TransactionSubscribeOptions::default(),
};
if let Some(ws) = helius.ws() {
let (mut stream, _unsub) = ws.transaction_subscribe(config).await?;
while let Some(event) = stream.next().await {
println!("{:#?}", event);
}
}
Ok(())
}
Sourcepub async fn account_subscribe(
&self,
pubkey: &Pubkey,
config: Option<RpcAccountInfoConfig>,
) -> Result<(BoxStream<'_, RpcResponse<UiAccount>>, Box<dyn FnOnce() -> BoxFuture<'static, ()> + Send>)>
pub async fn account_subscribe( &self, pubkey: &Pubkey, config: Option<RpcAccountInfoConfig>, ) -> Result<(BoxStream<'_, RpcResponse<UiAccount>>, Box<dyn FnOnce() -> BoxFuture<'static, ()> + Send>)>
Stream accounts with numerous configurations and filters to choose from.
§Example
use helius::Helius;
use helius::error::Result;
use helius::types::{Cluster, RpcTransactionsConfig, TransactionSubscribeFilter, TransactionSubscribeOptions};
use solana_sdk::pubkey;
use tokio_stream::StreamExt;
#[tokio::main]
async fn main() -> Result<()> {
let helius = Helius::new("your_api_key", Cluster::MainnetBeta).expect("Failed to create a Helius client");
// you may monitor updates for any account pubkey, this is just an example.
let key = pubkey!("BtsmiEEvnSuUnKxqXj2PZRYpPJAc7C34mGz8gtJ1DAaH");
if let Some(ws) = helius.ws() {
let (mut stream, _unsub) = ws.account_subscribe(&key, None).await?;
while let Some(event) = stream.next().await {
println!("{:#?}", event);
}
}
Ok(())
}
Auto Trait Implementations§
impl !Freeze for EnhancedWebsocket
impl !RefUnwindSafe for EnhancedWebsocket
impl Send for EnhancedWebsocket
impl Sync for EnhancedWebsocket
impl Unpin for EnhancedWebsocket
impl !UnwindSafe for EnhancedWebsocket
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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