eth_sendRawTransactions should use backups more often
This commit is contained in:
parent
1efa8e7772
commit
5ffe2aa72a
@ -1217,6 +1217,7 @@ impl Web3ProxyApp {
|
|||||||
// if we are sending the transaction privately, no matter the proxy_mode, we send to ALL private rpcs
|
// if we are sending the transaction privately, no matter the proxy_mode, we send to ALL private rpcs
|
||||||
(private_rpcs, None)
|
(private_rpcs, None)
|
||||||
} else {
|
} else {
|
||||||
|
// TODO: send to balanced_rpcs AND private_rpcs
|
||||||
(&self.balanced_rpcs, default_num)
|
(&self.balanced_rpcs, default_num)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1232,6 +1233,7 @@ impl Web3ProxyApp {
|
|||||||
None,
|
None,
|
||||||
Level::Trace,
|
Level::Trace,
|
||||||
num,
|
num,
|
||||||
|
true,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
@ -1528,10 +1530,7 @@ impl Web3ProxyApp {
|
|||||||
|
|
||||||
self.response_cache
|
self.response_cache
|
||||||
.try_get_with(cache_key, async move {
|
.try_get_with(cache_key, async move {
|
||||||
// TODO: retry some failures automatically!
|
|
||||||
// TODO: try private_rpcs if all the balanced_rpcs fail!
|
|
||||||
// TODO: put the hash here instead of the block number? its in the request already.
|
// TODO: put the hash here instead of the block number? its in the request already.
|
||||||
|
|
||||||
let mut response = self
|
let mut response = self
|
||||||
.balanced_rpcs
|
.balanced_rpcs
|
||||||
.try_proxy_connection(
|
.try_proxy_connection(
|
||||||
@ -1547,6 +1546,8 @@ impl Web3ProxyApp {
|
|||||||
response.id = Default::default();
|
response.id = Default::default();
|
||||||
|
|
||||||
// TODO: only cache the inner response
|
// TODO: only cache the inner response
|
||||||
|
// TODO: how are we going to stream this?
|
||||||
|
// TODO: check response size. if its very large, return it in a custom Error type that bypasses caching
|
||||||
Ok::<_, anyhow::Error>(response)
|
Ok::<_, anyhow::Error>(response)
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
|
@ -639,12 +639,15 @@ impl Web3Rpcs {
|
|||||||
authorization: &Arc<Authorization>,
|
authorization: &Arc<Authorization>,
|
||||||
block_needed: Option<&U64>,
|
block_needed: Option<&U64>,
|
||||||
max_count: Option<usize>,
|
max_count: Option<usize>,
|
||||||
|
always_include_backups: bool,
|
||||||
) -> Result<Vec<OpenRequestHandle>, Option<Instant>> {
|
) -> Result<Vec<OpenRequestHandle>, Option<Instant>> {
|
||||||
if let Ok(without_backups) = self
|
if !always_include_backups {
|
||||||
._all_connections(false, authorization, block_needed, max_count)
|
if let Ok(without_backups) = self
|
||||||
.await
|
._all_connections(false, authorization, block_needed, max_count)
|
||||||
{
|
.await
|
||||||
return Ok(without_backups);
|
{
|
||||||
|
return Ok(without_backups);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self._all_connections(true, authorization, block_needed, max_count)
|
self._all_connections(true, authorization, block_needed, max_count)
|
||||||
@ -1008,10 +1011,16 @@ impl Web3Rpcs {
|
|||||||
block_needed: Option<&U64>,
|
block_needed: Option<&U64>,
|
||||||
error_level: Level,
|
error_level: Level,
|
||||||
max_count: Option<usize>,
|
max_count: Option<usize>,
|
||||||
|
always_include_backups: bool,
|
||||||
) -> anyhow::Result<JsonRpcForwardedResponse> {
|
) -> anyhow::Result<JsonRpcForwardedResponse> {
|
||||||
loop {
|
loop {
|
||||||
match self
|
match self
|
||||||
.all_connections(authorization, block_needed, max_count)
|
.all_connections(
|
||||||
|
authorization,
|
||||||
|
block_needed,
|
||||||
|
max_count,
|
||||||
|
always_include_backups,
|
||||||
|
)
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
Ok(active_request_handles) => {
|
Ok(active_request_handles) => {
|
||||||
@ -1382,10 +1391,10 @@ mod tests {
|
|||||||
// no head block because the rpcs haven't communicated through their channels
|
// no head block because the rpcs haven't communicated through their channels
|
||||||
assert!(conns.head_block_hash().is_none());
|
assert!(conns.head_block_hash().is_none());
|
||||||
|
|
||||||
// all_backend_connections gives everything regardless of sync status
|
// all_backend_connections gives all non-backup servers regardless of sync status
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
conns
|
conns
|
||||||
.all_connections(&authorization, None, None)
|
.all_connections(&authorization, None, None, false)
|
||||||
.await
|
.await
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.len(),
|
.len(),
|
||||||
|
Loading…
Reference in New Issue
Block a user