use web3_rpcs.blocks_by_hash.get instead of something that might make queries
This commit is contained in:
parent
28df880d59
commit
86f70332be
@ -67,7 +67,7 @@ impl From<&Web3ProxyBlock> for BlockNumAndHash {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// modify params to always have a block hash and not "latest"
|
/// modify params to always have a block hash and not "latest"
|
||||||
/// TODO: this should replace all block numbers with hashes, not just "latest"
|
/// TODO: it would be nice to replace "latest" with the hash, but not all methods support that
|
||||||
#[async_recursion]
|
#[async_recursion]
|
||||||
pub async fn clean_block_number<'a>(
|
pub async fn clean_block_number<'a>(
|
||||||
params: &'a mut serde_json::Value,
|
params: &'a mut serde_json::Value,
|
||||||
@ -228,6 +228,8 @@ pub enum CacheMode {
|
|||||||
Never,
|
Never,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// TODO: i don't like this. we should make an enum with all of these methods and their types
|
||||||
|
/// TODO: serde tagged enums should work since the tag is the method
|
||||||
fn get_block_param_id(method: &str) -> Option<usize> {
|
fn get_block_param_id(method: &str) -> Option<usize> {
|
||||||
match method {
|
match method {
|
||||||
"debug_traceBlockByHash" => Some(0),
|
"debug_traceBlockByHash" => Some(0),
|
||||||
|
@ -21,7 +21,6 @@ use std::cmp::{min_by_key, Ordering, Reverse};
|
|||||||
use std::sync::{atomic, Arc};
|
use std::sync::{atomic, Arc};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use tokio::select;
|
use tokio::select;
|
||||||
use tokio::task::yield_now;
|
|
||||||
use tokio::time::{sleep_until, Instant};
|
use tokio::time::{sleep_until, Instant};
|
||||||
use tracing::{debug, enabled, error, info, trace, warn, Level};
|
use tracing::{debug, enabled, error, info, trace, warn, Level};
|
||||||
|
|
||||||
@ -953,14 +952,13 @@ impl ConsensusFinder {
|
|||||||
|
|
||||||
let parent_hash = block_to_check.parent_hash();
|
let parent_hash = block_to_check.parent_hash();
|
||||||
|
|
||||||
match web3_rpcs.block(parent_hash, Some(rpc), None).await {
|
match web3_rpcs.blocks_by_hash.get(parent_hash).await {
|
||||||
Ok(parent_block) => block_to_check = parent_block,
|
Some(parent_block) => block_to_check = parent_block,
|
||||||
Err(err) => {
|
None => {
|
||||||
debug!(
|
debug!(
|
||||||
"Problem fetching {:?} (parent of {:?}) during consensus finding: {:#?}",
|
"Unknown hash {:?} (parent of {:?}) during consensus finding",
|
||||||
parent_hash,
|
parent_hash,
|
||||||
block_to_check.hash(),
|
block_to_check.hash(),
|
||||||
err
|
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1032,13 +1030,10 @@ impl RpcsForRequest {
|
|||||||
let mut completed = HashSet::with_capacity(max_len);
|
let mut completed = HashSet::with_capacity(max_len);
|
||||||
|
|
||||||
// todo!("be sure to set server_error if we exit without any rpcs!");
|
// todo!("be sure to set server_error if we exit without any rpcs!");
|
||||||
#[allow(clippy::never_loop)]
|
|
||||||
loop {
|
loop {
|
||||||
// if self.request.connect_timeout() {
|
if self.request.connect_timeout() {
|
||||||
// break;
|
break;
|
||||||
// } else {
|
}
|
||||||
// yield_now().await;
|
|
||||||
// }
|
|
||||||
|
|
||||||
let mut earliest_retry_at = None;
|
let mut earliest_retry_at = None;
|
||||||
let mut wait_for_sync = FuturesUnordered::new();
|
let mut wait_for_sync = FuturesUnordered::new();
|
||||||
@ -1107,10 +1102,10 @@ impl RpcsForRequest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we got this far, no inner or outer rpcs are ready. thats suprising since an inner should have been
|
// if we got this far, no inner or outer rpcs are ready. thats suprising since an inner should have been ready. maybe it got rate limited
|
||||||
break;
|
warn!(?earliest_retry_at, num_waits=%wait_for_sync.len(), "no rpcs ready");
|
||||||
|
|
||||||
let min_wait_until = Instant::now() + Duration::from_millis(100);
|
let min_wait_until = Instant::now() + Duration::from_millis(10);
|
||||||
|
|
||||||
// clear earliest_retry_at if it is too far in the future to help us
|
// clear earliest_retry_at if it is too far in the future to help us
|
||||||
if let Some(retry_at) = earliest_retry_at {
|
if let Some(retry_at) = earliest_retry_at {
|
||||||
|
Loading…
Reference in New Issue
Block a user