fn default() -> Self {
        // WARNING: this directory default should be always overwritten with parameters
        // from cli for specific networks.
        let network_dir = dirs::home_dir()
            .unwrap_or_else(|| PathBuf::from("."))
            .join(DEFAULT_ROOT_DIR)
            .join(DEFAULT_HARDCODED_NETWORK)
            .join(DEFAULT_BEACON_NODE_DIR)
            .join(DEFAULT_NETWORK_DIR);

        // The function used to generate a gossipsub message id
        // We use the first 8 bytes of SHA256(data) for content addressing
        let fast_gossip_message_id = |message: &RawGossipsubMessage| {
            FastMessageId::from(&Sha256::digest(&message.data)[..8])
        };

        fn prefix(prefix: [u8; 4], data: &[u8]) -> Vec<u8> {
            let mut vec = Vec::with_capacity(prefix.len() + data.len());
            vec.extend_from_slice(&prefix);
            vec.extend_from_slice(data);
            vec
        }

        let gossip_message_id = |message: &GossipsubMessage| {
            MessageId::from(
                &Sha256::digest(prefix(MESSAGE_DOMAIN_VALID_SNAPPY, &message.data).as_slice())
                    [..20],
            )
        };

        // gossipsub configuration
        // Note: The topics by default are sent as plain strings. Hashes are an optional
        // parameter.
        let gs_config = GossipsubConfigBuilder::default()
            .max_transmit_size(GOSSIP_MAX_SIZE)
            .heartbeat_interval(Duration::from_millis(700))
            .mesh_n(8)
            .mesh_n_low(MESH_N_LOW)
            .mesh_n_high(12)
            .gossip_lazy(6)
            .fanout_ttl(Duration::from_secs(60))
            .history_length(6)
            .max_messages_per_rpc(Some(10))
            .history_gossip(3)
            .validate_messages() // require validation before propagation
            .validation_mode(ValidationMode::Anonymous)
            // prevent duplicates for 550 heartbeats(700millis * 550) = 385 secs
            .duplicate_cache_time(Duration::from_secs(385))
            .message_id_fn(gossip_message_id)
            .fast_message_id_fn(fast_gossip_message_id)
            .allow_self_origin(true)
            .build()
            .expect("valid gossipsub configuration");

        // discv5 configuration
        let discv5_config = Discv5ConfigBuilder::new()
            .enable_packet_filter()
            .session_cache_capacity(1000)
            .request_timeout(Duration::from_secs(1))
            .query_peer_timeout(Duration::from_secs(2))
            .query_timeout(Duration::from_secs(30))
            .request_retries(1)
            .enr_peer_update_min(10)
            .query_parallelism(5)
            .disable_report_discovered_peers()
            .ip_limit() // limits /24 IP's in buckets.
            .ping_interval(Duration::from_secs(300))
            .build();

        // NOTE: Some of these get overridden by the corresponding CLI default values.
        Config {
            network_dir,
            listen_address: "0.0.0.0".parse().expect("valid ip address"),
            libp2p_port: 9000,
            discovery_port: 9000,
            enr_address: None,
            enr_udp_port: None,
            enr_tcp_port: None,
            target_peers: 50,
            gs_config,
            discv5_config,
            boot_nodes_enr: vec![],
            boot_nodes_multiaddr: vec![],
            libp2p_nodes: vec![],
            trusted_peers: vec![],
            client_version: lighthouse_version::version_with_platform(),
            disable_discovery: false,
            upnp_enabled: true,
            private: false,
            subscribe_all_subnets: false,
            import_all_attestations: false,
            topics: Vec::new(),
        }
    }
/// Generate a default network configuration.
Generate a default network configuration.
Generate a default network configuration .
fn default() -> Self {
        // WARNING: this directory default should be always overwritten with parameters
        // from cli for specific networks.
        let network_dir = dirs::home_dir()
            .unwrap_or_else(|| PathBuf::from("."))
            .join(DEFAULT_ROOT_DIR)
            .join(DEFAULT_HARDCODED_NETWORK)
            .join(DEFAULT_BEACON_NODE_DIR)
            .join(DEFAULT_NETWORK_DIR);
        // The function used to generate a gossipsub message id
        // We use the first 8 bytes of SHA256(data) for content addressing
        let fast_gossip_message_id = |message: &RawGossipsubMessage| {
            FastMessageId::from(&Sha256::digest(&message.data)[..8])
        };
        fn prefix(prefix: [u8; 4], data: &[u8]) -> Vec<u8> {
            let mut vec = Vec::with_capacity(prefix.len() + data.len());
            vec.extend_from_slice(&prefix);
            vec.extend_from_slice(data);
            vec
        }
        let gossip_message_id = |message: &GossipsubMessage| {
            MessageId::from(
                &Sha256::digest(prefix(MESSAGE_DOMAIN_VALID_SNAPPY, &message.data).as_slice())
                    [..20],
            )
        };
        // gossipsub configuration
        // Note: The topics by default are sent as plain strings. Hashes are an optional
        // parameter.
        let gs_config = GossipsubConfigBuilder::default()
            .max_transmit_size(GOSSIP_MAX_SIZE)
            .heartbeat_interval(Duration::from_millis(700))
            .mesh_n(8)
            .mesh_n_low(MESH_N_LOW)
            .mesh_n_high(12)
            .gossip_lazy(6)
            .fanout_ttl(Duration::from_secs(60))
            .history_length(6)
            .max_messages_per_rpc(Some(10))
            .history_gossip(3)
            .validate_messages() // require validation before propagation
            .validation_mode(ValidationMode::Anonymous)
            // prevent duplicates for 550 heartbeats(700millis * 550) = 385 secs
            .duplicate_cache_time(Duration::from_secs(385))
            .message_id_fn(gossip_message_id)
            .fast_message_id_fn(fast_gossip_message_id)
            .allow_self_origin(true)
            .build()
            .expect("valid gossipsub configuration");
        // discv5 configuration
        let discv5_config = Discv5ConfigBuilder::new()
            .enable_packet_filter()
            .session_cache_capacity(1000)
            .request_timeout(Duration::from_secs(1))
            .query_peer_timeout(Duration::from_secs(2))
            .query_timeout(Duration::from_secs(30))
            .request_retries(1)
            .enr_peer_update_min(10)
            .query_parallelism(5)
            .disable_report_discovered_peers()
            .ip_limit() // limits /24 IP's in buckets.
            .ping_interval(Duration::from_secs(300))
            .build();
        // NOTE: Some of these get overridden by the corresponding CLI default values.
        Config {
            network_dir,
            listen_address: "0.0.0.0".parse().expect("valid ip address"),
            libp2p_port: 9000,
            discovery_port: 9000,
            enr_address: None,
            enr_udp_port: None,
            enr_tcp_port: None,
            target_peers: 50,
            gs_config,
            discv5_config,
            boot_nodes_enr: vec![],
            boot_nodes_multiaddr: vec![],
            libp2p_nodes: vec![],
            trusted_peers: vec![],
            client_version: lighthouse_version::version_with_platform(),
            disable_discovery: false,
            upnp_enabled: true,
            private: false,
            subscribe_all_subnets: false,
            import_all_attestations: false,
            topics: Vec::new(),
        }
    }
