fn default() -> Self {
        let agent_version = format!(
            "{}/{}/{}",
            DEFAULT_CLIENT_NAME,
            format!("v{}", env!("CARGO_PKG_VERSION")),
            format!("{}-{}", Target::arch(), Target::os()),
        );

        let mut network_dir = dirs::home_dir().unwrap_or_else(|| PathBuf::from("."));
        network_dir.push(format!(".{}", DEFAULT_CLIENT_NAME));
        network_dir.push("network");

        // The function used to generate a gossipsub message id
        // We use base64(SHA256(data)) for content addressing
        let gossip_message_id = |message: &GossipsubMessage| {
            MessageId(base64::encode_config(
                &Sha256::digest(&message.data),
                base64::URL_SAFE,
            ))
        };

        // gossipsub configuration
        // Note: The topics by default are sent as plain strings. Hashes are an optional
        // parameter.
        let gs_config = GossipsubConfigBuilder::new()
            .max_transmit_size(GOSSIP_MAX_SIZE)
            .heartbeat_interval(Duration::from_secs(1))
            .manual_propagation() // require validation before propagation
            .no_source_id()
            .message_id_fn(gossip_message_id)
            .build();

        // discv5 configuration
        let discv5_config = Discv5ConfigBuilder::new()
            .enable_packet_filter()
            .session_cache_capacity(1000)
            .request_timeout(Duration::from_secs(4))
            .request_retries(2)
            .enr_peer_update_min(2) // prevents NAT's should be raised for mainnet
            .query_parallelism(5)
            .query_timeout(Duration::from_secs(30))
            .query_peer_timeout(Duration::from_secs(2))
            .ip_limit() // limits /24 IP's in buckets.
            .ping_interval(Duration::from_secs(300))
            .build();

        Config {
            agent_version,
            protocol_version: format!("{}/libp2p", DEFAULT_CLIENT_NAME),
            network_dir,
            listen_address: "127.0.0.1".parse().expect("valid ip address"),
            libp2p_port: 9000,
            discovery_port: 9000,
            enr_address: None,
            enr_udp_port: None,
            enr_tcp_port: None,
            max_peers: 50,
            secret_key_hex: None,
            gs_config,
            discv5_config,
            boot_nodes: vec![],
            libp2p_nodes: vec![],
            disable_discovery: false,
            topics: vec![],
            propagation_percentage: None,
        }
    }
/// Generate a default network configuration.
Generate a default network configuration.
Generate a default network configuration .
fn default() -> Self {
        let agent_version = format!(
            "{}/{}/{}",
            DEFAULT_CLIENT_NAME,
            format!("v{}", env!("CARGO_PKG_VERSION")),
            format!("{}-{}", Target::arch(), Target::os()),
        );
        let mut network_dir = dirs::home_dir().unwrap_or_else(|| PathBuf::from("."));
        network_dir.push(format!(".{}", DEFAULT_CLIENT_NAME));
        network_dir.push("network");
        // The function used to generate a gossipsub message id
        // We use base64(SHA256(data)) for content addressing
        let gossip_message_id = |message: &GossipsubMessage| {
            MessageId(base64::encode_config(
                &Sha256::digest(&message.data),
                base64::URL_SAFE,
            ))
        };
        // gossipsub configuration
        // Note: The topics by default are sent as plain strings. Hashes are an optional
        // parameter.
        let gs_config = GossipsubConfigBuilder::new()
            .max_transmit_size(GOSSIP_MAX_SIZE)
            .heartbeat_interval(Duration::from_secs(1))
            .manual_propagation() // require validation before propagation
            .no_source_id()
            .message_id_fn(gossip_message_id)
            .build();
        // discv5 configuration
        let discv5_config = Discv5ConfigBuilder::new()
            .enable_packet_filter()
            .session_cache_capacity(1000)
            .request_timeout(Duration::from_secs(4))
            .request_retries(2)
            .enr_peer_update_min(2) // prevents NAT's should be raised for mainnet
            .query_parallelism(5)
            .query_timeout(Duration::from_secs(30))
            .query_peer_timeout(Duration::from_secs(2))
            .ip_limit() // limits /24 IP's in buckets.
            .ping_interval(Duration::from_secs(300))
            .build();
        Config {
            agent_version,
            protocol_version: format!("{}/libp2p", DEFAULT_CLIENT_NAME),
            network_dir,
            listen_address: "127.0.0.1".parse().expect("valid ip address"),
            libp2p_port: 9000,
            discovery_port: 9000,
            enr_address: None,
            enr_udp_port: None,
            enr_tcp_port: None,
            max_peers: 50,
            secret_key_hex: None,
            gs_config,
            discv5_config,
            boot_nodes: vec![],
            libp2p_nodes: vec![],
            disable_discovery: false,
            topics: vec![],
            propagation_percentage: None,
        }
    }
fn default ( ) -> Self { let agent_version = format ! ( " " DEFAULT_CLIENT_NAME format ( " " env ( " " ) ) format ( " " Target arch ( ) Target os ( ) ) ) ; let mut network_dir = dirs :: home_dir ( ) . unwrap_or_else ( | | PathBuf :: from ( " " ) ) ; network_dir . push ( format ! ( " " DEFAULT_CLIENT_NAME ) ) ; network_dir . push ( " " ) ; // The function used to generate a gossipsub message id // We use base64(SHA256(data)) for content addressing let gossip_message_id = | message : & GossipsubMessage | { MessageId ( base64 :: encode_config ( & Sha256 :: digest ( & message . data ) , base64 :: URL_SAFE , ) ) } ; // gossipsub configuration // Note: The topics by default are sent as plain strings. Hashes are an optional // parameter. let gs_config = GossipsubConfigBuilder :: new ( ) . max_transmit_size ( GOSSIP_MAX_SIZE ) . heartbeat_interval ( Duration :: from_secs ( 1 ) ) . manual_propagation ( ) // require validation before propagation . no_source_id ( ) . message_id_fn ( gossip_message_id ) . build ( ) ; // discv5 configuration let discv5_config = Discv5ConfigBuilder :: new ( ) . enable_packet_filter ( ) . session_cache_capacity ( 1000 ) . request_timeout ( Duration :: from_secs ( 4 ) ) . request_retries ( 2 ) . enr_peer_update_min ( 2 ) // prevents NAT's should be raised for mainnet . query_parallelism ( 5 ) . query_timeout ( Duration :: from_secs ( 30 ) ) . query_peer_timeout ( Duration :: from_secs ( 2 ) ) . ip_limit ( ) // limits /24 IP's in buckets. . ping_interval ( Duration :: from_secs ( 300 ) ) . build ( ) ; Config { agent_version , protocol_version : format ! ( " " DEFAULT_CLIENT_NAME ) , network_dir , listen_address : " " . parse ( ) . expect ( " " ) , libp2p_port : 9000 , discovery_port : 9000 , enr_address : None , enr_udp_port : None , enr_tcp_port : None , max_peers : 50 , secret_key_hex : None , gs_config , discv5_config , boot_nodes : vec ! [ ] , libp2p_nodes : vec ! [ ] , disable_discovery : false , topics : vec ! [ ] , propagation_percentage : None , } }
Generate a default network configuration.
Generate a default network configuration .