one more Cow
This commit is contained in:
parent
020dff0233
commit
61126bb2ac
@ -423,7 +423,7 @@ impl Web3ProxyApp {
|
||||
top_config.app.max_head_block_lag,
|
||||
top_config.app.min_synced_rpcs,
|
||||
top_config.app.min_sum_soft_limit,
|
||||
"balanced rpcs".to_string(),
|
||||
"balanced rpcs".into(),
|
||||
Some(watch_consensus_head_sender),
|
||||
)
|
||||
.await
|
||||
@ -445,7 +445,7 @@ impl Web3ProxyApp {
|
||||
None,
|
||||
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
|
||||
// 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
|
||||
@ -474,7 +474,7 @@ impl Web3ProxyApp {
|
||||
None,
|
||||
0,
|
||||
0,
|
||||
"eip4337 rpcs".to_string(),
|
||||
"eip4337 rpcs".into(),
|
||||
None,
|
||||
)
|
||||
.await
|
||||
|
@ -724,7 +724,6 @@ impl Authorization {
|
||||
)
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn try_new(
|
||||
authorization_checks: AuthorizationChecks,
|
||||
ip: &IpAddr,
|
||||
|
@ -22,6 +22,7 @@ use moka::future::CacheBuilder;
|
||||
use serde::ser::{SerializeStruct, Serializer};
|
||||
use serde_json::json;
|
||||
use serde_json::value::RawValue;
|
||||
use std::borrow::Cow;
|
||||
use std::cmp::min_by_key;
|
||||
use std::fmt::{self, Display};
|
||||
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.
|
||||
#[derive(From)]
|
||||
pub struct Web3Rpcs {
|
||||
/// TODO: this should be a Cow
|
||||
pub(crate) name: String,
|
||||
pub(crate) name: Cow<'static, str>,
|
||||
pub(crate) chain_id: u64,
|
||||
/// 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>)>,
|
||||
@ -67,13 +67,12 @@ pub struct Web3Rpcs {
|
||||
|
||||
impl Web3Rpcs {
|
||||
/// Spawn durable connections to multiple Web3 providers.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub async fn spawn(
|
||||
chain_id: u64,
|
||||
max_head_block_lag: Option<U64>,
|
||||
min_head_rpcs: usize,
|
||||
min_sum_soft_limit: u32,
|
||||
name: String,
|
||||
name: Cow<'static, str>,
|
||||
watch_consensus_head_sender: Option<watch::Sender<Option<Web3ProxyBlock>>>,
|
||||
) -> anyhow::Result<(
|
||||
Arc<Self>,
|
||||
@ -789,7 +788,6 @@ impl Web3Rpcs {
|
||||
}
|
||||
|
||||
/// Make a request with stat tracking.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub async fn request_with_metadata<P: JsonRpcParams, R: JsonRpcResultData>(
|
||||
&self,
|
||||
method: &str,
|
||||
@ -1528,7 +1526,7 @@ mod tests {
|
||||
block_sender: block_sender.clone(),
|
||||
by_name: RwLock::new(by_name),
|
||||
chain_id,
|
||||
name: "test".to_string(),
|
||||
name: "test".into(),
|
||||
watch_head_block: Some(watch_consensus_head_sender),
|
||||
watch_ranked_rpcs,
|
||||
blocks_by_hash: CacheBuilder::new(100)
|
||||
@ -1783,7 +1781,7 @@ mod tests {
|
||||
block_sender,
|
||||
by_name: RwLock::new(by_name),
|
||||
chain_id,
|
||||
name: "test".to_string(),
|
||||
name: "test".into(),
|
||||
watch_head_block: Some(watch_consensus_head_sender),
|
||||
watch_ranked_rpcs,
|
||||
blocks_by_hash: CacheBuilder::new(100)
|
||||
@ -1951,7 +1949,7 @@ mod tests {
|
||||
block_sender,
|
||||
by_name: RwLock::new(by_name),
|
||||
chain_id,
|
||||
name: "test".to_string(),
|
||||
name: "test".into(),
|
||||
watch_head_block: Some(watch_consensus_head_sender),
|
||||
watch_ranked_rpcs,
|
||||
blocks_by_hash: Cache::new(10_000),
|
||||
|
@ -581,7 +581,6 @@ impl Web3Rpc {
|
||||
}
|
||||
|
||||
/// 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(
|
||||
self: Arc<Self>,
|
||||
block_map: BlocksByHashCache,
|
||||
|
Loading…
Reference in New Issue
Block a user