diff --git a/tpu-client-next/src/transaction_batch.rs b/tpu-client-next/src/transaction_batch.rs index a81461a9526efc..a10973bbbbf4f9 100644 --- a/tpu-client-next/src/transaction_batch.rs +++ b/tpu-client-next/src/transaction_batch.rs @@ -1,19 +1,20 @@ //! This module holds [`TransactionBatch`] structure. -use solana_time_utils::timestamp; +use {solana_time_utils::timestamp, tokio_util::bytes::Bytes}; /// Batch of generated transactions timestamp is used to discard batches which /// are too old to have valid blockhash. #[derive(Clone, PartialEq)] pub struct TransactionBatch { wired_transactions: Vec, + // Time of creation of this batch, used for batch timeouts timestamp: u64, } -type WiredTransaction = Vec; +type WiredTransaction = Bytes; impl IntoIterator for TransactionBatch { - type Item = Vec; + type Item = Bytes; type IntoIter = std::vec::IntoIter; fn into_iter(self) -> Self::IntoIter { self.wired_transactions.into_iter() @@ -21,7 +22,15 @@ impl IntoIterator for TransactionBatch { } impl TransactionBatch { - pub fn new(wired_transactions: Vec) -> Self { + pub fn new(wired_transactions: Vec) -> Self + where + T: AsRef<[u8]> + Send + 'static, + { + let wired_transactions = wired_transactions + .into_iter() + .map(|v| Bytes::from_owner(v)) + .collect(); + Self { wired_transactions, timestamp: timestamp(),