Skip to content

Refactor transaction sender #42

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions solana-transaction-utils/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use solana_sdk::{message::CompileError, transaction::TransactionError};
use solana_tpu_client::tpu_client::TpuSenderError;

#[derive(Debug, thiserror::Error, Clone)]
pub enum Error {
Expand All @@ -15,8 +14,8 @@ pub enum Error {
SignerError(String),
#[error("Ix group too large")]
IxGroupTooLarge,
#[error("TPU sender error: {0}")]
TpuSenderError(String),
#[error("Max retries exceeded")]
MaxRetriesExceeded,
#[error("Transaction error: {0}")]
TransactionError(TransactionError),
#[error("Simulated transaction error: {0}")]
Expand All @@ -29,8 +28,6 @@ pub enum Error {
FeeTooHigh,
#[error("Transaction has failed too many retries and gone stale")]
StaleTransaction,
#[error("System time error: {0}")]
SystemTimeError(String),
#[error("message channel closed")]
ChannelClosed,
}
Expand All @@ -41,12 +38,6 @@ impl From<solana_client::client_error::ClientError> for Error {
}
}

impl From<TpuSenderError> for Error {
fn from(value: TpuSenderError) -> Self {
Self::TpuSenderError(value.to_string())
}
}

impl<T> From<tokio::sync::mpsc::error::SendError<T>> for Error {
fn from(_value: tokio::sync::mpsc::error::SendError<T>) -> Self {
Self::ChannelClosed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ use solana_sdk::{
signers::Signers,
transaction::{TransactionError, VersionedTransaction},
};
use solana_tpu_client::tpu_client::TpuSenderError;
use tokio::{sync::RwLock, task::JoinHandle};

use crate::error::Error;
Expand Down Expand Up @@ -217,7 +216,7 @@ async fn send_transaction_with_rpc_fallback(
context.error_map.insert(index, transaction_error.clone());
}
_ => {
return Err(TpuSenderError::from(e).into());
return Err(crate::Error::from(e));
}
}
}
Expand Down Expand Up @@ -521,6 +520,6 @@ pub async fn send_and_confirm_transactions_in_parallel<T: Signers + ?Sized>(
}
Ok(transaction_errors)
} else {
Err(TpuSenderError::Custom("Max retries exceeded".into()).into())
Err(crate::Error::MaxRetriesExceeded)
}
}
Loading