diff --git a/web3_proxy/src/rpcs/consensus.rs b/web3_proxy/src/rpcs/consensus.rs index 1c9a5876..78a80f13 100644 --- a/web3_proxy/src/rpcs/consensus.rs +++ b/web3_proxy/src/rpcs/consensus.rs @@ -102,7 +102,7 @@ pub struct RpcsForRequest { } impl RankedRpcs { - pub fn from_rpcs(rpcs: Vec>, head_block: Option) -> Option { + pub fn from_rpcs(rpcs: Vec>, head_block: Option) -> Self { // we don't need to sort the rpcs now. we will sort them when a request neds them // TODO: the shame about this is that we lose just being able to compare 2 random servers @@ -117,15 +117,13 @@ impl RankedRpcs { let sort_mode = SortMethod::Shuffle; - let ranked_rpcs = RankedRpcs { + Self { backups_needed, head_block, inner: rpcs, num_synced, sort_mode, - }; - - Some(ranked_rpcs) + } } pub fn from_votes( @@ -904,12 +902,7 @@ impl RpcsForRequest { let error_handler = None; // todo!("be sure to set server_error if we exit without any rpcs!"); - #[allow(clippy::never_loop)] - loop { - if self.request.connect_timeout() { - break; - } - + while !self.request.connect_timeout() { let mut earliest_retry_at = None; let mut opened = 0; let mut tried = 0; diff --git a/web3_proxy/src/rpcs/many.rs b/web3_proxy/src/rpcs/many.rs index c623f019..3f88e446 100644 --- a/web3_proxy/src/rpcs/many.rs +++ b/web3_proxy/src/rpcs/many.rs @@ -408,7 +408,6 @@ impl Web3Rpcs { ranked_rpcs } else if self.watch_head_block.is_some() { // if we are here, this set of rpcs is subscribed to newHeads. But we didn't get a RankedRpcs. that means something is wrong - trace!("watch_head_block is some"); return Err(Web3ProxyError::NoServersSynced); } else { trace!("watch_head_block is none"); @@ -416,12 +415,10 @@ impl Web3Rpcs { // no RankedRpcs, but also no newHeads subscription. This is probably a set of "protected" rpcs or similar let rpcs = self.by_name.read().values().cloned().collect(); - if let Some(x) = RankedRpcs::from_rpcs(rpcs, web3_request.head_block.clone()) { - Arc::new(x) - } else { - // i doubt we will ever get here - return Err(Web3ProxyError::NoServersSynced); - } + // TODO: does this need the head_block? i don't think so + let x = RankedRpcs::from_rpcs(rpcs, web3_request.head_block.clone()); + + Arc::new(x) }; match ranked_rpcs.for_request(web3_request) { @@ -549,6 +546,7 @@ impl Web3Rpcs { // TODO: what error code? what data? // cloudflare gives {"jsonrpc":"2.0","error":{"code":-32043,"message":"Requested data cannot be older than 128 blocks."},"id":1} + // TODO: some queries other providers give "successful" results with null data. i don't like that at all but its what is often expected Err(JsonRpcErrorData { message: "Requested data is not available".into(), code: -32001,