Thanks to visit codestin.com
Credit goes to docs.rs

Skip to main content

Crate allenhark_slipstream

Crate allenhark_slipstream 

Source
Expand description

§allenhark-slipstream - Rust SDK for Slipstream

Slipstream is a sender-agnostic Solana transaction relay system with leader-proximity-aware routing.

§Quick Start

use allenhark_slipstream::{Config, SlipstreamClient};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Create configuration
    let config = Config::builder()
        .api_key("sk_test_12345678")
        .region("us-west")
        .build()?;

    // Connect to Slipstream
    let client = SlipstreamClient::connect(config).await?;

    // Submit a transaction
    let tx_bytes = vec![/* signed transaction bytes */];
    let result = client.submit_transaction(&tx_bytes).await?;
    println!("Transaction signature: {:?}", result.signature);

    Ok(())
}

§Streaming

The SDK supports real-time streaming of leader hints, tip instructions, and priority fees:

use allenhark_slipstream::{Config, SlipstreamClient};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let config = Config::builder()
        .api_key("sk_test_12345678")
        .leader_hints(true)
        .build()?;

    let client = SlipstreamClient::connect(config).await?;

    // Subscribe to leader hints
    let mut hints = client.subscribe_leader_hints().await?;
    while let Some(hint) = hints.recv().await {
        println!("Preferred region: {} (confidence: {})",
            hint.preferred_region, hint.confidence);
    }

    Ok(())
}

§Protocol Fallback

The SDK automatically falls back through protocols if the preferred one is unavailable:

  1. QUIC (2s timeout) - Primary high-performance protocol
  2. gRPC (3s timeout) - Streaming fallback
  3. WebSocket (3s timeout) - Browser-compatible streaming
  4. HTTP (5s timeout) - Polling fallback

§Features

  • Persistent connections - Single connection reused for all operations
  • Auto-reconnect - Automatic reconnection on connection loss
  • Leader hints - Real-time region recommendations
  • Tip instructions - Dynamic tip wallet selection
  • Priority fees - Compute unit price recommendations

Re-exports§

pub use client::SlipstreamClient;
pub use config::BackoffStrategy;
pub use config::Config;
pub use config::ConfigBuilder;
pub use config::PriorityFeeConfig;
pub use config::Protocol;
pub use config::ProtocolTimeouts;
pub use error::Result;
pub use error::SdkError;
pub use types::AlternativeSender;
pub use types::ConnectionInfo;
pub use types::ConnectionState;
pub use types::ConnectionStatus;
pub use types::LeaderHint;
pub use types::LeaderHintMetadata;
pub use types::PerformanceMetrics;
pub use types::PriorityFee;
pub use types::PriorityFeeSpeed;
pub use types::RateLimitInfo;
pub use types::RoutingInfo;
pub use types::SubmitOptions;
pub use types::TipInstruction;
pub use types::TransactionError;
pub use types::TransactionResult;
pub use types::TransactionStatus;

Modules§

client
SlipstreamClient - Main SDK entry point
config
Configuration types for the Slipstream SDK
connection
Connection management and protocol implementations
error
Error types for the Slipstream SDK
types
Message types for the Slipstream SDK

Constants§

VERSION
SDK version