From 580965ef83bf11c61ecc7398a3e43cf7d18e134b Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Fri, 24 Feb 2023 23:31:10 -0800 Subject: [PATCH] get instead of remove --- web3_proxy/src/block_number.rs | 5 +++-- web3_proxy/src/rpcs/many.rs | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/web3_proxy/src/block_number.rs b/web3_proxy/src/block_number.rs index 4b92d1e7..2b68f432 100644 --- a/web3_proxy/src/block_number.rs +++ b/web3_proxy/src/block_number.rs @@ -70,7 +70,7 @@ pub async fn clean_block_number( // convert the json value to a BlockNumber let (block_num, change) = if let Some(obj) = x.as_object_mut() { // it might be a Map like `{"blockHash": String("0xa5626dc20d3a0a209b1de85521717a3e859698de8ce98bca1b16822b7501f74b")}` - if let Some(block_hash) = obj.remove("blockHash") { + if let Some(block_hash) = obj.get("blockHash").cloned() { let block_hash: H256 = serde_json::from_value(block_hash).context("decoding blockHash")?; @@ -79,7 +79,7 @@ pub async fn clean_block_number( .await .context("fetching block number from hash")?; - // TODO: set change to true? i think not we should probably use hashes for everything. + // TODO: we do not change the (*block.number(), false) } else { return Err(anyhow::anyhow!("blockHash missing")); @@ -176,6 +176,7 @@ pub async fn block_needed( "eth_getLogs" => { // TODO: think about this more // TODO: jsonrpc has a specific code for this + // TODO: this shouldn't be a 500. this should let obj = params[0] .as_object_mut() .ok_or_else(|| anyhow::anyhow!("invalid format"))?; diff --git a/web3_proxy/src/rpcs/many.rs b/web3_proxy/src/rpcs/many.rs index d53f0531..2aeeb8e9 100644 --- a/web3_proxy/src/rpcs/many.rs +++ b/web3_proxy/src/rpcs/many.rs @@ -887,7 +887,7 @@ impl Web3Rpcs { continue; } - // others look like this + // others look like this (this is the example in the official spec) if error_msg == "Method not found" { method_not_available_response = Some(response); continue;