Files
solana/client/src/tpu_connection.rs
ryleung-solana 9b46f9b2da Quic Connection Cache (#23598)
Add a connection cache to allow add modules that send data to get or create connections (e.g. for quic) associated with a certain SocketAddr
2022-03-15 18:16:35 -04:00

22 lines
672 B
Rust

use {
solana_sdk::{transaction::Transaction, transport::Result as TransportResult},
std::net::{SocketAddr, UdpSocket},
};
pub trait TpuConnection {
fn new(client_socket: UdpSocket, tpu_addr: SocketAddr) -> Self
where
Self: Sized;
fn tpu_addr(&self) -> &SocketAddr;
fn send_transaction(&self, tx: &Transaction) -> TransportResult<()> {
let data = bincode::serialize(tx).expect("serialize Transaction in send_transaction");
self.send_wire_transaction(data)
}
fn send_wire_transaction(&self, data: Vec<u8>) -> TransportResult<()>;
fn send_batch(&self, transactions: Vec<Transaction>) -> TransportResult<()>;
}