Reduces network debug output for regtest and default testnet (#8760)

Co-authored-by: Pili Guerra <mpguerra@users.noreply.github.com>
This commit is contained in:
Arya 2024-08-15 16:33:12 -04:00 committed by GitHub
parent ec48599cac
commit 9dfb14365f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 17 additions and 1 deletions

View File

@ -41,7 +41,7 @@ impl From<Network> for NetworkKind {
} }
/// An enum describing the possible network choices. /// An enum describing the possible network choices.
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize)] #[derive(Clone, Default, Eq, PartialEq, Serialize)]
#[serde(into = "NetworkKind")] #[serde(into = "NetworkKind")]
pub enum Network { pub enum Network {
/// The production mainnet. /// The production mainnet.
@ -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 { impl Network {
/// Creates a new [`Network::Testnet`] with the default Testnet [`testnet::Parameters`]. /// Creates a new [`Network::Testnet`] with the default Testnet [`testnet::Parameters`].
pub fn new_default_testnet() -> Self { pub fn new_default_testnet() -> Self {