fn default ( ) -> Self { // WARNING: this directory default should be always overwritten with parameters // from cli for specific networks. let network_dir = dirs :: home_dir ( ) . unwrap_or_else ( | | PathBuf :: from ( " " ) ) . join ( DEFAULT_ROOT_DIR ) . join ( DEFAULT_HARDCODED_NETWORK ) . join ( DEFAULT_BEACON_NODE_DIR ) . join ( DEFAULT_NETWORK_DIR ) ; // The function used to generate a gossipsub message id // We use the first 8 bytes of SHA256(data) for content addressing let fast_gossip_message_id = | message : & RawGossipsubMessage | { FastMessageId :: from ( & Sha256 :: digest ( & message . data ) [ .. 8 ] ) } ; fn prefix ( prefix : [ u8 ; 4 ] , data : & [ u8 ] ) -> Vec < u8 > { let mut vec = Vec :: with_capacity ( prefix . len ( ) + data . len ( ) ) ; vec . extend_from_slice ( & prefix ) ; vec . extend_from_slice ( data ) ; vec } let gossip_message_id = | message : & GossipsubMessage | { MessageId :: from ( & Sha256 :: digest ( prefix ( MESSAGE_DOMAIN_VALID_SNAPPY , & message . data ) . as_slice ( ) ) [ .. 20 ] , ) } ; // gossipsub configuration // Note: The topics by default are sent as plain strings. Hashes are an optional // parameter. let gs_config = GossipsubConfigBuilder :: default ( ) . max_transmit_size ( GOSSIP_MAX_SIZE ) . heartbeat_interval ( Duration :: from_millis ( 700 ) ) . mesh_n ( 8 ) . mesh_n_low ( MESH_N_LOW ) . mesh_n_high ( 12 ) . gossip_lazy ( 6 ) . fanout_ttl ( Duration :: from_secs ( 60 ) ) . history_length ( 6 ) . max_messages_per_rpc ( Some ( 10 ) ) . history_gossip ( 3 ) . validate_messages ( ) // require validation before propagation . validation_mode ( ValidationMode :: Anonymous ) // prevent duplicates for 550 heartbeats(700millis * 550) = 385 secs . duplicate_cache_time ( Duration :: from_secs ( 385 ) ) . message_id_fn ( gossip_message_id ) . fast_message_id_fn ( fast_gossip_message_id ) . allow_self_origin ( true ) . build ( ) . expect ( " " ) ; // discv5 configuration let discv5_config = Discv5ConfigBuilder :: new ( ) . enable_packet_filter ( ) . session_cache_capacity ( 1000 ) . request_timeout ( Duration :: from_secs ( 1 ) ) . query_peer_timeout ( Duration :: from_secs ( 2 ) ) . query_timeout ( Duration :: from_secs ( 30 ) ) . request_retries ( 1 ) . enr_peer_update_min ( 10 ) . query_parallelism ( 5 ) . disable_report_discovered_peers ( ) . ip_limit ( ) // limits /24 IP's in buckets. . ping_interval ( Duration :: from_secs ( 300 ) ) . build ( ) ; // NOTE: Some of these get overridden by the corresponding CLI default values. Config { network_dir , listen_address : " " . parse ( ) . expect ( " " ) , libp2p_port : 9000 , discovery_port : 9000 , enr_address : None , enr_udp_port : None , enr_tcp_port : None , target_peers : 50 , gs_config , discv5_config , boot_nodes_enr : vec ! [ ] , boot_nodes_multiaddr : vec ! [ ] , libp2p_nodes : vec ! [ ] , trusted_peers : vec ! [ ] , client_version : lighthouse_version :: version_with_platform ( ) , disable_discovery : false , upnp_enabled : true , private : false , subscribe_all_subnets : false , import_all_attestations : false , topics : Vec :: new ( ) , } }
Generate a default network configuration.
Generate a default network configuration .