2022-03-09 21:33:05 -05:00
|
|
|
use {
|
|
|
|
solana_sdk::{transaction::Transaction, transport::Result as TransportResult},
|
|
|
|
std::net::{SocketAddr, UdpSocket},
|
|
|
|
};
|
|
|
|
|
|
|
|
pub trait TpuConnection {
|
2022-03-15 18:16:35 -04:00
|
|
|
fn new(client_socket: UdpSocket, tpu_addr: SocketAddr) -> Self
|
|
|
|
where
|
|
|
|
Self: Sized;
|
2022-03-09 21:33:05 -05:00
|
|
|
|
|
|
|
fn tpu_addr(&self) -> &SocketAddr;
|
|
|
|
|
|
|
|
fn send_transaction(&self, tx: &Transaction) -> TransportResult<()> {
|
|
|
|
let data = bincode::serialize(tx).expect("serialize Transaction in send_transaction");
|
2022-03-17 13:31:11 -07:00
|
|
|
self.send_wire_transaction(&data)
|
2022-03-09 21:33:05 -05:00
|
|
|
}
|
|
|
|
|
2022-03-17 13:31:11 -07:00
|
|
|
fn send_wire_transaction(&self, data: &[u8]) -> TransportResult<()>;
|
2022-03-09 21:33:05 -05:00
|
|
|
|
2022-03-17 13:31:11 -07:00
|
|
|
fn send_batch(&self, transactions: &[Transaction]) -> TransportResult<()>;
|
2022-03-09 21:33:05 -05:00
|
|
|
}
|