Rust
Yellowstone's own Rust client, yellowstone-grpc-client, streams from Slipstream unchanged.
cargo add yellowstone-grpc-client yellowstone-grpc-proto tokio futures
Build the client with your region's endpoint (https://slipstream-fra2.reflow.xyz today), an API key as the x-token and TLS with the system's roots, then subscribe.
use futures::StreamExt;
use std::collections::HashMap;
use yellowstone_grpc_client::{ClientTlsConfig, GeyserGrpcClient};
use yellowstone_grpc_proto::prelude::{CommitmentLevel, SubscribeRequest, SubscribeRequestFilterSlots};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut client = GeyserGrpcClient::build_from_shared(std::env::var("SLIPSTREAM_ENDPOINT")?)?
.x_token(Some(std::env::var("SLIPSTREAM_KEY")?))?
.tls_config(ClientTlsConfig::new().with_native_roots())?
.connect()
.await?;
let request = SubscribeRequest {
slots: HashMap::from([("slots".to_owned(), SubscribeRequestFilterSlots::default())]),
commitment: Some(CommitmentLevel::Processed as i32),
..Default::default()
};
let (_sink, mut stream) = client.subscribe_with_request(Some(request)).await?;
while let Some(update) = stream.next().await {
println!("{:?}", update?.update_oneof);
}
Ok(())
}
The sink half of the pair takes a new SubscribeRequest to change the filters without reconnecting. The repository's examples cover every kind of update.