mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 03:01:07 +00:00
Implement Debug for some structures (#3941)
* Implement Debug for some structures `NetworkConfiguration`, `TransportConfig`, `NodeKeyConfig` and `Secret`. Needs a new release of the `rust-libp2p` crate. This PR is just a reminder. * Explicitly separate `std` and `core` * Add manual implementation for Secret
This commit is contained in:
@@ -28,12 +28,11 @@ use crate::service::{ExHashT, TransactionPool};
|
||||
use bitflags::bitflags;
|
||||
use consensus::{block_validation::BlockAnnounceValidator, import_queue::ImportQueue};
|
||||
use sr_primitives::traits::{Block as BlockT};
|
||||
use std::sync::Arc;
|
||||
use libp2p::identity::{Keypair, ed25519};
|
||||
use libp2p::wasm_ext;
|
||||
use libp2p::{PeerId, Multiaddr, multiaddr};
|
||||
use std::error::Error;
|
||||
use std::{io::{self, Write}, iter, fmt, fs, net::Ipv4Addr, path::{Path, PathBuf}};
|
||||
use core::{fmt, iter};
|
||||
use std::{error::Error, fs, io::{self, Write}, net::Ipv4Addr, path::{Path, PathBuf}, sync::Arc};
|
||||
use zeroize::Zeroize;
|
||||
|
||||
/// Network initialization parameters.
|
||||
@@ -234,7 +233,7 @@ impl From<multiaddr::Error> for ParseErr {
|
||||
}
|
||||
|
||||
/// Network service configuration.
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct NetworkConfiguration {
|
||||
/// Directory path to store general network configuration. None means nothing will be saved.
|
||||
pub config_path: Option<String>,
|
||||
@@ -317,7 +316,7 @@ impl NetworkConfiguration {
|
||||
}
|
||||
|
||||
/// Configuration for the transport layer.
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum TransportConfig {
|
||||
/// Normal transport mode.
|
||||
Normal {
|
||||
@@ -362,7 +361,7 @@ impl NonReservedPeerMode {
|
||||
/// The configuration of a node's secret key, describing the type of key
|
||||
/// and how it is obtained. A node's identity keypair is the result of
|
||||
/// the evaluation of the node key configuration.
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum NodeKeyConfig {
|
||||
/// A Ed25519 secret key configuration.
|
||||
Ed25519(Secret<ed25519::SecretKey>)
|
||||
@@ -386,6 +385,16 @@ pub enum Secret<K> {
|
||||
New
|
||||
}
|
||||
|
||||
impl<K> fmt::Debug for Secret<K> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
Secret::Input(_) => f.debug_tuple("Secret::Input").finish(),
|
||||
Secret::File(path) => f.debug_tuple("Secret::File").field(path).finish(),
|
||||
Secret::New => f.debug_tuple("Secret::New").finish(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl NodeKeyConfig {
|
||||
/// Evaluate a `NodeKeyConfig` to obtain an identity `Keypair`:
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user