From 2544e3608d99db1bd904ed960de2fe4e2c263571 Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Tue, 21 Nov 2023 23:39:16 -0400 Subject: [PATCH] simpler Debug impl --- web3_proxy/src/rpcs/blockchain.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/web3_proxy/src/rpcs/blockchain.rs b/web3_proxy/src/rpcs/blockchain.rs index 68b00eef..d59db09e 100644 --- a/web3_proxy/src/rpcs/blockchain.rs +++ b/web3_proxy/src/rpcs/blockchain.rs @@ -8,6 +8,7 @@ use moka::future::Cache; use serde::ser::SerializeStruct; use serde::Serialize; use serde_json::json; +use std::fmt::Debug; use std::hash::Hash; use std::time::Duration; use std::{fmt::Display, sync::Arc}; @@ -24,9 +25,18 @@ pub type BlocksByNumberCache = Cache; /// A block and its age with a less verbose serialized format /// This does **not** implement Default. We rarely want a block with number 0 and hash 0. -#[derive(Clone, Debug)] +#[derive(Clone)] pub struct Web3ProxyBlock(pub ArcBlock); +impl Debug for Web3ProxyBlock { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("Web3ProxyBlock") + .field("number", &self.number()) + .field("hash", &self.hash()) + .finish() + } +} + impl Serialize for Web3ProxyBlock { fn serialize(&self, serializer: S) -> Result where