pub fn new(
        local_key: &Keypair,
        config: &NetworkConfig,
        network_globals: Arc<NetworkGlobals>,
        log: &slog::Logger,
    ) -> error::Result<Self> {
        // start the discovery service
        let mut discovery = Discovery::new(local_key, config, network_globals.clone(), log)?;

        // start searching for peers
        discovery.discover_peers();

        let heartbeat = tokio::time::interval(tokio::time::Duration::from_secs(HEARTBEAT_INTERVAL));

        Ok(PeerManager {
            network_globals,
            events: SmallVec::new(),
            ping_peers: HashSetDelay::new(Duration::from_secs(PING_INTERVAL)),
            status_peers: HashSetDelay::new(Duration::from_secs(STATUS_INTERVAL)),
            target_peers: config.max_peers, //TODO: Add support for target peers and max peers
            discovery,
            heartbeat,
            log: log.clone(),
        })
    }
// NOTE: Must be run inside a tokio executor.
Must be run inside a tokio executor.
Must be run inside a tokio executor .
pub fn new(
        local_key: &Keypair,
        config: &NetworkConfig,
        network_globals: Arc<NetworkGlobals>,
        log: &slog::Logger,
    ) -> error::Result<Self> {
        // start the discovery service
        let mut discovery = Discovery::new(local_key, config, network_globals.clone(), log)?;
        // start searching for peers
        discovery.discover_peers();
        let heartbeat = tokio::time::interval(tokio::time::Duration::from_secs(HEARTBEAT_INTERVAL));
        Ok(PeerManager {
            network_globals,
            events: SmallVec::new(),
            ping_peers: HashSetDelay::new(Duration::from_secs(PING_INTERVAL)),
            status_peers: HashSetDelay::new(Duration::from_secs(STATUS_INTERVAL)),
            target_peers: config.max_peers, //TODO: Add support for target peers and max peers
            discovery,
            heartbeat,
            log: log.clone(),
        })
    }
pub fn new ( local_key : & Keypair , config : & NetworkConfig , network_globals : Arc < NetworkGlobals > , log : & slog :: Logger , ) -> error :: Result < Self > { // start the discovery service let mut discovery = Discovery :: new ( local_key , config , network_globals . clone ( ) , log ) ? ; // start searching for peers discovery . discover_peers ( ) ; let heartbeat = tokio :: time :: interval ( tokio :: time :: Duration :: from_secs ( HEARTBEAT_INTERVAL ) ) ; Ok ( PeerManager { network_globals , events : SmallVec :: new ( ) , ping_peers : HashSetDelay :: new ( Duration :: from_secs ( PING_INTERVAL ) ) , status_peers : HashSetDelay :: new ( Duration :: from_secs ( STATUS_INTERVAL ) ) , target_peers : config . max_peers , //TODO: Add support for target peers and max peers discovery , heartbeat , log : log . clone ( ) , } ) }
NOTE: Must be run inside a tokio executor.
NOTE : Must be run inside a tokio executor .
local_key
&Keypair
config
&NetworkConfig
network_globals
Arc<NetworkGlobals>
log
&slog::Logger
local_key
&Keypair
config
&NetworkConfig
network_globals
Arc<NetworkGlobals>
log
&slog::Logger