only send to 2 servers (not 3x2)
This commit is contained in:
parent
572fc87cf5
commit
d6e9f61ee2
@ -1369,22 +1369,32 @@ impl Web3ProxyApp {
|
|||||||
|
|
||||||
let mut result = self
|
let mut result = self
|
||||||
.balanced_rpcs
|
.balanced_rpcs
|
||||||
.try_send_all_synced_connections::<serde_json::Value>(
|
.try_proxy_connection::<Arc<RawValue>>(
|
||||||
web3_request,
|
web3_request,
|
||||||
Some(Duration::from_secs(30)),
|
|
||||||
Some(crate::rpcs::request::RequestErrorHandler::DebugLevel),
|
|
||||||
Some(3),
|
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
// TODO: helper for doing parsed() inside a result?
|
||||||
|
if let Ok(SingleResponse::Stream(x)) = result {
|
||||||
|
result = x.read().await.map(SingleResponse::Parsed).map_err(Into::into);
|
||||||
|
}
|
||||||
|
|
||||||
// if we got "null" or "", it is probably because the tx is old. retry on nodes with old block data
|
// if we got "null" or "", it is probably because the tx is old. retry on nodes with old block data
|
||||||
// TODO: this feels fragile. how should we do this better/
|
// TODO: this feels fragile. how should we do this better/
|
||||||
let try_archive = match &result {
|
let try_archive = match &result {
|
||||||
Ok(serde_json::Value::Null) => true,
|
Ok(SingleResponse::Parsed(x)) => {
|
||||||
Ok(serde_json::Value::Array(x)) => x.is_empty(),
|
let x = x.result().map(|x| json!(x));
|
||||||
Ok(serde_json::Value::String(x)) => x.is_empty(),
|
|
||||||
|
match x {
|
||||||
|
Some(serde_json::Value::Null) => true,
|
||||||
|
Some(serde_json::Value::Array(x)) => x.is_empty(),
|
||||||
|
Some(serde_json::Value::String(x)) => x.is_empty(),
|
||||||
|
None => true,
|
||||||
|
_ => false,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Ok(SingleResponse::Stream(..)) => unimplemented!(),
|
||||||
Err(..) => true,
|
Err(..) => true,
|
||||||
_ => false,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if try_archive {
|
if try_archive {
|
||||||
@ -1394,20 +1404,18 @@ impl Web3ProxyApp {
|
|||||||
.store(true, atomic::Ordering::Relaxed);
|
.store(true, atomic::Ordering::Relaxed);
|
||||||
|
|
||||||
// TODO: we don't actually want try_send_all. we want the first non-null, non-error response
|
// TODO: we don't actually want try_send_all. we want the first non-null, non-error response
|
||||||
result = self
|
self
|
||||||
.balanced_rpcs
|
.balanced_rpcs
|
||||||
.try_send_all_synced_connections::<serde_json::Value>(
|
.try_proxy_connection::<Arc<RawValue>>(
|
||||||
web3_request,
|
web3_request,
|
||||||
Some(Duration::from_secs(30)),
|
|
||||||
Some(crate::rpcs::request::RequestErrorHandler::DebugLevel),
|
|
||||||
Some(3),
|
|
||||||
)
|
)
|
||||||
.await;
|
.await?
|
||||||
|
} else {
|
||||||
|
|
||||||
|
// TODO: if result is an error, return a null instead?
|
||||||
|
|
||||||
|
result?
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: if parsed is an error, return a null instead
|
|
||||||
|
|
||||||
jsonrpc::ParsedResponse::from_value(result?, web3_request.id()).into()
|
|
||||||
}
|
}
|
||||||
// TODO: eth_gasPrice that does awesome magic to predict the future
|
// TODO: eth_gasPrice that does awesome magic to predict the future
|
||||||
"eth_hashrate" => jsonrpc::ParsedResponse::from_value(json!(U64::zero()), web3_request.id()).into(),
|
"eth_hashrate" => jsonrpc::ParsedResponse::from_value(json!(U64::zero()), web3_request.id()).into(),
|
||||||
|
Loading…
Reference in New Issue
Block a user