This commit is contained in:
Bryan Stitt 2022-05-15 01:51:24 +00:00
parent 015b36f5b2
commit dfb98ede20
3 changed files with 8 additions and 10 deletions

View File

@ -17,9 +17,9 @@
- maybe always try at least two servers in parallel? and then return the first? or only if the first one doesn't respond very quickly?
- [ ] incoming rate limiting (by ip or by api key or what?)
- [ ] improve caching
- [ ] if the params include a block, we can cache for longer
- [ ] if the eth_call (or similar) params include a block, we can cache for longer
- [ ] if the call is something simple like "symbol" or "decimals", cache that too
- [ ] when we receive a block, we should store it for later eth_getBlockByNumber and similar calls
- [ ] when we receive a block, we should store it for later eth_getBlockByNumber, eth_blockNumber, and similar calls
- [ ] measure latency to nodes?
- [ ] one proxy for mulitple chains?
- [ ] zero downtime deploys

View File

@ -15,7 +15,7 @@ flume = "0.10.12"
futures = { version = "0.3.21", features = ["thread-pool"] }
governor = { version = "0.4.2", features = ["dashmap", "std"] }
hashbrown = "0.12.1"
linkedhashmap = { path = "../linkedhashmap" }
linkedhashmap = { path = "../linkedhashmap", features = ["inline-more"] }
parking_lot = "0.12.0"
proctitle = "0.1.1"
regex = "1.5.5"

View File

@ -68,6 +68,7 @@ impl Web3Connection {
pub async fn try_new(
chain_id: usize,
url_str: String,
// optional because this is only used for http providers. websocket providers don't use it
http_client: Option<reqwest::Client>,
hard_rate_limit: Option<u32>,
clock: &QuantaClock,
@ -112,7 +113,7 @@ impl Web3Connection {
let connection = Web3Connection {
clock: clock.clone(),
url: url_str.clone(),
active_requests: Default::default(),
active_requests: 0.into(),
provider,
ratelimiter: hard_rate_limiter,
soft_limit,
@ -121,14 +122,11 @@ impl Web3Connection {
let connection = Arc::new(connection);
// TODO: check the chain_id here
// check the server's chain_id here
let active_request_handle = connection.wait_for_request_handle().await;
// TODO: passing empty_params like this feels awkward.
let empty_params: Option<()> = None;
// TODO: some rpcs (on bsc and fantom) do not return an id
// TODO: some public rpcs (on bsc and fantom) do not return an id and so this ends up being an error
let found_chain_id: Result<String, _> = active_request_handle
.request("eth_chainId", empty_params)
.request("eth_chainId", Option::None::<()>)
.await;
match found_chain_id {