From 1b0cab9f54cc2980ff98b3f7b3cfe3f25a6990e0 Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Thu, 1 Dec 2022 02:01:41 +0000 Subject: [PATCH] better errors --- web3_proxy/src/rpcs/blockchain.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/web3_proxy/src/rpcs/blockchain.rs b/web3_proxy/src/rpcs/blockchain.rs index 842f64c8..8e0354d2 100644 --- a/web3_proxy/src/rpcs/blockchain.rs +++ b/web3_proxy/src/rpcs/blockchain.rs @@ -125,7 +125,7 @@ impl Web3Connections { .try_send_best_upstream_server(authorization, request, None, None) .await?; - let block = response.result.unwrap(); + let block = response.result.context("failed fetching block")?; serde_json::from_str(block.get())? } @@ -278,9 +278,9 @@ impl Web3Connections { if block_timestamp < oldest_allowed { let behind_secs = (oldest_allowed - block_timestamp).as_secs(); - warn!("rpc is behind by {} seconds", behind_secs); - - connection_heads.remove(&rpc.name); + if connection_heads.remove(&rpc.name).is_some() { + warn!("{} is behind by {} seconds", &rpc.name, behind_secs); + }; None } else {