Skip to content

Commit c0b6b73

Browse files
authored
Merge pull request #42 from helium/madninja/tpu_conduit
Refactor transaction sender
2 parents fbc5541 + ba1c559 commit c0b6b73

File tree

7 files changed

+202
-228
lines changed

7 files changed

+202
-228
lines changed

solana-transaction-utils/src/error.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use solana_sdk::{message::CompileError, transaction::TransactionError};
2-
use solana_tpu_client::tpu_client::TpuSenderError;
32

43
#[derive(Debug, thiserror::Error, Clone)]
54
pub enum Error {
@@ -15,8 +14,8 @@ pub enum Error {
1514
SignerError(String),
1615
#[error("Ix group too large")]
1716
IxGroupTooLarge,
18-
#[error("TPU sender error: {0}")]
19-
TpuSenderError(String),
17+
#[error("Max retries exceeded")]
18+
MaxRetriesExceeded,
2019
#[error("Transaction error: {0}")]
2120
TransactionError(TransactionError),
2221
#[error("Simulated transaction error: {0}")]
@@ -29,8 +28,6 @@ pub enum Error {
2928
FeeTooHigh,
3029
#[error("Transaction has failed too many retries and gone stale")]
3130
StaleTransaction,
32-
#[error("System time error: {0}")]
33-
SystemTimeError(String),
3431
#[error("message channel closed")]
3532
ChannelClosed,
3633
}
@@ -41,12 +38,6 @@ impl From<solana_client::client_error::ClientError> for Error {
4138
}
4239
}
4340

44-
impl From<TpuSenderError> for Error {
45-
fn from(value: TpuSenderError) -> Self {
46-
Self::TpuSenderError(value.to_string())
47-
}
48-
}
49-
5041
impl<T> From<tokio::sync::mpsc::error::SendError<T>> for Error {
5142
fn from(_value: tokio::sync::mpsc::error::SendError<T>) -> Self {
5243
Self::ChannelClosed

solana-transaction-utils/src/send_and_confirm_transactions_in_parallel.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ use solana_sdk::{
2323
signers::Signers,
2424
transaction::{TransactionError, VersionedTransaction},
2525
};
26-
use solana_tpu_client::tpu_client::TpuSenderError;
2726
use tokio::{sync::RwLock, task::JoinHandle};
2827

2928
use crate::error::Error;
@@ -217,7 +216,7 @@ async fn send_transaction_with_rpc_fallback(
217216
context.error_map.insert(index, transaction_error.clone());
218217
}
219218
_ => {
220-
return Err(TpuSenderError::from(e).into());
219+
return Err(crate::Error::from(e));
221220
}
222221
}
223222
}
@@ -521,6 +520,6 @@ pub async fn send_and_confirm_transactions_in_parallel<T: Signers + ?Sized>(
521520
}
522521
Ok(transaction_errors)
523522
} else {
524-
Err(TpuSenderError::Custom("Max retries exceeded".into()).into())
523+
Err(crate::Error::MaxRetriesExceeded)
525524
}
526525
}

0 commit comments

Comments
 (0)