runtime/cpp/src/network/NetworkManager.cpp
// A listener can keep a peer alive, so we need a shared_ptr
A listener can keep a peer alive, so we need a shared_ptr
A listener can keep a peer alive so we need a shared_ptr
void NetworkManager::listenInternal(shared_ptr<Peer> peer) {
  auto fac_ptr = 
      [](asio::io_service& service, CodecFormat format) {
        return make_shared<InternalIncomingConnection>(service, format);
      };
  auto listen_addr = peer->address();
  auto listener = make_shared<Listener>(io_service_, listen_addr, peer,
                                        internal_format_, fac_ptr);
  internal_listeners_->insert(listen_addr, listener);
  auto e_handler =
      [listeners = internal_listeners_, listen_addr](boost_error ec) {
        throw std::runtime_error("Listener error handler: " + ec.message());
        listeners->erase(listen_addr);
      };
  listener->acceptConnection(e_handler);
}
void NetworkManager :: listenInternal ( shared_ptr < Peer > peer ) { auto fac_ptr = [ ] ( asio :: io_service & service , CodecFormat format ) { return make_shared < InternalIncomingConnection > ( service , format ) ; } ; auto listen_addr = peer -> address ( ) ; auto listener = make_shared < Listener > ( io_service_ , listen_addr , peer , internal_format_ , fac_ptr ) ; internal_listeners_ -> insert ( listen_addr , listener ) ; auto e_handler = [ listeners = internal_listeners_ , listen_addr ] ( boost_error ec ) { throw std :: runtime_error ( " " + ec . message ( ) ) ; listeners -> erase ( listen_addr ) ; } ; listener -> acceptConnection ( e_handler ) ; }
A listener can keep a peer alive, so we need a shared_ptr
A listener can keep a peer alive so we need a shared_ptr
// Construct Listener // Accept connections, removing the listener upon error