clippy
This commit is contained in:
parent
b41d05e613
commit
92a977fb98
|
@ -147,9 +147,7 @@ async fn new_endpoint_with_validator_identity(validator_identity: ValidatorIdent
|
||||||
)
|
)
|
||||||
.expect("Failed to initialize QUIC connection certificates");
|
.expect("Failed to initialize QUIC connection certificates");
|
||||||
|
|
||||||
let endpoint_outbound = create_tpu_client_endpoint(certificate.clone(), key.clone());
|
create_tpu_client_endpoint(certificate, key)
|
||||||
|
|
||||||
endpoint_outbound
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_tpu_client_endpoint(
|
fn create_tpu_client_endpoint(
|
||||||
|
@ -196,13 +194,12 @@ fn create_tpu_client_endpoint(
|
||||||
|
|
||||||
// send potentially large amount of transactions to a single TPU
|
// send potentially large amount of transactions to a single TPU
|
||||||
#[tracing::instrument(skip_all, level = "debug")]
|
#[tracing::instrument(skip_all, level = "debug")]
|
||||||
async fn send_tx_batch_to_tpu(auto_connection: &AutoReconnect, txs: &Vec<VersionedTransaction>) {
|
async fn send_tx_batch_to_tpu(auto_connection: &AutoReconnect, txs: &[VersionedTransaction]) {
|
||||||
for chunk in txs.chunks(MAX_PARALLEL_STREAMS) {
|
for chunk in txs.chunks(MAX_PARALLEL_STREAMS) {
|
||||||
let all_send_fns = chunk
|
let all_send_fns = chunk
|
||||||
.iter()
|
.iter()
|
||||||
.map(|tx| {
|
.map(|tx| {
|
||||||
let tx_raw = bincode::serialize(tx).unwrap();
|
bincode::serialize(tx).unwrap()
|
||||||
tx_raw
|
|
||||||
})
|
})
|
||||||
.map(|tx_raw| {
|
.map(|tx_raw| {
|
||||||
auto_connection.send_uni(tx_raw) // ignores error
|
auto_connection.send_uni(tx_raw) // ignores error
|
||||||
|
|
|
@ -53,7 +53,7 @@ impl TpuForwardingRequest {
|
||||||
|
|
||||||
// TODO reame
|
// TODO reame
|
||||||
pub fn deserialize_from_raw_request(raw_proxy_request: &Vec<u8>) -> TpuForwardingRequest {
|
pub fn deserialize_from_raw_request(raw_proxy_request: &Vec<u8>) -> TpuForwardingRequest {
|
||||||
let request = bincode::deserialize::<TpuForwardingRequest>(&raw_proxy_request)
|
let request = bincode::deserialize::<TpuForwardingRequest>(raw_proxy_request)
|
||||||
.context("deserialize proxy request")
|
.context("deserialize proxy request")
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ impl AutoReconnect {
|
||||||
}
|
}
|
||||||
let mut lock = self.current.write().await;
|
let mut lock = self.current.write().await;
|
||||||
let maybe_conn = lock.as_ref();
|
let maybe_conn = lock.as_ref();
|
||||||
return match maybe_conn {
|
match maybe_conn {
|
||||||
Some(current) => {
|
Some(current) => {
|
||||||
if current.close_reason().is_some() {
|
if current.close_reason().is_some() {
|
||||||
let old_stable_id = current.stable_id();
|
let old_stable_id = current.stable_id();
|
||||||
|
@ -73,7 +73,7 @@ impl AutoReconnect {
|
||||||
self.reconnect_count.load(Ordering::SeqCst)
|
self.reconnect_count.load(Ordering::SeqCst)
|
||||||
);
|
);
|
||||||
|
|
||||||
new_connection.clone()
|
new_connection
|
||||||
} else {
|
} else {
|
||||||
debug!("Reuse connection {} with write-lock", current.stable_id());
|
debug!("Reuse connection {} with write-lock", current.stable_id());
|
||||||
current.clone()
|
current.clone()
|
||||||
|
@ -87,9 +87,9 @@ impl AutoReconnect {
|
||||||
// let old_conn = foo.replace(Some(new_connection.clone()));
|
// let old_conn = foo.replace(Some(new_connection.clone()));
|
||||||
debug!("Create initial connection {}", new_connection.stable_id());
|
debug!("Create initial connection {}", new_connection.stable_id());
|
||||||
|
|
||||||
new_connection.clone()
|
new_connection
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn create_connection(&self) -> Connection {
|
async fn create_connection(&self) -> Connection {
|
||||||
|
|
|
@ -25,16 +25,9 @@ pub struct SelfSignedTlsConfigProvider {
|
||||||
server_crypto: ServerConfig,
|
server_crypto: ServerConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
const INSTANCES: AtomicU32 = AtomicU32::new(0);
|
|
||||||
|
|
||||||
impl SelfSignedTlsConfigProvider {
|
impl SelfSignedTlsConfigProvider {
|
||||||
pub fn new_singleton_self_signed_localhost() -> Self {
|
pub fn new_singleton_self_signed_localhost() -> Self {
|
||||||
// note: this check could be relaxed when you know what you are doing!
|
// note: this check could be relaxed when you know what you are doing!
|
||||||
assert_eq!(
|
|
||||||
INSTANCES.fetch_add(1, Ordering::Relaxed),
|
|
||||||
0,
|
|
||||||
"should be a singleton"
|
|
||||||
);
|
|
||||||
let hostnames = vec!["localhost".to_string()];
|
let hostnames = vec!["localhost".to_string()];
|
||||||
let (certificate, private_key) = Self::gen_tls_certificate_and_key(hostnames.clone());
|
let (certificate, private_key) = Self::gen_tls_certificate_and_key(hostnames.clone());
|
||||||
let server_crypto = Self::build_server_crypto(certificate.clone(), private_key.clone());
|
let server_crypto = Self::build_server_crypto(certificate.clone(), private_key.clone());
|
||||||
|
@ -43,7 +36,7 @@ impl SelfSignedTlsConfigProvider {
|
||||||
certificate,
|
certificate,
|
||||||
private_key,
|
private_key,
|
||||||
client_crypto: Self::build_client_crypto_insecure(),
|
client_crypto: Self::build_client_crypto_insecure(),
|
||||||
server_crypto: server_crypto,
|
server_crypto,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +54,7 @@ impl SelfSignedTlsConfigProvider {
|
||||||
.with_no_client_auth();
|
.with_no_client_auth();
|
||||||
client_crypto.enable_early_data = true;
|
client_crypto.enable_early_data = true;
|
||||||
client_crypto.alpn_protocols = vec![ALPN_TPU_FORWARDPROXY_PROTOCOL_ID.to_vec()];
|
client_crypto.alpn_protocols = vec![ALPN_TPU_FORWARDPROXY_PROTOCOL_ID.to_vec()];
|
||||||
return client_crypto;
|
client_crypto
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_server_crypto(server_cert: Certificate, server_key: PrivateKey) -> ServerConfig {
|
fn build_server_crypto(server_cert: Certificate, server_key: PrivateKey) -> ServerConfig {
|
||||||
|
@ -74,7 +67,7 @@ impl SelfSignedTlsConfigProvider {
|
||||||
.with_single_cert(vec![server_cert], server_key)
|
.with_single_cert(vec![server_cert], server_key)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
server_crypto.alpn_protocols = vec![ALPN_TPU_FORWARDPROXY_PROTOCOL_ID.to_vec()];
|
server_crypto.alpn_protocols = vec![ALPN_TPU_FORWARDPROXY_PROTOCOL_ID.to_vec()];
|
||||||
return server_crypto;
|
server_crypto
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_client_tls_crypto_config(&self) -> &ClientConfig {
|
pub fn get_client_tls_crypto_config(&self) -> &ClientConfig {
|
||||||
|
|
|
@ -14,7 +14,7 @@ impl ValidatorIdentity {
|
||||||
pub fn new(keypair: Option<Keypair>) -> Self {
|
pub fn new(keypair: Option<Keypair>) -> Self {
|
||||||
let dummy_keypair = Keypair::new();
|
let dummy_keypair = Keypair::new();
|
||||||
ValidatorIdentity {
|
ValidatorIdentity {
|
||||||
keypair: keypair.map(|kp| Arc::new(kp)),
|
keypair: keypair.map(Arc::new),
|
||||||
dummy_keypair: Arc::new(dummy_keypair),
|
dummy_keypair: Arc::new(dummy_keypair),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ impl ValidatorIdentity {
|
||||||
impl Display for ValidatorIdentity {
|
impl Display for ValidatorIdentity {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
match &self.keypair {
|
match &self.keypair {
|
||||||
Some(keypair) => write!(f, "{}", keypair.pubkey().to_string()),
|
Some(keypair) => write!(f, "{}", keypair.pubkey()),
|
||||||
None => write!(f, "no keypair"),
|
None => write!(f, "no keypair"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue