From 1666a455640116a962fd1303de45b4c7f6f5beee Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Tue, 10 Oct 2023 21:30:55 -0700 Subject: [PATCH] faster head_block_num --- web3_proxy/src/rpcs/consensus.rs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/web3_proxy/src/rpcs/consensus.rs b/web3_proxy/src/rpcs/consensus.rs index 96866ca8..613e259a 100644 --- a/web3_proxy/src/rpcs/consensus.rs +++ b/web3_proxy/src/rpcs/consensus.rs @@ -436,22 +436,18 @@ impl RankedRpcs { // TODO: refs for all of these. borrow on a Sender is cheap enough // TODO: move this to many.rs impl Web3Rpcs { + #[inline] pub fn head_block(&self) -> Option { self.watch_head_block .as_ref() .and_then(|x| x.borrow().clone()) } - /// note: you probably want to use `head_block` instead - /// TODO: return a ref? - pub fn head_block_hash(&self) -> Option { - self.head_block().map(|x| *x.hash()) - } - - /// note: you probably want to use `head_block` instead - /// TODO: return a ref? + #[inline] pub fn head_block_num(&self) -> Option { - self.head_block().map(|x| x.number()) + self.watch_head_block + .as_ref() + .and_then(|x| x.borrow().as_ref().map(|x| x.number())) } pub fn synced(&self) -> bool {