one more Cow

This commit is contained in:
Bryan Stitt 2023-07-14 18:35:40 -07:00
parent 020dff0233
commit 61126bb2ac
4 changed files with 9 additions and 13 deletions

View File

@ -423,7 +423,7 @@ impl Web3ProxyApp {
top_config.app.max_head_block_lag, top_config.app.max_head_block_lag,
top_config.app.min_synced_rpcs, top_config.app.min_synced_rpcs,
top_config.app.min_sum_soft_limit, top_config.app.min_sum_soft_limit,
"balanced rpcs".to_string(), "balanced rpcs".into(),
Some(watch_consensus_head_sender), Some(watch_consensus_head_sender),
) )
.await .await
@ -445,7 +445,7 @@ impl Web3ProxyApp {
None, None,
0, 0,
0, 0,
"protected rpcs".to_string(), "protected rpcs".into(),
// subscribing to new heads here won't work well. if they are fast, they might be ahead of balanced_rpcs // subscribing to new heads here won't work well. if they are fast, they might be ahead of balanced_rpcs
// they also often have low rate limits // they also often have low rate limits
// however, they are well connected to miners/validators. so maybe using them as a safety check would be good // however, they are well connected to miners/validators. so maybe using them as a safety check would be good
@ -474,7 +474,7 @@ impl Web3ProxyApp {
None, None,
0, 0,
0, 0,
"eip4337 rpcs".to_string(), "eip4337 rpcs".into(),
None, None,
) )
.await .await

View File

@ -724,7 +724,6 @@ impl Authorization {
) )
} }
#[allow(clippy::too_many_arguments)]
pub fn try_new( pub fn try_new(
authorization_checks: AuthorizationChecks, authorization_checks: AuthorizationChecks,
ip: &IpAddr, ip: &IpAddr,

View File

@ -22,6 +22,7 @@ use moka::future::CacheBuilder;
use serde::ser::{SerializeStruct, Serializer}; use serde::ser::{SerializeStruct, Serializer};
use serde_json::json; use serde_json::json;
use serde_json::value::RawValue; use serde_json::value::RawValue;
use std::borrow::Cow;
use std::cmp::min_by_key; use std::cmp::min_by_key;
use std::fmt::{self, Display}; use std::fmt::{self, Display};
use std::sync::atomic::Ordering; use std::sync::atomic::Ordering;
@ -34,8 +35,7 @@ use tracing::{debug, error, info, trace, warn};
/// A collection of web3 connections. Sends requests either the current best server or all servers. /// A collection of web3 connections. Sends requests either the current best server or all servers.
#[derive(From)] #[derive(From)]
pub struct Web3Rpcs { pub struct Web3Rpcs {
/// TODO: this should be a Cow pub(crate) name: Cow<'static, str>,
pub(crate) name: String,
pub(crate) chain_id: u64, pub(crate) chain_id: u64,
/// if watch_consensus_head_sender is some, Web3Rpc inside self will send blocks here when they get them /// if watch_consensus_head_sender is some, Web3Rpc inside self will send blocks here when they get them
pub(crate) block_sender: mpsc::UnboundedSender<(Option<Web3ProxyBlock>, Arc<Web3Rpc>)>, pub(crate) block_sender: mpsc::UnboundedSender<(Option<Web3ProxyBlock>, Arc<Web3Rpc>)>,
@ -67,13 +67,12 @@ pub struct Web3Rpcs {
impl Web3Rpcs { impl Web3Rpcs {
/// Spawn durable connections to multiple Web3 providers. /// Spawn durable connections to multiple Web3 providers.
#[allow(clippy::too_many_arguments)]
pub async fn spawn( pub async fn spawn(
chain_id: u64, chain_id: u64,
max_head_block_lag: Option<U64>, max_head_block_lag: Option<U64>,
min_head_rpcs: usize, min_head_rpcs: usize,
min_sum_soft_limit: u32, min_sum_soft_limit: u32,
name: String, name: Cow<'static, str>,
watch_consensus_head_sender: Option<watch::Sender<Option<Web3ProxyBlock>>>, watch_consensus_head_sender: Option<watch::Sender<Option<Web3ProxyBlock>>>,
) -> anyhow::Result<( ) -> anyhow::Result<(
Arc<Self>, Arc<Self>,
@ -789,7 +788,6 @@ impl Web3Rpcs {
} }
/// Make a request with stat tracking. /// Make a request with stat tracking.
#[allow(clippy::too_many_arguments)]
pub async fn request_with_metadata<P: JsonRpcParams, R: JsonRpcResultData>( pub async fn request_with_metadata<P: JsonRpcParams, R: JsonRpcResultData>(
&self, &self,
method: &str, method: &str,
@ -1528,7 +1526,7 @@ mod tests {
block_sender: block_sender.clone(), block_sender: block_sender.clone(),
by_name: RwLock::new(by_name), by_name: RwLock::new(by_name),
chain_id, chain_id,
name: "test".to_string(), name: "test".into(),
watch_head_block: Some(watch_consensus_head_sender), watch_head_block: Some(watch_consensus_head_sender),
watch_ranked_rpcs, watch_ranked_rpcs,
blocks_by_hash: CacheBuilder::new(100) blocks_by_hash: CacheBuilder::new(100)
@ -1783,7 +1781,7 @@ mod tests {
block_sender, block_sender,
by_name: RwLock::new(by_name), by_name: RwLock::new(by_name),
chain_id, chain_id,
name: "test".to_string(), name: "test".into(),
watch_head_block: Some(watch_consensus_head_sender), watch_head_block: Some(watch_consensus_head_sender),
watch_ranked_rpcs, watch_ranked_rpcs,
blocks_by_hash: CacheBuilder::new(100) blocks_by_hash: CacheBuilder::new(100)
@ -1951,7 +1949,7 @@ mod tests {
block_sender, block_sender,
by_name: RwLock::new(by_name), by_name: RwLock::new(by_name),
chain_id, chain_id,
name: "test".to_string(), name: "test".into(),
watch_head_block: Some(watch_consensus_head_sender), watch_head_block: Some(watch_consensus_head_sender),
watch_ranked_rpcs, watch_ranked_rpcs,
blocks_by_hash: Cache::new(10_000), blocks_by_hash: Cache::new(10_000),

View File

@ -581,7 +581,6 @@ impl Web3Rpc {
} }
/// TODO: this needs to be a subscribe_with_reconnect that does a retry with jitter and exponential backoff /// TODO: this needs to be a subscribe_with_reconnect that does a retry with jitter and exponential backoff
#[allow(clippy::too_many_arguments)]
async fn subscribe_with_reconnect( async fn subscribe_with_reconnect(
self: Arc<Self>, self: Arc<Self>,
block_map: BlocksByHashCache, block_map: BlocksByHashCache,