mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-01 12:11:20 +00:00
*: Derive Debug
and Clone
(#2495)
Co-authored-by: Max Inden <mail@max-inden.de>
This commit is contained in:
parent
9f1114d8b9
commit
65cc8994a6
@ -63,7 +63,7 @@ use std::convert::{TryFrom, TryInto};
|
||||
/// let keypair = Keypair::rsa_from_pkcs8(&mut bytes);
|
||||
/// ```
|
||||
///
|
||||
#[derive(Clone)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum Keypair {
|
||||
/// An Ed25519 keypair.
|
||||
Ed25519(ed25519::Keypair),
|
||||
|
@ -33,6 +33,14 @@ use zeroize::Zeroize;
|
||||
#[derive(Clone)]
|
||||
pub struct Keypair(Arc<RsaKeyPair>);
|
||||
|
||||
impl std::fmt::Debug for Keypair {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
f.debug_struct("Keypair")
|
||||
.field("public", self.0.public_key())
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl Keypair {
|
||||
/// Decode an RSA keypair from a DER-encoded private key in PKCS#8 PrivateKeyInfo
|
||||
/// format (i.e. unencrypted) as defined in [RFC5208].
|
||||
|
@ -198,7 +198,7 @@ where
|
||||
}
|
||||
|
||||
/// The yamux configuration.
|
||||
#[derive(Clone)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct YamuxConfig {
|
||||
inner: yamux::Config,
|
||||
mode: Option<yamux::Mode>,
|
||||
|
@ -37,6 +37,7 @@ pub use self::protocol::{FloodsubMessage, FloodsubRpc};
|
||||
pub use self::topic::Topic;
|
||||
|
||||
/// Configuration options for the Floodsub protocol.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct FloodsubConfig {
|
||||
/// Peer id of the local node. Used for the source of the messages that we publish.
|
||||
pub local_peer_id: PeerId,
|
||||
|
@ -149,6 +149,7 @@ pub enum GossipsubEvent {
|
||||
/// A data structure for storing configuration for publishing messages. See [`MessageAuthenticity`]
|
||||
/// for further details.
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
#[derive(Clone)]
|
||||
enum PublishConfig {
|
||||
Signing {
|
||||
keypair: Keypair,
|
||||
|
@ -40,6 +40,7 @@ const DEFAULT_MAX_TOPICS: usize = 300;
|
||||
// store metrics.
|
||||
const DEFAULT_MAX_NEVER_SUBSCRIBED_TOPICS: usize = 50;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Config {
|
||||
/// This provides an upper bound to the number of mesh topics we create metrics for. It
|
||||
/// prevents unbounded labels being created in the metrics.
|
||||
|
@ -44,7 +44,7 @@ use unsigned_varint::codec;
|
||||
pub(crate) const SIGNING_PREFIX: &[u8] = b"libp2p-pubsub:";
|
||||
|
||||
/// Implementation of [`InboundUpgrade`] and [`OutboundUpgrade`] for the Gossipsub protocol.
|
||||
#[derive(Clone)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ProtocolConfig {
|
||||
/// The Gossipsub protocol id to listen on.
|
||||
protocol_ids: Vec<ProtocolId>,
|
||||
|
@ -82,7 +82,7 @@ enum Reply {
|
||||
|
||||
/// Configuration for the [`Identify`] [`NetworkBehaviour`].
|
||||
#[non_exhaustive]
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct IdentifyConfig {
|
||||
/// Application-specific version of the protocol family used by the peer,
|
||||
/// e.g. `ipfs/1.0.0` or `polkadot/1.0.0`.
|
||||
|
@ -44,7 +44,7 @@ pub struct MemoryStore {
|
||||
}
|
||||
|
||||
/// Configuration for a `MemoryStore`.
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct MemoryStoreConfig {
|
||||
/// The maximum number of records.
|
||||
pub max_records: usize,
|
||||
|
@ -49,7 +49,7 @@ lazy_static! {
|
||||
}
|
||||
|
||||
/// Configuration for mDNS.
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct MdnsConfig {
|
||||
/// TTL to use for mdns records.
|
||||
pub ttl: Duration,
|
||||
|
@ -38,7 +38,7 @@ use std::{
|
||||
use void::Void;
|
||||
|
||||
/// The configuration for outbound pings.
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Config {
|
||||
/// The timeout of an outbound ping.
|
||||
timeout: Duration,
|
||||
|
@ -102,7 +102,7 @@ enum IncomingRelayReq {
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct RelayConfig {
|
||||
/// How long to keep connections alive when they're idle.
|
||||
///
|
||||
|
@ -37,6 +37,7 @@ use std::fmt;
|
||||
use std::task::{Context, Poll};
|
||||
use std::time::Duration;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct RelayHandlerConfig {
|
||||
pub connection_idle_timeout: Duration,
|
||||
}
|
||||
|
@ -61,6 +61,28 @@ pub struct Config {
|
||||
pub circuit_src_rate_limiters: Vec<Box<dyn rate_limiter::RateLimiter>>,
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for Config {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
f.debug_struct("Config")
|
||||
.field("max_reservations", &self.max_reservations)
|
||||
.field("max_reservations_per_peer", &self.max_reservations_per_peer)
|
||||
.field("reservation_duration", &self.reservation_duration)
|
||||
.field(
|
||||
"reservation_rate_limiters",
|
||||
&format!("[{} rate limiters]", self.reservation_rate_limiters.len()),
|
||||
)
|
||||
.field("max_circuits", &self.max_circuits)
|
||||
.field("max_circuits_per_peer", &self.max_circuits_per_peer)
|
||||
.field("max_circuit_duration", &self.max_circuit_duration)
|
||||
.field("max_circuit_bytes", &self.max_circuit_bytes)
|
||||
.field(
|
||||
"circuit_src_rate_limiters",
|
||||
&format!("[{} rate limiters]", self.circuit_src_rate_limiters.len()),
|
||||
)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Config {
|
||||
fn default() -> Self {
|
||||
let reservation_rate_limiters = vec![
|
||||
|
@ -44,6 +44,7 @@ use std::fmt;
|
||||
use std::task::{Context, Poll};
|
||||
use std::time::Duration;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Config {
|
||||
pub reservation_duration: Duration,
|
||||
pub max_circuit_duration: Duration,
|
||||
|
@ -84,7 +84,7 @@ mod generic {
|
||||
}
|
||||
|
||||
/// Configuration for a [`RateLimiter`].
|
||||
#[derive(Clone, Copy)]
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct RateLimiterConfig {
|
||||
/// The maximum number of tokens in the bucket at any point in time.
|
||||
pub limit: NonZeroU32,
|
||||
|
Loading…
x
Reference in New Issue
Block a user