cleanup
This commit is contained in:
parent
015b36f5b2
commit
dfb98ede20
4
TODO.md
4
TODO.md
|
@ -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?
|
- 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?)
|
- [ ] incoming rate limiting (by ip or by api key or what?)
|
||||||
- [ ] improve caching
|
- [ ] 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
|
- [ ] 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?
|
- [ ] measure latency to nodes?
|
||||||
- [ ] one proxy for mulitple chains?
|
- [ ] one proxy for mulitple chains?
|
||||||
- [ ] zero downtime deploys
|
- [ ] zero downtime deploys
|
||||||
|
|
|
@ -15,7 +15,7 @@ flume = "0.10.12"
|
||||||
futures = { version = "0.3.21", features = ["thread-pool"] }
|
futures = { version = "0.3.21", features = ["thread-pool"] }
|
||||||
governor = { version = "0.4.2", features = ["dashmap", "std"] }
|
governor = { version = "0.4.2", features = ["dashmap", "std"] }
|
||||||
hashbrown = "0.12.1"
|
hashbrown = "0.12.1"
|
||||||
linkedhashmap = { path = "../linkedhashmap" }
|
linkedhashmap = { path = "../linkedhashmap", features = ["inline-more"] }
|
||||||
parking_lot = "0.12.0"
|
parking_lot = "0.12.0"
|
||||||
proctitle = "0.1.1"
|
proctitle = "0.1.1"
|
||||||
regex = "1.5.5"
|
regex = "1.5.5"
|
||||||
|
|
|
@ -68,6 +68,7 @@ impl Web3Connection {
|
||||||
pub async fn try_new(
|
pub async fn try_new(
|
||||||
chain_id: usize,
|
chain_id: usize,
|
||||||
url_str: String,
|
url_str: String,
|
||||||
|
// optional because this is only used for http providers. websocket providers don't use it
|
||||||
http_client: Option<reqwest::Client>,
|
http_client: Option<reqwest::Client>,
|
||||||
hard_rate_limit: Option<u32>,
|
hard_rate_limit: Option<u32>,
|
||||||
clock: &QuantaClock,
|
clock: &QuantaClock,
|
||||||
|
@ -112,7 +113,7 @@ impl Web3Connection {
|
||||||
let connection = Web3Connection {
|
let connection = Web3Connection {
|
||||||
clock: clock.clone(),
|
clock: clock.clone(),
|
||||||
url: url_str.clone(),
|
url: url_str.clone(),
|
||||||
active_requests: Default::default(),
|
active_requests: 0.into(),
|
||||||
provider,
|
provider,
|
||||||
ratelimiter: hard_rate_limiter,
|
ratelimiter: hard_rate_limiter,
|
||||||
soft_limit,
|
soft_limit,
|
||||||
|
@ -121,14 +122,11 @@ impl Web3Connection {
|
||||||
|
|
||||||
let connection = Arc::new(connection);
|
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;
|
let active_request_handle = connection.wait_for_request_handle().await;
|
||||||
|
// TODO: some public rpcs (on bsc and fantom) do not return an id and so this ends up being an error
|
||||||
// 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
|
|
||||||
let found_chain_id: Result<String, _> = active_request_handle
|
let found_chain_id: Result<String, _> = active_request_handle
|
||||||
.request("eth_chainId", empty_params)
|
.request("eth_chainId", Option::None::<()>)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
match found_chain_id {
|
match found_chain_id {
|
||||||
|
|
Loading…
Reference in New Issue