move config safty checks earlier
This commit is contained in:
parent
69f0125eba
commit
f736aeb027
@ -284,6 +284,27 @@ impl Web3ProxyApp {
|
||||
};
|
||||
|
||||
let balanced_rpcs = top_config.balanced_rpcs;
|
||||
|
||||
// safety check on balanced_rpcs
|
||||
if balanced_rpcs.len() < top_config.app.min_synced_rpcs {
|
||||
return Err(anyhow::anyhow!(
|
||||
"Only {}/{} rpcs! Add more balanced_rpcs or reduce min_synced_rpcs.",
|
||||
balanced_rpcs.len(),
|
||||
top_config.app.min_synced_rpcs
|
||||
));
|
||||
}
|
||||
|
||||
// safety check on sum soft limit
|
||||
let sum_soft_limit = balanced_rpcs.values().fold(0, |acc, x| acc + x.soft_limit);
|
||||
|
||||
if sum_soft_limit < top_config.app.min_sum_soft_limit {
|
||||
return Err(anyhow::anyhow!(
|
||||
"Only {}/{} soft limit! Add more balanced_rpcs, increase soft limits, or reduce min_sum_soft_limit.",
|
||||
sum_soft_limit,
|
||||
top_config.app.min_sum_soft_limit
|
||||
));
|
||||
}
|
||||
|
||||
let private_rpcs = top_config.private_rpcs.unwrap_or_default();
|
||||
|
||||
// these are safe to cancel
|
||||
|
@ -959,6 +959,7 @@ impl Serialize for Web3Connection {
|
||||
&self.frontend_requests.load(atomic::Ordering::Relaxed),
|
||||
)?;
|
||||
|
||||
// TODO: rename to head_block (need to work with the frontend team)
|
||||
let head_block_id = &*self.head_block.read();
|
||||
state.serialize_field("head_block_id", head_block_id)?;
|
||||
|
||||
|
@ -173,17 +173,6 @@ impl Web3Connections {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: now this errors for private rpcs when we disable all!
|
||||
if connections.len() < min_head_rpcs {
|
||||
return Err(anyhow::anyhow!(
|
||||
"Only {}/{} connections! Add more connections or reduce min_head_rpcs.",
|
||||
connections.len(),
|
||||
min_head_rpcs
|
||||
));
|
||||
}
|
||||
|
||||
// TODO: safety check on sum soft limit
|
||||
|
||||
let synced_connections = SyncedConnections::default();
|
||||
|
||||
// TODO: max_capacity and time_to_idle from config
|
||||
|
Loading…
Reference in New Issue
Block a user