From dc5c944545de7c8a44cac4abb3c1b511f8133e6d Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Mon, 5 Dec 2022 14:38:54 -0800 Subject: [PATCH] rename head_block_id to head_block --- web3_proxy/src/app/mod.rs | 2 +- web3_proxy/src/rpcs/blockchain.rs | 6 +++--- web3_proxy/src/rpcs/connection.rs | 16 ++++++++-------- web3_proxy/src/rpcs/request.rs | 2 +- web3_proxy/src/rpcs/synced_connections.rs | 16 ++++++++-------- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/web3_proxy/src/app/mod.rs b/web3_proxy/src/app/mod.rs index 2751cca2..6d1ab5b0 100644 --- a/web3_proxy/src/app/mod.rs +++ b/web3_proxy/src/app/mod.rs @@ -882,7 +882,7 @@ impl Web3ProxyApp { // TODO: if no servers synced, wait for them to be synced? let head_block = self .balanced_rpcs - .head_block_id() + .head_block() .context("no servers synced")?; // we do this check before checking caches because it might modify the request params diff --git a/web3_proxy/src/rpcs/blockchain.rs b/web3_proxy/src/rpcs/blockchain.rs index 0029a096..638c55c8 100644 --- a/web3_proxy/src/rpcs/blockchain.rs +++ b/web3_proxy/src/rpcs/blockchain.rs @@ -509,7 +509,7 @@ impl Web3Connections { let consensus_head_block: SavedBlock = maybe_head_block.into(); let new_synced_connections = SyncedConnections { - head_block_id: Some(consensus_head_block.clone()), + head_block: Some(consensus_head_block.clone()), conns, }; @@ -518,7 +518,7 @@ impl Web3Connections { .swap(Arc::new(new_synced_connections)); // TODO: if the rpc_head_block != consensus_head_block, log something? - match &old_synced_connections.head_block_id { + match &old_synced_connections.head_block { None => { debug!( "first {}/{}/{} block={}, rpc={}", @@ -543,7 +543,7 @@ impl Web3Connections { match consensus_head_block.number().cmp(&old_head_block.number()) { Ordering::Equal => { - // TODO: if rpc_block_id != consensus_head_block_id, do a different log? + // TODO: if rpc_block_id != consensus_head_block, do a different log? // multiple blocks with the same fork! if consensus_head_block.hash() == old_head_block.hash() { diff --git a/web3_proxy/src/rpcs/connection.rs b/web3_proxy/src/rpcs/connection.rs index 16941e71..3998f6c3 100644 --- a/web3_proxy/src/rpcs/connection.rs +++ b/web3_proxy/src/rpcs/connection.rs @@ -7,7 +7,7 @@ use crate::config::BlockAndRpc; use crate::frontend::authorization::Authorization; use anyhow::Context; use ethers::prelude::{Bytes, Middleware, ProviderError, TxHash, H256, U64}; -use ethers::types::{Block, U256}; +use ethers::types::U256; use futures::future::try_join_all; use futures::StreamExt; use log::{debug, error, info, trace, warn, Level}; @@ -499,15 +499,15 @@ impl Web3Connection { let new_head_block = match new_head_block { Ok(None) => { { - let mut head_block_id = self.head_block.write(); + let mut head_block = self.head_block.write(); - if head_block_id.is_none() { + if head_block.is_none() { // we previously sent a None. return early return Ok(()); } warn!("{} is not synced!", self); - *head_block_id = None; + *head_block = None; } None @@ -536,9 +536,9 @@ impl Web3Connection { warn!("unable to get block from {}. err={:?}", self, err); { - let mut head_block_id = self.head_block.write(); + let mut head_block = self.head_block.write(); - *head_block_id = None; + *head_block = None; } None @@ -1082,8 +1082,8 @@ impl Serialize for Web3Connection { )?; // TODO: rename to head_block (need to work with the frontend team) - let head_block_id = &*self.head_block.read(); - state.serialize_field("head_block_id", head_block_id)?; + let head_block = &*self.head_block.read(); + state.serialize_field("head_block", head_block)?; state.end() } diff --git a/web3_proxy/src/rpcs/request.rs b/web3_proxy/src/rpcs/request.rs index 313944ab..ced5362e 100644 --- a/web3_proxy/src/rpcs/request.rs +++ b/web3_proxy/src/rpcs/request.rs @@ -8,7 +8,7 @@ use entities::revert_log; use entities::sea_orm_active_enums::Method; use ethers::providers::{HttpClientError, ProviderError, WsClientError}; use ethers::types::{Address, Bytes}; -use log::{debug, error, info, trace, warn, Level}; +use log::{debug, error, trace, warn, Level}; use metered::metered; use metered::HitCount; use metered::ResponseTime; diff --git a/web3_proxy/src/rpcs/synced_connections.rs b/web3_proxy/src/rpcs/synced_connections.rs index 7101ffdd..f6a5e288 100644 --- a/web3_proxy/src/rpcs/synced_connections.rs +++ b/web3_proxy/src/rpcs/synced_connections.rs @@ -11,7 +11,7 @@ use std::sync::Arc; #[derive(Clone, Default, Serialize)] pub struct SyncedConnections { // TODO: store ArcBlock instead? - pub(super) head_block_id: Option, + pub(super) head_block: Option, // TODO: this should be able to serialize, but it isn't #[serde(skip_serializing)] pub(super) conns: Vec>, @@ -22,31 +22,31 @@ impl fmt::Debug for SyncedConnections { // TODO: the default formatter takes forever to write. this is too quiet though // TODO: print the actual conns? f.debug_struct("SyncedConnections") - .field("head_block_id", &self.head_block_id) + .field("head_block", &self.head_block) .field("num_conns", &self.conns.len()) .finish_non_exhaustive() } } impl Web3Connections { - pub fn head_block_id(&self) -> Option { - self.synced_connections.load().head_block_id.clone() + pub fn head_block(&self) -> Option { + self.synced_connections.load().head_block.clone() } pub fn head_block_hash(&self) -> Option { self.synced_connections .load() - .head_block_id + .head_block .as_ref() - .map(|head_block_id| head_block_id.hash()) + .map(|head_block| head_block.hash()) } pub fn head_block_num(&self) -> Option { self.synced_connections .load() - .head_block_id + .head_block .as_ref() - .map(|head_block_id| head_block_id.number()) + .map(|head_block| head_block.number()) } pub fn synced(&self) -> bool {