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
impl LightspeedClient
Sourcepub fn new(config: LightspeedConfig) -> Result<Self, LightspeedError>
pub fn new(config: LightspeedConfig) -> Result<Self, LightspeedError>
Sourcepub async fn start_keep_alive(&self) -> Result<(), LightspeedError>
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.
Sourcepub async fn send_transaction<T: Signer>(
&self,
instructions: Vec<Instruction>,
payer: &Pubkey,
signers: &[&T],
recent_blockhash: Hash,
) -> Result<TransactionResult, LightspeedError>
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 executepayer- Account paying for transaction fees and tipsigners- All required transaction signersrecent_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);Sourcepub async fn send_transaction_with_priority<T: Signer>(
&self,
instructions: Vec<Instruction>,
payer: &Pubkey,
signers: &[&T],
recent_blockhash: Hash,
priority: Priority,
) -> Result<TransactionResult, LightspeedError>
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 executepayer- Account paying for transaction fees and tipsigners- All required transaction signersrecent_blockhash- Recent blockhash from the clusterpriority- Priority level for this transaction
§Priority Levels
Priority::Minimum- 0.0001 SOL tipPriority::Standard- 0.001 SOL tipPriority::Rush- 0.005 SOL tipPriority::Custom(lamports)- Custom tip amount
Sourcepub 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>
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 executepayer- Account paying for transaction fees and tipsigners- All required transaction signersrecent_blockhash- Recent blockhash from the clustertip_lamports- Tip amount in lamports
Sourcepub fn create_tip_instruction(&self, payer: &Pubkey) -> Instruction
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
Sourcepub fn create_tip_instruction_with_priority(
&self,
payer: &Pubkey,
priority: Priority,
) -> Instruction
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 tippriority- Priority level determining tip amount
Sourcepub fn create_tip_instruction_with_tip(
&self,
payer: &Pubkey,
tip_lamports: u64,
) -> Instruction
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 tiptip_lamports- Tip amount in lamports
Sourcepub async fn send_prebuilt_transaction(
&self,
transaction: &Transaction,
) -> Result<Signature, LightspeedError>
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?;Sourcepub fn set_tip_address(
&mut self,
new_tip_address: &str,
) -> Result<(), LightspeedError>
pub fn set_tip_address( &mut self, new_tip_address: &str, ) -> Result<(), LightspeedError>
Sourcepub fn get_tip_address(&self) -> Pubkey
pub fn get_tip_address(&self) -> Pubkey
Returns the current tip recipient address
Sourcepub async fn keep_alive(&self) -> Result<(), LightspeedError>
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.
Sourcepub async fn stop_keep_alive(&self) -> bool
pub async fn stop_keep_alive(&self) -> bool
Auto Trait Implementations§
impl Freeze for LightspeedClient
impl !RefUnwindSafe for LightspeedClient
impl Send for LightspeedClient
impl Sync for LightspeedClient
impl Unpin for LightspeedClient
impl !UnwindSafe for LightspeedClient
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
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