diff --git a/web3_proxy/src/rpcs/blockchain.rs b/web3_proxy/src/rpcs/blockchain.rs index e727bde0..05a681a4 100644 --- a/web3_proxy/src/rpcs/blockchain.rs +++ b/web3_proxy/src/rpcs/blockchain.rs @@ -149,16 +149,16 @@ impl Web3Connections { let get_block_params = (*hash, false); // TODO: if error, retry? let block: ArcBlock = match rpc { - Some(rpc) => { - rpc.wait_for_request_handle(authorization, Duration::from_secs(30), false) - .await? - .request( - "eth_getBlockByHash", - &json!(get_block_params), - Level::Error.into(), - ) - .await? - } + Some(rpc) => rpc + .wait_for_request_handle(authorization, Duration::from_secs(30), false) + .await? + .request::<_, Option<_>>( + "eth_getBlockByHash", + &json!(get_block_params), + Level::Error.into(), + ) + .await? + .context("no block!")?, None => { // TODO: helper for method+params => JsonRpcRequest // TODO: does this id matter? @@ -172,7 +172,9 @@ impl Web3Connections { let block = response.result.context("failed fetching block")?; - serde_json::from_str(block.get())? + let block: Option = serde_json::from_str(block.get())?; + + block.context("no block!")? } }; diff --git a/web3_proxy/src/rpcs/connection.rs b/web3_proxy/src/rpcs/connection.rs index b24d2dbf..0fdd1f00 100644 --- a/web3_proxy/src/rpcs/connection.rs +++ b/web3_proxy/src/rpcs/connection.rs @@ -193,13 +193,14 @@ impl Web3Connection { let head_block: ArcBlock = self .wait_for_request_handle(authorization, Duration::from_secs(30), true) .await? - .request( + .request::<_, Option<_>>( "eth_getBlockByNumber", &json!(("latest", false)), // error here are expected, so keep the level low Level::Debug.into(), ) - .await?; + .await? + .context("no block!")?; if SavedBlock::from(head_block).syncing() { // if the node is syncing, we can't check its block data limit