define basic proxy wire format
This commit is contained in:
parent
90e04680af
commit
4e25095744
|
@ -2,5 +2,7 @@ pub mod quic_util;
|
|||
pub mod tls_config_provicer;
|
||||
pub mod proxy;
|
||||
pub mod test_client;
|
||||
pub mod proxy_request_format;
|
||||
|
||||
pub use tls_config_provicer::SelfSignedTlsConfigProvider;
|
||||
// pub mod tls_config;
|
|
@ -1,4 +1,4 @@
|
|||
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
|
||||
use std::net::{IpAddr, Ipv4Addr, SocketAddr, SocketAddrV4};
|
||||
use std::path::Path;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
@ -8,6 +8,8 @@ use quinn::{Connecting, Endpoint, SendStream, ServerConfig};
|
|||
use rcgen::generate_simple_self_signed;
|
||||
use rustls::{Certificate, PrivateKey};
|
||||
use rustls::server::ResolvesServerCert;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use solana_sdk::signature::Keypair;
|
||||
use solana_sdk::transaction::VersionedTransaction;
|
||||
use tokio::net::ToSocketAddrs;
|
||||
|
@ -137,6 +139,7 @@ async fn handle_connection2(connecting: Connecting) -> anyhow::Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
async fn send_data(mut send: SendStream) -> anyhow::Result<()> {
|
||||
send.write_all(b"HELLO STRANGER\r\n").await?;
|
||||
send.finish().await?;
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
use std::net::SocketAddrV4;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use solana_sdk::transaction::VersionedTransaction;
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
pub struct TpuForwardingRequestV1 {
|
||||
pub tpu_socket_addr: SocketAddrV4, // TODO is that correct
|
||||
pub identity_tpunode: Pubkey,
|
||||
pub transactions: Vec<VersionedTransaction>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
pub enum TpuForwardingRequest {
|
||||
V1(TpuForwardingRequestV1),
|
||||
}
|
||||
|
||||
impl TpuForwardingRequest {
|
||||
pub fn new(tpu_socket_addr: SocketAddrV4, identity_tpunode: Pubkey,
|
||||
transactions: Vec<VersionedTransaction>) -> Self {
|
||||
TpuForwardingRequest::V1(
|
||||
TpuForwardingRequestV1 {
|
||||
tpu_socket_addr,
|
||||
identity_tpunode,
|
||||
transactions,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// TODO reame
|
||||
fn deserialize_request(raw_tx: &Vec<u8>) -> TpuForwardingRequest {
|
||||
todo!();
|
||||
}
|
||||
|
||||
fn serialize_transactions_for_tpu(
|
||||
tpu_socket_addr: SocketAddrV4,
|
||||
tpu_identity: Pubkey,
|
||||
transactions: Vec<VersionedTransaction>) -> Vec<u8> {
|
||||
|
||||
let request = TpuForwardingRequest::new(tpu_socket_addr, tpu_identity, transactions);
|
||||
|
||||
bincode::serialize(&request).expect("Expect to serialize transactions")
|
||||
}
|
||||
|
||||
|
||||
mod test {
|
||||
use std::str::FromStr;
|
||||
use log::info;
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use crate::proxy_request_format::serialize_transactions_for_tpu;
|
||||
|
||||
#[test]
|
||||
fn deser() {
|
||||
let wire_data = serialize_transactions_for_tpu(
|
||||
"127.0.0.1:5454".parse().unwrap(),
|
||||
Pubkey::from_str("Bm8rtweCQ19ksNebrLY92H7x4bCaeDJSSmEeWqkdCeop").unwrap(),
|
||||
vec![]);
|
||||
|
||||
println!("wire_data: {:02X?}", wire_data);
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue