Skip to content

Commit

Permalink
Reduces network debug output for regtest and default testnet (#8760)
Browse files Browse the repository at this point in the history
Co-authored-by: Pili Guerra <[email protected]>
  • Loading branch information
arya2 and mpguerra authored Aug 15, 2024
1 parent ec48599 commit 9dfb143
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion zebra-chain/src/parameters/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl From<Network> for NetworkKind {
}

/// An enum describing the possible network choices.
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize)]
#[derive(Clone, Default, Eq, PartialEq, Serialize)]
#[serde(into = "NetworkKind")]
pub enum Network {
/// The production mainnet.
Expand Down Expand Up @@ -121,6 +121,22 @@ impl fmt::Display for Network {
}
}

impl std::fmt::Debug for Network {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Mainnet => write!(f, "{self}"),
Self::Testnet(params) if params.is_regtest() => f
.debug_struct("Regtest")
.field("activation_heights", params.activation_heights())
.finish(),
Self::Testnet(params) if params.is_default_testnet() => {
write!(f, "{self}")
}
Self::Testnet(params) => f.debug_tuple("ConfiguredTestnet").field(params).finish(),
}
}
}

impl Network {
/// Creates a new [`Network::Testnet`] with the default Testnet [`testnet::Parameters`].
pub fn new_default_testnet() -> Self {
Expand Down

0 comments on commit 9dfb143

Please sign in to comment.