LightspeedClient

Struct LightspeedClient 

Source
pub struct LightspeedClient { /* private fields */ }
Expand description

Lightspeed RPC client for prioritized transaction processing

The client handles authentication, tip management, and connection maintenance for interacting with the Lightspeed service. API keys are securely transmitted via the Authorization header on all requests.

§Example

use lightspeed_sdk::{LightspeedClientBuilder, Priority};
use solana_sdk::{signature::Keypair, signer::Signer};
 
let client = LightspeedClientBuilder::new("your-api-key")
    .svs_rpc_url("https://basic.rpc.solanavibestation.com") 
    .build()?;
 
// Send a transaction with automatic tip injection
let payer = Keypair::new();
// ... create instructions ...

Implementations§

Source§

impl LightspeedClient

Source

pub fn new(config: LightspeedConfig) -> Result<Self, LightspeedError>

Creates a new Lightspeed client with the provided configuration

§Arguments
  • config - Client configuration including API key, tier, and settings
§Errors

Returns an error if:

  • The API key is empty
  • The endpoint URL is invalid
  • HTTP client initialization fails
Source

pub async fn start_keep_alive(&self) -> Result<(), LightspeedError>

Starts automatic keep-alive to maintain connection health

Spawns a background task that periodically sends keep-alive requests to prevent connection timeouts. The interval is configured via LightspeedClientBuilder::keep_alive_interval().

§Example
client.start_keep_alive().await?;
// Connection will be maintained automatically
§Errors

Returns LightspeedError::KeepAliveAlreadyRunning if keep-alive is already active.

Source

pub async fn send_transaction<T: Signer>( &self, instructions: Vec<Instruction>, payer: &Pubkey, signers: &[&T], recent_blockhash: Hash, ) -> Result<TransactionResult, LightspeedError>

Sends a transaction with automatic tip injection using the default priority

A tip instruction is automatically appended to your transaction to ensure prioritized processing. The tip amount is determined by the client’s default priority setting.

§Arguments
  • instructions - Transaction instructions to execute
  • payer - Account paying for transaction fees and tip
  • signers - All required transaction signers
  • recent_blockhash - Recent blockhash from the cluster
§Returns

Returns a TransactionResult containing the signature and tip amount.

§Example
let payer = Keypair::new();
let recipient = solana_sdk::pubkey::Pubkey::new_unique();
 
let instruction = system_instruction::transfer(
    &payer.pubkey(),
    &recipient,
    1_000_000,
);
 
let result = client.send_transaction(
    vec![instruction],
    &payer.pubkey(),
    &[&payer],
    Hash::default(), // Use real blockhash in production
).await?;
 
println!("Transaction: {}", result.signature);
println!("Tip paid: {} lamports", result.tip_amount);
Source

pub async fn send_transaction_with_priority<T: Signer>( &self, instructions: Vec<Instruction>, payer: &Pubkey, signers: &[&T], recent_blockhash: Hash, priority: Priority, ) -> Result<TransactionResult, LightspeedError>

Sends a transaction with a specific priority level

Similar to send_transaction but allows overriding the default priority for this specific transaction.

§Arguments
  • instructions - Transaction instructions to execute
  • payer - Account paying for transaction fees and tip
  • signers - All required transaction signers
  • recent_blockhash - Recent blockhash from the cluster
  • priority - Priority level for this transaction
§Priority Levels
  • Priority::Minimum - 0.0001 SOL tip
  • Priority::Standard - 0.001 SOL tip
  • Priority::Rush - 0.005 SOL tip
  • Priority::Custom(lamports) - Custom tip amount
Source

pub async fn send_transaction_with_tip<T: Signer>( &self, instructions: Vec<Instruction>, payer: &Pubkey, signers: &[&T], recent_blockhash: Hash, tip_lamports: u64, ) -> Result<TransactionResult, LightspeedError>

Sends a transaction with a custom tip amount

Provides direct control over the tip amount in lamports.

§Arguments
  • instructions - Transaction instructions to execute
  • payer - Account paying for transaction fees and tip
  • signers - All required transaction signers
  • recent_blockhash - Recent blockhash from the cluster
  • tip_lamports - Tip amount in lamports
Source

pub fn create_tip_instruction(&self, payer: &Pubkey) -> Instruction

Creates a tip instruction using the default priority

Use this when manually constructing transactions that need tip instructions.

§Arguments
  • payer - Account that will pay the tip
Source

pub fn create_tip_instruction_with_priority( &self, payer: &Pubkey, priority: Priority, ) -> Instruction

Creates a tip instruction with a specific priority

§Arguments
  • payer - Account that will pay the tip
  • priority - Priority level determining tip amount
Source

pub fn create_tip_instruction_with_tip( &self, payer: &Pubkey, tip_lamports: u64, ) -> Instruction

Creates a tip instruction with a custom amount

§Arguments
  • payer - Account that will pay the tip
  • tip_lamports - Tip amount in lamports
Source

pub async fn send_prebuilt_transaction( &self, transaction: &Transaction, ) -> Result<Signature, LightspeedError>

Sends a pre-built transaction through Lightspeed

The transaction should already include a tip instruction. This method provides direct control for advanced use cases.

§Arguments
  • transaction - Signed transaction including tip instruction
§Example
let payer = Keypair::new();
 
// Build transaction with tip
let tip = client.create_tip_instruction(&payer.pubkey());
let mut tx = Transaction::new_with_payer(
    &[tip],
    Some(&payer.pubkey()),
);
tx.sign(&[&payer], Hash::default());
 
// Send through Lightspeed
let signature = client.send_prebuilt_transaction(&tx).await?;
Source

pub fn set_tip_address( &mut self, new_tip_address: &str, ) -> Result<(), LightspeedError>

Updates the tip recipient address

§Arguments
  • new_tip_address - New tip address as a base58 string
§Errors

Returns an error if the address is not a valid Solana public key.

Source

pub fn get_tip_address(&self) -> Pubkey

Returns the current tip recipient address

Source

pub async fn keep_alive(&self) -> Result<(), LightspeedError>

Sends a keep-alive request to maintain connection

This is called automatically when keep-alive is enabled via start_keep_alive(). Can also be called manually if needed.

Source

pub async fn stop_keep_alive(&self) -> bool

Stops the automatic keep-alive task

§Returns

Returns true if a keep-alive task was running and has been stopped, false if no task was running.

§Example
client.start_keep_alive().await?;
// ... do work ...
let was_running = client.stop_keep_alive().await;
assert!(was_running);

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,